= minus
+strand, C = plus strand, and C<_> = no frame info, C<0,1,2> = respective
+(absolute) frame. The L<_context()> method will convert a (strand,
+frame) specification to a context string, e.g.:
+
+ $context = $self->_context(-strand=>-1, -frame=>-2);
+
+returns C.
+
+The contexts present among the HSPs in a hit are identified and stored
+for convenience upon object construction. These are accessed off the
+object with the L method. If contexts don't apply for the
+given report, this returns C<('all')>.
+
=head1 DESIGN NOTE
The major calculations are made just-in-time, and then memoized. So,
@@ -112,7 +136,7 @@
use warnings;
# Object preamble - inherits from Bio::Root::Root
-use lib '../../..';
+#use lib '../../..';
use Bio::Root::Root;
use Bio::Search::Tiling::TilingI;
@@ -130,44 +154,59 @@
Function: Builds a new Bio::Search::Tiling::GenericTiling object
Returns : an instance of Bio::Search::Tiling::GenericTiling
Args : -hit => $a_Bio_Search_Hit_HitI_object
- filtering args for nucleotide data:
- -qstrand => [[ 1 | -1 ]]
- -hstrand => [[ 1 | -1 ]]
- -qframe => [[ -2 | -1 | 0 | 1 | 2 ]]
- -hframe => [[ -2 | -1 | 0 | 1 | 2 ]]
- Note : Not all filters are valid for all BLAST/FAST
- algorithms. The constructor will warn when,
- e.g., -qstrand is set for BLASTP data.
-
+ general filter function:
+ -hsp_filter => sub { my $this_hsp = shift;
+ ...;
+ return 1 if $wanted;
+ return 0; }
=cut
sub new {
my $class = shift;
my @args = @_;
- my $self = $class->SUPER::new;
- my($hit, $qstrand, $hstrand, $qframe, $hframe) = $self->_rearrange( [qw( HIT QSTRAND HSTRAND QFRAME HFRAME )], at args );
+ my $self = $class->SUPER::new(@args);
+ my($hit, $filter) = $self->_rearrange( [qw( HIT HSP_FILTER)], at args );
$self->throw("HitI object required") unless $hit;
$self->throw("Argument must be HitI object") unless ( ref $hit && $hit->isa('Bio::Search::Hit::HitI') );
$self->{hit} = $hit;
+ $self->_set_mapping();
+ $self->{"_algorithm"} = $hit->algorithm;
my @hsps;
- $self->_check_new_args($qstrand, $hstrand, $qframe, $hframe);
- # filter if requested
- while (local $_ = $hit->next_hsp) {
- push @hsps, $_ if ( ( !$qstrand || ($qstrand == $_->strand('query'))) &&
- ( !$hstrand || ($hstrand == $_->strand('hit')) ) &&
- ( !defined $qframe || ($qframe == $_->frame('query')) ) &&
- ( !defined $hframe || ($hframe == $_->frame('hit')) ) );
+ # apply filter function if requested
+ if ( defined $filter ) {
+ if ( ref($filter) eq 'CODE' ) {
+ @hsps = map { $filter->($_) ? $_ : () } @hsps;
+ }
+ else {
+ $self->warn("-filter is not a coderef; ignoring");
+ }
}
+ else {
+ @hsps = $hit->hsps;
+ }
+
+ # identify available contexts
+ for my $t qw( query hit ) {
+ my %contexts;
+ if ($self->_has_logical_length($t)) {
+ for my $i (0..$#hsps) {
+ my $ctxt = $self->_context(-strand => $hsps[$i]->strand($t),
+ -frame => $hsps[$i]->frame($t));
+ $contexts{$ctxt} ||= [];
+ push @{$contexts{$ctxt}}, $i;
+ }
+ }
+ else {
+ $contexts{'all'} = [(0..$#hsps)];
+ }
+ $self->{"_contexts_${t}"} = \%contexts;
+ }
+
$self->warn("No HSPs present in hit after filtering") unless (@hsps);
$self->hsps(\@hsps);
- $self->_set_mapping();
- $self->{"strand_query"} = $qstrand;
- $self->{"strand_hit"} = $hstrand;
- $self->{"frame_query"} = $qframe;
- $self->{"strand_hit"} = $hframe;
return $self;
}
@@ -220,26 +259,29 @@
=head2 identities
Title : identities
- Usage : $tiling->identities($type, $action)
+ Usage : $tiling->identities($type, $action, $context)
Function: Retrieve the calculated number of identities for the invocant
Example :
Returns : value of identities (a scalar)
Args : scalar $type: one of 'hit', 'subject', 'query'
default is 'query'
- option scalar $action: one of 'exact', 'est', 'max'
+ option scalar $action: one of 'exact', 'est', 'fast', 'max'
default is 'exact'
+ option scalar $context: strand/frame context string
Note : getter only
+
=cut
sub identities{
my $self = shift;
- my ($type, $action) = @_;
+ my ($type, $action, $context) = @_;
$self->_check_type_arg(\$type);
$self->_check_action_arg(\$action);
- if (!defined $self->{"identities_${type}_${action}"}) {
- $self->_calc_stats($type, $action);
+ $self->_check_context_arg($type, \$context);
+ if (!defined $self->{"identities_${type}_${action}_${context}"}) {
+ $self->_calc_stats($type, $action, $context);
}
- return $self->{"identities_${type}_${action}"};
+ return $self->{"identities_${type}_${action}_${context}"};
}
=head2 conserved
@@ -251,100 +293,115 @@
Returns : value of conserved (a scalar)
Args : scalar $type: one of 'hit', 'subject', 'query'
default is 'query'
- option scalar $action: one of 'exact', 'est', 'max'
+ option scalar $action: one of 'exact', 'est', 'fast', 'max'
default is 'exact'
+ option scalar $context: strand/frame context string
Note : getter only
=cut
sub conserved{
my $self = shift;
- my ($type, $action) = @_;
+ my ($type, $action, $context) = @_;
$self->_check_type_arg(\$type);
$self->_check_action_arg(\$action);
- if (!defined $self->{"conserved_${type}_${action}"}) {
- $self->_calc_stats($type, $action);
+ $self->_check_context_arg($type, \$context);
+ if (!defined $self->{"conserved_${type}_${action}_${context}"}) {
+ $self->_calc_stats($type, $action, $context);
}
- return $self->{"conserved_${type}_${action}"};
+ return $self->{"conserved_${type}_${action}_${context}"};
}
=head2 length
Title : length
- Usage : $tiling->length($type, $action)
+ Usage : $tiling->length($type, $action, $context)
Function: Retrieve the total length of aligned residues for
the seq $type
Example :
Returns : value of length (a scalar)
Args : scalar $type: one of 'hit', 'subject', 'query'
default is 'query'
- option scalar $action: one of 'exact', 'est', 'max'
+ option scalar $action: one of 'exact', 'est', 'fast', 'max'
default is 'exact'
+ option scalar $context: strand/frame context string
Note : getter only
=cut
sub length{
my $self = shift;
- my ($type,$action) = @_;
+ my ($type,$action,$context) = @_;
$self->_check_type_arg(\$type);
$self->_check_action_arg(\$action);
- if (!defined $self->{"length_${type}_${action}"}) {
- $self->_calc_stats($type, $action);
+ $self->_check_context_arg($type, \$context);
+ if (!defined $self->{"length_${type}_${action}_${context}"}) {
+ $self->_calc_stats($type, $action, $context);
}
- return $self->{"length_${type}_${action}"};
+ return $self->{"length_${type}_${action}_${context}"};
}
-=head2 frac_identical
+=head2 frac
- Title : frac_identical
- Usage : $tiling->frac_identical($type, $denom)
+ Title : frac
+ Usage : $tiling->frac($type, $denom, $action, $context, $method)
Function: Return the fraction of sequence length consisting
- of identical pairs, with respect to $denom
+ of desired kinds of pairs (given by $method),
+ with respect to $denom
Returns : scalar float
- Args : scalar $type, one of 'hit', 'subject', 'query'
- scalar $denom, one of 'total', 'aligned'
- Note : $denom == 'aligned', return identities/num_aligned
- $denom == 'total', return identities/_reported_length
+ Args : -type => one of 'hit', 'subject', 'query'
+ -denom => one of 'total', 'aligned'
+ -action => one of 'exact', 'est', 'fast', 'max'
+ -context => strand/frame context string
+ -method => one of 'identical', 'conserved'
+ Note : $denom == 'aligned', return desired_stat/num_aligned
+ $denom == 'total', return desired_stat/_reported_length
(i.e., length of the original input sequences)
-
+ Note : In keeping with the spirit of Bio::Search::HSP::HSPI,
+ reported lengths of translated dna are reduced by
+ a factor of 3, to provide fractions relative to
+ amino acid coordinates.
+
=cut
-sub frac_identical {
- my ($self, $type, $denom) = @_;
- if (@_ == 1) {
- $type = '';
- $self->_check_type_arg(\$type); # set default
- $denom = 'total'; # is this the right default?
+sub frac {
+ my $self = shift;
+ my @args = @_;
+ my ($type, $denom, $action, $context, $method) = $self->_rearrange([qw(TYPE DENOM ACTION CONTEXT METHOD)], at args);
+ $self->_check_type_arg(\$type);
+ $self->_check_action_arg(\$action);
+ $self->_check_context_arg($type, \$context);
+ unless ($method and grep(/^$method$/, qw( identical conserved ))) {
+ $self->throw("-method must specified; one of ('identical', 'conserved')");
}
- elsif (@_ == 2) {
@@ Diff output truncated at 10000 characters. @@
From bugzilla-daemon at portal.open-bio.org Sun May 31 16:26:34 2009
From: bugzilla-daemon at portal.open-bio.org (bugzilla-daemon at portal.open-bio.org)
Date: Sun, 31 May 2009 16:26:34 -0400
Subject: [Bioperl-guts-l] [Bug 2844] New: Patch to add "revtrans" method to
Bio::Tools::SeqPattern
Message-ID:
http://bugzilla.open-bio.org/show_bug.cgi?id=2844
Summary: Patch to add "revtrans" method to Bio::Tools::SeqPattern
Product: BioPerl
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: bioperl-dev
AssignedTo: bioperl-guts-l at bioperl.org
ReportedBy: vecchi.b at gmail.com
The attached patch adds one method to Bio::Tools::SeqPattern: revtrans. This
method reverse translates a Bio::Tools::SeqPattern instance of the type "Amino"
into a Bio::Tools::SeqPattern instance of the type "Dna". It was discussed in
the mailing list as a valuable addition, and it has already been accepted as a
script.
Regarding its addition as a method, Heikki Lehvaslaiho had concerns about it
making the module slower. Therefore, I attach the results of a benchmark (and
the script that runs it), proving that it doesn't significantly lower the speed
of the original methods of the SeqPattern module.
The patch produces the following modifications:
Bio/Tools/SeqPattern.pm: it adds the "revtrans" method, along with its
documentation. This method is simply a thin wrapper over the main
"_reverse_translate_motif" method of the Bio/Tools/SeqPattern/Revtrans.pm
module. The latter is only 'require-d', and the helper subroutine only imported
when the "revtrans" method is called.
Bio/Tools/SeqPattern/Revtrans.pm: This module contains all of the logic for the
"revtrans" subroutine, and exports the "_reverse_translate_motif" subroutine
upon demand from the main SeqPattern module.
t/SeqTools/Revtrans.t: new test file for for the Revtrans.pm module.
t/SeqTools/SeqPatternt: Added tests to assess the correct functionality and
error checking of the new method.
Needless to say; if the patch is accepted I'd gladly assume the commitment to
maintain it.
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
From bugzilla-daemon at portal.open-bio.org Sun May 31 16:27:32 2009
From: bugzilla-daemon at portal.open-bio.org (bugzilla-daemon at portal.open-bio.org)
Date: Sun, 31 May 2009 16:27:32 -0400
Subject: [Bioperl-guts-l] [Bug 2844] Patch to add "revtrans" method to
Bio::Tools::SeqPattern
In-Reply-To:
Message-ID: <200905312027.n4VKRWSx030425@portal.open-bio.org>
http://bugzilla.open-bio.org/show_bug.cgi?id=2844
------- Comment #1 from vecchi.b at gmail.com 2009-05-31 16:27 EST -------
Created an attachment (id=1311)
--> (http://bugzilla.open-bio.org/attachment.cgi?id=1311&action=view)
The svn diff to apply the patch
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
From bugzilla-daemon at portal.open-bio.org Sun May 31 16:28:21 2009
From: bugzilla-daemon at portal.open-bio.org (bugzilla-daemon at portal.open-bio.org)
Date: Sun, 31 May 2009 16:28:21 -0400
Subject: [Bioperl-guts-l] [Bug 2844] Patch to add "revtrans" method to
Bio::Tools::SeqPattern
In-Reply-To:
Message-ID: <200905312028.n4VKSLNi030609@portal.open-bio.org>
http://bugzilla.open-bio.org/show_bug.cgi?id=2844
------- Comment #2 from vecchi.b at gmail.com 2009-05-31 16:28 EST -------
Created an attachment (id=1312)
--> (http://bugzilla.open-bio.org/attachment.cgi?id=1312&action=view)
The benchmarking script
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
From bugzilla-daemon at portal.open-bio.org Sun May 31 16:28:47 2009
From: bugzilla-daemon at portal.open-bio.org (bugzilla-daemon at portal.open-bio.org)
Date: Sun, 31 May 2009 16:28:47 -0400
Subject: [Bioperl-guts-l] [Bug 2844] Patch to add "revtrans" method to
Bio::Tools::SeqPattern
In-Reply-To:
Message-ID: <200905312028.n4VKSltE030650@portal.open-bio.org>
http://bugzilla.open-bio.org/show_bug.cgi?id=2844
------- Comment #3 from vecchi.b at gmail.com 2009-05-31 16:28 EST -------
Created an attachment (id=1313)
--> (http://bugzilla.open-bio.org/attachment.cgi?id=1313&action=view)
The results of the benchmark
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
From bugzilla-daemon at portal.open-bio.org Sun May 31 16:59:03 2009
From: bugzilla-daemon at portal.open-bio.org (bugzilla-daemon at portal.open-bio.org)
Date: Sun, 31 May 2009 16:59:03 -0400
Subject: [Bioperl-guts-l] [Bug 2844] Patch to add "revtrans" method to
Bio::Tools::SeqPattern
In-Reply-To:
Message-ID: <200905312059.n4VKx3bD032504@portal.open-bio.org>
http://bugzilla.open-bio.org/show_bug.cgi?id=2844
------- Comment #4 from cjfields at bioperl.org 2009-05-31 16:59 EST -------
'Revtrans' could mean 'reverse transcribe' or 'reverse translate'. In fact it
almost always means the former in my line of work, whereas you are using it to
mean the latter.
I suggest disambiguating that (maybe 'rtranlate' or 'revtranslate').
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
From maj at dev.open-bio.org Sun May 31 17:20:39 2009
From: maj at dev.open-bio.org (Mark Allen Jensen)
Date: Sun, 31 May 2009 17:20:39 -0400
Subject: [Bioperl-guts-l] [15724]
bioperl-dev/trunk/Bio/Search/Tiling/MapTiling.pm: context for tiling
iterator
Message-ID: <200905312120.n4VLKdrd001501@dev.open-bio.org>
Revision: 15724
Author: maj
Date: 2009-05-31 17:20:38 -0400 (Sun, 31 May 2009)
Log Message:
-----------
context for tiling iterator
Modified Paths:
--------------
bioperl-dev/trunk/Bio/Search/Tiling/MapTiling.pm
Modified: bioperl-dev/trunk/Bio/Search/Tiling/MapTiling.pm
===================================================================
--- bioperl-dev/trunk/Bio/Search/Tiling/MapTiling.pm 2009-05-31 00:21:22 UTC (rev 15723)
+++ bioperl-dev/trunk/Bio/Search/Tiling/MapTiling.pm 2009-05-31 21:20:38 UTC (rev 15724)
@@ -230,9 +230,10 @@
sub next_tiling{
my $self = shift;
- my $type = shift;
+ my ($type, $context) = @_;
$self->_check_type_arg(\$type);
- return $self->_tiling_iterator($type)->();
+ $self->_check_context_arg($type, \$context);
+ return $self->_tiling_iterator($type, $context)->();
}
=head2 rewind_tilings
@@ -249,9 +250,10 @@
sub rewind_tilings{
my $self = shift;
- my $type = shift;
+ my ($type,$context) = @_
$self->_check_type_arg(\$type);
- return $self->_tiling_iterator($type)->('REWIND');
+ $self->_check_context_arg($type, \$context);
+ return $self->_tiling_iterator($type, $context)->('REWIND');
}
=head2 STATISTICS
@@ -897,7 +899,7 @@
and returns only the maximum identites/positives over
overlapping HSP for the component interval. No averaging
is involved here.
- 'fast' is doesn't involve tiling at all (hence the name),
+ 'fast' doesn't involve tiling at all (hence the name),
but it seems like a very good estimate, and uses only
reported values, and so does not require sequence data. It
calculates an average of reported identities, conserved
From bugzilla-daemon at portal.open-bio.org Sun May 31 17:27:42 2009
From: bugzilla-daemon at portal.open-bio.org (bugzilla-daemon at portal.open-bio.org)
Date: Sun, 31 May 2009 17:27:42 -0400
Subject: [Bioperl-guts-l] [Bug 2844] Patch to add "revtrans" method to
Bio::Tools::SeqPattern
In-Reply-To:
Message-ID: <200905312127.n4VLRgQE001694@portal.open-bio.org>
http://bugzilla.open-bio.org/show_bug.cgi?id=2844
------- Comment #5 from jason at bioperl.org 2009-05-31 17:27 EST -------
or backtranslate - http://www.biorecipes.com/BackTranslate/code.html
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
From bugzilla-daemon at portal.open-bio.org Sun May 31 18:01:18 2009
From: bugzilla-daemon at portal.open-bio.org (bugzilla-daemon at portal.open-bio.org)
Date: Sun, 31 May 2009 18:01:18 -0400
Subject: [Bioperl-guts-l] [Bug 2844] Patch to add "revtrans" method to
Bio::Tools::SeqPattern
In-Reply-To:
Message-ID: <200905312201.n4VM1I3O003843@portal.open-bio.org>
http://bugzilla.open-bio.org/show_bug.cgi?id=2844
------- Comment #6 from vecchi.b at gmail.com 2009-05-31 18:01 EST -------
Created an attachment (id=1314)
--> (http://bugzilla.open-bio.org/attachment.cgi?id=1314&action=view)
diff file for the addition of "backtranslate" method
Good points. I've settled for "backtranslate", as per Jason's suggestion. The
new attached diff file contains the full patch with the replaced method and
file names.
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.