view release on metacpan or search on metacpan
Bio/Align/DNAStatistics.pm view on Meta::CPAN
return $results;
}
=head2 calc_average_KaKs
Title : calc_average_KaKs.
Useage : my $res= $stats->calc_average_KaKs($alnobj, 1000).
Function : calculates Nei_Gojobori stats for average of all
sequences in the alignment.
Args : A Bio::Align::AlignI compliant object such as a
Bio::SimpleAlign object, number of bootstrap iterations
(default 1000).
Returns : A reference to a hash of statistics as listed in Description.
=cut
sub calc_average_KaKs {
#calculates global value for sequences in alignment using bootstrapping
#this is quite slow (~10 seconds per 3 X 200nt seqs);
my ($self, $aln, $bootstrap_rpt) = @_;
$bootstrap_rpt ||= 1000;
Bio/Search/Hit/PsiBlastHit.pm view on Meta::CPAN
been found in a previous iteration.
This is only applicable to PSI-BLAST reports.
This method indicates if the hit was reported in the
"Sequences used in model and found again" section of the
PSI-BLAST report or if it was reported in the
"Sequences not found previously or not previously below threshold"
section of the PSI-BLAST report. Only for hits in iteration > 1.
Example : if( $sbjct->found_again()) { ... };
Returns : Boolean (1 or 0) for PSI-BLAST report iterations greater than 1.
Returns undef for PSI-BLAST report iteration 1 and non PSI_BLAST
reports.
Argument : none
Throws : none
See Also : L<found_again()|found_again>
=cut
#----------------
Bio/Search/Iteration/GenericIteration.pm view on Meta::CPAN
}
=head2 get_hit
See documentation in L<Bio::Search::Iteration::IterationI::get_hit()|Bio::Search::Iteration::IterationI>.
To free up the memory used by the get_hit() functionality, call free_hit_lookup().
This functionality might be useful at the Result level, too.
BlastResult::get_hit() would return a list of HitI objects for hits
that occur in multiple iterations.
=cut
sub get_hit {
my ($self,$name) = @_;
$self->_create_hit_lookup() unless defined $self->{'_hit_lookup'};
return $self->{'_hit_lookup'}->{"\U$name"};
}
Bio/Search/Iteration/IterationI.pm view on Meta::CPAN
# First, open up a SearchIO stream
use Bio::SearchIO;
my $file = shift or die "Usage: $0 <BLAST-report-file>\n";
my $in = Bio::SearchIO->new(-format => 'blast',
-file => $file # comment out this line to read STDIN
);
# Iterate over all results in the input stream
while (my $result = $in->next_result) {
printf "Result #%d: %s\n", $in->result_count, $result->to_string;
printf "Total Iterations: %d\n", $result->num_iterations();
# Iterate over all iterations and process old and new hits
# separately.
while( my $it = $result->next_iteration) {
printf "\nIteration %d\n", $it->number;
printf "Converged: %d\n", $it->converged;
# Print out the hits not found in previous iteration
printf "New hits: %d\n", $it->num_hits_new;
while( my $hit = $it->next_hit_new ) {
printf " %s, Expect=%g\n", $hit->name, $hit->expect;
Bio/Search/Iteration/IterationI.pm view on Meta::CPAN
Corresponds to subset A in the "Classification of Hits"
documentation section of this module.
Returns : A Bio::Search::Hit::HitI object or undef if there are no more.
Hits will be returned in the order in which they occur in the report
unless otherwise specified.
Args : none
See Also: L<hits>, L<Classification of Hits>
next_hit() iterates through all hits, including the new ones
for this iteration and those found in previous iterations.
You can interrogate each hit using L<Bio::Search::Hit::HitI::found_again>
to determine whether it is new or old.
To get just the new hits, use L<next_hit_new>.
To get just the old hits, use L<next_hit_old>.
=cut
sub next_hit {
my ($self,@args) = @_;
Bio/Search/Result/BlastResult.pm view on Meta::CPAN
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
Bio::Search::Result::BlastResult - Blast-specific subclass of Bio::Search::Result::GenericResult
=head1 SYNOPSIS
# Working with iterations (PSI-BLAST results)
$result->next_iteration();
$result->num_iterations();
$result->iteration();
$result->iterations();
# See Bio::Search::Result::GenericResult for information about working with Results.
# See L<Bio::Search::Iteration::IterationI|Bio::Search::Iteration::IterationI>
# for details about working with iterations.
# TODO:
# * Show how to configure a SearchIO stream so that it generates
# BlastResult objects.
=head1 DESCRIPTION
This object is a subclass of Bio::Search::Result::GenericResult
and provides some operations that facilitate working with BLAST
Bio/Search/Result/BlastResult.pm view on Meta::CPAN
use base qw(Bio::Search::Result::GenericResult);
=head2 new
Title : new
Usage : my $obj = Bio::Search::Result::BlastResult->new();
Function: Builds a new Bio::Search::Result::BlastResult object
Returns : Bio::Search::Result::BlastResult
Args : See Bio::Search::Result::GenericResult();
The following parameters are specific to BlastResult:
-iterations => array ref of Bio::Search::Iteration::IterationI objects
-inclusion_threshold => e-value threshold for inclusion in the
PSI-BLAST score matrix model (blastpgp)
=cut
sub new {
my($class,@args) = @_;
my $self = $class->SUPER::new(@args);
$self->{'_iterations'} = [];
$self->{'_iteration_index'} = 0;
$self->{'_iteration_count'} = 0;
my( $iters, $ithresh ) = $self->_rearrange([qw(ITERATIONS
INCLUSION_THRESHOLD)],@args);
$self->{'_inclusion_threshold'} = $ithresh; # This is a read-only variable
if( defined $iters ) {
$self->throw("Must define arrayref of Iterations when initializing a $class\n") unless ref($iters) =~ /array/i;
foreach my $i ( @{$iters} ) {
$self->add_iteration($i);
}
}
else {
# This shouldn't get called with the new SearchIO::blast.
print STDERR "BlastResult::new(): Not adding iterations.\n";
$self->{'_no_iterations'} = 1;
}
return $self;
}
=head2 hits
Title : hits
Usage : my @hits = $result->hits
Function: Returns the available hits for this Result
Returns : Array of L<Bio::Search::Hit::HitI> objects
Args : none
Note : This method overrides L<Bio::Search::Result::GenericResult::hits> to
take into account the possibility of multiple iterations, as occurs
in PSI-BLAST reports.
If there are multiple iterations, all 'new' hits for all iterations
are returned. These are the hits that did not occur in a previous
iteration.
See Also: L<Bio::Search::Result::GenericResult::hits>
=cut
sub hits {
my ($self) = shift;
if ($self->{'_no_iterations'}) {
return $self->SUPER::hits;
}
my @hits = ();
foreach my $it ($self->iterations) {
push @hits, $it->hits;
}
return @hits;
}
=head2 next_hit
Title : next_hit
Usage : while( $hit = $result->next_hit()) { ... }
Function: Returns the next available Hit object, representing potential
matches between the query and various entities from the database.
Returns : a Bio::Search::Hit::HitI object or undef if there are no more.
Args : none
Note : This method overrides L<Bio::Search::Result::GenericResult::next_hit>
to take into account the possibility of multiple iterations, as
occurs in PSI-BLAST reports.
If there are multiple iterations, calling next_hit() traverses the
all of the hits, old and new, for each iteration, calling next_hit()
on each iteration.
See Also: L<Bio::Search::Iteration::GenericIteration::next_hit>
=cut
sub next_hit {
my ($self,@args) = @_;
if ($self->{'_no_iterations'}) {
return $self->SUPER::next_hit(@args);
}
my $iter_index;
if (not defined $self->{'_last_hit'}) {
$iter_index = $self->{'_iter_index'} = $self->_next_iteration_index;
} else {
$iter_index = $self->{'_iter_index'};
}
return if $iter_index >= scalar @{$self->{'_iterations'}};
my $it = $self->{'_iterations'}->[$iter_index];
my $hit = $self->{'_last_hit'} = $it->next_hit;
return defined($hit) ? $hit : $self->next_hit;
}
=head2 num_hits
Title : num_hits
Usage : my $hitcount= $result->num_hits
Function: returns the number of hits for this query result
Returns : integer
Args : none
Note : This method overrides L<Bio::Search::Result::GenericResult::num_hits>
to take into account the possibility of multiple iterations, as
occurs in PSI-BLAST reports.
If there are multiple iterations, calling num_hits() returns the
number of 'new' hits for each iteration. These are the hits that did
not occur in a previous iteration.
See Also: L<Bio::Search::Result::GenericResult::num_hits>
=cut
sub num_hits{
my ($self) = shift;
if ($self->{'_no_iterations'}) {
return $self->SUPER::num_hits;
}
if (not defined $self->{'_iterations'}) {
$self->throw("Can't get Hits: data not collected.");
}
return scalar( $self->hits );
}
=head2 add_hit
Title : add_hit
Usage : $report->add_hit($hit)
Function: Adds a HitI to the stored list of hits
Bio/Search/Result/BlastResult.pm view on Meta::CPAN
$self->throw("Passed in a " .ref($hit).
" as a Iteration which is not a Bio::Search::Hit::HitI.");
}
return $iter->num_hits;
}
=head2 add_iteration
Title : add_iteration
Usage : $report->add_iteration($iteration)
Function: Adds a IterationI to the stored list of iterations
Returns : Number of IterationI currently stored
Args : Bio::Search::Iteration::IterationI
=cut
sub add_iteration {
my ($self,$i) = @_;
if( $i->isa('Bio::Search::Iteration::IterationI') ) {
push @{$self->{'_iterations'}}, $i;
$self->{'_iteration_count'}++;
} else {
$self->throw("Passed in a " .ref($i).
" as a Iteration which is not a Bio::Search::Iteration::IterationI.");
}
return scalar @{$self->{'_iterations'}};
}
=head2 next_iteration
Title : next_iteration
Usage : while( $it = $result->next_iteration()) { ... }
Function: Returns the next Iteration object, representing all hits
found within a given PSI-Blast iteration.
Returns : a Bio::Search::Iteration::IterationI object or undef if there are no more.
Args : none
=cut
sub next_iteration {
my ($self) = @_;
unless($self->{'_iter_queue_started'}) {
$self->{'_iter_queue'} = [$self->iterations()];
$self->{'_iter_queue_started'} = 1;
}
return shift @{$self->{'_iter_queue'}};
}
=head2 iteration
Usage : $iteration = $blast->iteration( $number );
Purpose : Get an IterationI object for the specified iteration
in the search result (PSI-BLAST).
Returns : Bio::Search::Iteration::IterationI object
Throws : Bio::Root::NoSuchThing exception if $number is not within
range of the number of iterations in this report.
Argument : integer (optional, if not specified get the last iteration)
First iteration = 1
=cut
sub iteration {
my ($self,$num) = @_;
$num = scalar @{$self->{'_iterations'}} unless defined $num;
unless ($num >= 1 and $num <= scalar $self->{'_iteration_count'}) {
$self->throw(-class=>'Bio::Root::NoSuchThing',
-text=>"No such iteration number: $num. Valid range=1-$self->{'_iteration_count'}",
-value=>$num);
}
return $self->{'_iterations'}->[$num-1];
}
=head2 num_iterations
Usage : $num_iterations = $blast->num_iterations;
Purpose : Get the number of iterations in the search result (PSI-BLAST).
Returns : Total number of iterations in the report
Argument : none (read-only)
=cut
sub num_iterations { shift->{'_iteration_count'} }
# Methods provided for consistency with BPpsilite.pm (now deprecated);
# these are now merely synonyms
=head2 number_of_iterations
Usage : $num_iterations = $blast->number_of_iterations;
Purpose : Get the number of iterations in the search result (PSI-BLAST).
Returns : Total number of iterations in the report
Argument : none (read-only)
Note : Alias of L<num_iterations>.
=cut
sub number_of_iterations { shift->num_iterations }
=head2 round
Usage : $round = $blast->round( $number );
Purpose : Get an IterationI object for the specified iteration
in the search result (PSI-BLAST).
Returns : Bio::Search::Iteration::IterationI object
Throws : Bio::Root::NoSuchThing exception if $number is not within
range of the number of iterations in this report.
Argument : integer (optional, if not specified get the last iteration)
First iteration = 1
Note : Alias of L<iteration>.
=cut
sub round { shift->iteration(@_) }
=head2 iterations
Title : iterations
Usage : my @iterations = $result->iterations
Function: Returns the IterationI objects contained within this Result
Returns : Array of L<Bio::Search::Iteration::IterationI> objects
Args : none
=cut
sub iterations {
my $self = shift;
my @its = ();
if( ref($self->{'_iterations'}) =~ /ARRAY/i ) {
@its = @{$self->{'_iterations'}};
}
return @its;
}
=head2 psiblast
Usage : if( $blast->psiblast ) { ... }
Purpose : Set/get a boolean indicator whether or not the report
is a PSI-BLAST report.
Returns : 1 if PSI-BLAST, undef if not.
Bio/Search/Result/BlastResult.pm view on Meta::CPAN
This is NOT the same as determining the number of hits via
the hits() method, which will return zero hits if there were no
hits in the report or if all hits were filtered out during the parse.
Thus, this method can be used to distinguish these possibilities
for hitless reports generated when filtering.
Returns : Boolean
Argument : (optional) integer indicating the iteration number (PSI-BLAST)
If iteration number is not specified and this is a PSI-BLAST result,
then this method will return true only if all iterations had
no hits found.
=cut
sub no_hits_found {
my ($self, $round) = @_;
my $result = 0; # final return value of this method.
# Watch the double negative!
# result = 0 means "yes hits were found"
# result = 1 means "no hits were found" (for the indicated iteration or all iterations)
# If a iteration was not specified and there were multiple iterations,
# this method should return true only if all iterations had no hits found.
if( not defined $round ) {
if( $self->{'_iterations'} > 1) {
$result = 1;
foreach my $i( 1..$self->{'_iterations'} ) {
if( not defined $self->{"_iteration_$i"}->{'_no_hits_found'} ) {
$result = 0;
last;
}
}
}
else {
$result = $self->{"_iteration_1"}->{'_no_hits_found'};
}
}
Bio/Search/Result/BlastResult.pm view on Meta::CPAN
Since this is an in-memory implementation
Returns : none
Args : none
=cut
sub rewind {
my $self = shift;
$self->SUPER::rewind(@_);
$self->{'_iteration_index'} = 0;
foreach ($self->iterations) {
$_->rewind;
}
}
=head2 inclusion_threshold
Title : inclusion_threshold
Usage : my $incl_thresh = $result->inclusion_threshold; (read-only)
Function: Gets the e-value threshold for inclusion in the PSI-BLAST
Bio/Search/Result/CrossMatchResult.pm view on Meta::CPAN
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
Bio::Search::Result::CrossMatchResult - CrossMatch-specific subclass of Bio::Search::Result::GenericResult
=head1 SYNOPSIS
# Working with iterations (CrossMatch results)
$result->next_iteration();
$result->num_iterations();
$result->iteration();
$result->iterations();
# See Bio::Search::Result::GenericResult for information about working with Results.
# See L<Bio::Search::Iteration::IterationI|Bio::Search::Iteration::IterationI>
# for details about working with iterations.
# TODO:
# * Show how to configure a SearchIO stream so that it generates
# CrossMatchResult objects.
=head1 DESCRIPTION
This object is a subclass of Bio::Search::Result::GenericResult
and provides some operations that facilitate working with CrossMatch
Bio/Search/Result/CrossMatchResult.pm view on Meta::CPAN
use base qw(Bio::Search::Result::GenericResult);
=head2 new
Title : new
Usage : my $obj = Bio::Search::Result::CrossMatchResult->new();
Function: Builds a new Bio::Search::Result::CrossMatchResult object
Returns : Bio::Search::Result::CrossMatchResult
Args : See Bio::Search::Result::GenericResult();
The following parameters are specific to CrossMatchResult:
-iterations => array ref of Bio::Search::Iteration::IterationI objects
-inclusion_threshold => e-value threshold for inclusion in the
CrossMatch score matrix model (blastpgp)
=cut
sub new {
my($class,@args) = @_;
my $self = $class->SUPER::new(@args);
$self->{'_iterations'} = [];
$self->{'_iteration_index'} = 0;
$self->{'_iteration_count'} = 0;
my( $iters, $ithresh ) = $self->_rearrange([qw(ITERATIONS
INCLUSION_THRESHOLD)],@args);
$self->{'_inclusion_threshold'} = $ithresh; # This is a read-only variable
if( defined $iters ) {
$self->throw("Must define arrayref of Iterations when initializing a $class\n") unless ref($iters) =~ /array/i;
foreach my $i ( @{$iters} ) {
$self->add_iteration($i);
}
}
else {
# This shouldn't get called with the new SearchIO::blast.
#print STDERR "CrossMatchResult::new(): Not adding iterations.\n";
$self->{'_no_iterations'} = 1;
}
#$self->SUPER::algorithm('cross_match');
return $self;
}
=head2 hits
This method overrides L<Bio::Search::Result::GenericResult::hits> to take
into account the possibility of multiple iterations, as occurs in CrossMatch reports.
If there are multiple iterations, all 'new' hits for all iterations are returned.
These are the hits that did not occur in a previous iteration.
See Also: L<Bio::Search::Result::GenericResult::hits>
=cut
sub hits {
my ($self) = shift;
if ($self->{'_no_iterations'}) {
return $self->SUPER::hits;
}
my @hits = ();
foreach my $it ($self->iterations) {
push @hits, $it->hits;
}
return @hits;
}
=head2 next_hit
This method overrides L<Bio::Search::Result::GenericResult::next_hit> to take
into account the possibility of multiple iterations, as occurs in CrossMatch reports.
If there are multiple iterations, calling next_hit() traverses the
all of the hits, old and new, for each iteration, calling next_hit() on each iteration.
See Also: L<Bio::Search::Iteration::GenericIteration::next_hit>
=cut
sub next_hit {
my ($self,@args) = @_;
if ($self->{'_no_iterations'}) {
return $self->SUPER::next_hit(@args);
}
my $iter_index;
if (not defined $self->{'_last_hit'}) {
$iter_index = $self->{'_iter_index'} = $self->_next_iteration_index;
} else {
$iter_index = $self->{'_iter_index'};
}
return if $iter_index >= scalar @{$self->{'_iterations'}};
my $it = $self->{'_iterations'}->[$iter_index];
my $hit = $self->{'_last_hit'} = $it->next_hit;
return defined($hit) ? $hit : $self->next_hit;
}
=head2 num_hits
This method overrides L<Bio::Search::Result::GenericResult::num_hits> to take
into account the possibility of multiple iterations, as occurs in CrossMatch reports.
If there are multiple iterations, calling num_hits() returns the number of
'new' hits for each iteration. These are the hits that did not occur
in a previous iteration.
See Also: L<Bio::Search::Result::GenericResult::num_hits>
=cut
sub num_hits{
my ($self) = shift;
if ($self->{'_no_iterations'}) {
return $self->SUPER::num_hits;
}
if (not defined $self->{'_iterations'}) {
$self->throw("Can't get Hits: data not collected.");
}
return scalar( $self->hits );
}
=head2 add_iteration
Title : add_iteration
Usage : $report->add_iteration($iteration)
Function: Adds a IterationI to the stored list of iterations
Returns : Number of IterationI currently stored
Args : Bio::Search::Iteration::IterationI
=cut
sub add_iteration {
my ($self,$i) = @_;
if( $i->isa('Bio::Search::Iteration::IterationI') ) {
push @{$self->{'_iterations'}}, $i;
$self->{'_iteration_count'}++;
} else {
$self->throw("Passed in a " .ref($i).
" as a Iteration which is not a Bio::Search::IterationI.");
}
return scalar @{$self->{'_iterations'}};
}
=head2 next_iteration
Title : next_iteration
Usage : while( $it = $result->next_iteration()) { ... }
Function: Returns the next Iteration object, representing all hits
found within a given CrossMatch iteration.
Returns : a Bio::Search::Iteration::IterationI object or undef if there are no more.
Args : none
=cut
sub next_iteration {
my ($self) = @_;
unless($self->{'_iter_queue_started'}) {
$self->{'_iter_queue'} = [$self->iterations()];
$self->{'_iter_queue_started'} = 1;
}
return shift @{$self->{'_iter_queue'}};
}
=head2 iteration
Usage : $iteration = $blast->iteration( $number );
Purpose : Get an IterationI object for the specified iteration
in the search result (CrossMatch).
Returns : Bio::Search::Iteration::IterationI object
Throws : Bio::Root::NoSuchThing exception if $number is not within
range of the number of iterations in this report.
Argument : integer (optional, if not specified get the last iteration)
First iteration = 1
=cut
sub iteration {
my ($self,$num) = @_;
$num = scalar @{$self->{'_iterations'}} unless defined $num;
unless ($num >= 1 and $num <= scalar $self->{'_iteration_count'}) {
$self->throw(-class=>'Bio::Root::NoSuchThing',
-text=>"No such iteration number: $num. Valid range=1-$self->{'_iteration_count'}",
-value=>$num);
}
return $self->{'_iterations'}->[$num-1];
}
=head2 num_iterations
Usage : $num_iterations = $blast->num_iterations;
Purpose : Get the number of iterations in the search result (CrossMatch).
Returns : Total number of iterations in the report
Argument : none (read-only)
=cut
sub num_iterations { shift->{'_iteration_count'} }
# Methods provided for consistency with BPpsilite.pm (now deprecated);
# these are now merely synonyms
=head2 number_of_iterations
Same as L<num_iterations>.
=cut
sub number_of_iterations { shift->num_iterations }
=head2 round
Same as L<iteration>.
=cut
sub round { shift->iteration(@_) }
=head2 iterations
Title : iterations
Usage : my @iterations = $result->iterations
Function: Returns the IterationI objects contained within this Result
Returns : Array of L<Bio::Search::Iteration::IterationI> objects
Args : none
=cut
sub iterations {
my $self = shift;
my @its = ();
if( ref($self->{'_iterations'}) =~ /ARRAY/i ) {
@its = @{$self->{'_iterations'}};
}
return @its;
}
=head2 no_hits_found
Usage : $nohits = $blast->no_hits_found( $iteration_number );
Purpose : Get boolean indicator indicating whether or not any hits
were present in the report.
This is NOT the same as determining the number of hits via
the hits() method, which will return zero hits if there were no
hits in the report or if all hits were filtered out during the parse.
Thus, this method can be used to distinguish these possibilities
for hitless reports generated when filtering.
Returns : Boolean
Argument : (optional) integer indicating the iteration number (CrossMatch)
If iteration number is not specified and this is a CrossMatch result,
then this method will return true only if all iterations had
no hits found.
=cut
sub no_hits_found {
my ($self, $round) = @_;
my $result = 0; # final return value of this method.
# Watch the double negative!
# result = 0 means "yes hits were found"
# result = 1 means "no hits were found" (for the indicated iteration or all iterations)
# If a iteration was not specified and there were multiple iterations,
# this method should return true only if all iterations had no hits found.
if( not defined $round ) {
if( $self->{'_iterations'} > 1) {
$result = 1;
foreach my $i( 1..$self->{'_iterations'} ) {
if( not defined $self->{"_iteration_$i"}->{'_no_hits_found'} ) {
$result = 0;
last;
}
}
}
else {
$result = $self->{"_iteration_1"}->{'_no_hits_found'};
}
}
Bio/Search/Result/CrossMatchResult.pm view on Meta::CPAN
Since this is an in-memory implementation
Returns : none
Args : none
=cut
sub rewind {
my $self = shift;
$self->SUPER::rewind(@_);
$self->{'_iteration_index'} = 0;
foreach ($self->iterations) {
$_->rewind;
}
}
=head2 inclusion_threshold
Title : inclusion_threshold
Usage : my $incl_thresh = $result->inclusion_threshold; (read-only)
Function: Gets the e-value threshold for inclusion in the CrossMatch
Bio/Search/Result/ResultI.pm view on Meta::CPAN
my @hits = $self->hits();
eval {@sorted_hits = sort $coderef @hits };
if ($@) {
$self->throw("Unable to sort hits: $@");
}
else {
$self->{'_hits'} = \@sorted_hits;
$self->{'_no_iterations'} = 1; # to bypass iteration checking in hits() method
1;
}
}
=head2 _default sort_hits
Title : _default_sort_hits
Usage : Do not call directly.
Function: Sort hits in descending order by score
Args : None
Bio/SearchIO/IteratedSearchResultEventBuilder.pm view on Meta::CPAN
Function: Begins a result event cycle
Returns : none
Args : Type of Report
=cut
sub start_result {
my $self = shift;
#print STDERR "ISREB: start_result()\n";
$self->SUPER::start_result(@_);
$self->{'_iterations'} = [];
$self->{'_iteration_count'} = 0;
$self->{'_old_hit_names'} = undef;
$self->{'_hit_names_below'} = undef;
return;
}
=head2 start_iteration
Title : start_iteration
Usage : $handler->start_iteration()
Bio/SearchIO/IteratedSearchResultEventBuilder.pm view on Meta::CPAN
$args{'-number'} = $self->{'_iteration_count'};
$args{'-oldhits_below'} = $self->{'_oldhits_below'};
$args{'-oldhits_newly_below'} = $self->{'_oldhits_newly_below'};
$args{'-oldhits_not_below'} = $self->{'_oldhits_not_below'};
$args{'-newhits_below'} = $self->{'_newhits_below'};
$args{'-newhits_not_below'} = $self->{'_newhits_not_below'};
$args{'-hit_factory'} = $self->factory('hit');
my $it = $self->factory('iteration')->create_object(%args);
push @{$self->{'_iterations'}}, $it;
return $it;
}
# Title : _add_hit (private function for internal use only)
# Purpose : Applies hit filtering and calls _store_hit if it passes filtering.
# Argument: Bio::Search::Hit::HitI object
sub _add_hit {
my ($self, $hit) = @_;
Bio/SearchIO/IteratedSearchResultEventBuilder.pm view on Meta::CPAN
sub _store_hit {
my ($self, $hit, $hit_name, $hit_signif) = @_;
my $ithresh = $self->{'_inclusion_threshold'};
# This is the assumption leading to Bug 1986. The assumption here is that
# the hit name is unique (and thus new), therefore any subsequent encounters
# with a hit containing the same name are filed as old hits. This isn't
# always true (see the bug report for a few examples). Adding an explicit
# check for the presence of iterations, adding to new hits otherwise.
if (exists $self->{'_old_hit_names'}->{$hit_name}
&& scalar @{$self->{_iterations}}) {
if (exists $self->{'_hit_names_below'}->{$hit_name}) {
push @{$self->{'_oldhits_below'}}, $hit;
} elsif ($hit_signif <= $ithresh) {
push @{$self->{'_oldhits_newly_below'}}, $hit;
} else {
push @{$self->{'_oldhits_not_below'}}, $hit;
}
} else {
if ($hit_signif <= $ithresh) {
push @{$self->{'_newhits_below'}}, $hit;
Bio/SearchIO/SearchResultEventBuilder.pm view on Meta::CPAN
}
delete $data->{'runid'};
}
my %args = map { my $v = $data->{$_}; s/RESULT//; ($_ => $v); }
grep { /^RESULT/ } keys %{$data};
$args{'-algorithm'} = uc( $args{'-algorithm_name'}
|| $data->{'RESULT-algorithm_name'}
|| $type);
($self->isa('Bio::SearchIO::IteratedSearchResultEventBuilder')) ?
( $args{'-iterations'} = $self->{'_iterations'} )
: ( $args{'-hits'} = $self->{'_hits'} );
my $result = $self->factory('result')->create_object(%args);
$result->hit_factory($self->factory('hit'));
($self->isa('Bio::SearchIO::IteratedSearchResultEventBuilder')) ?
( $self->{'_iterations'} = [] )
: ( $self->{'_hits'} = [] );
return $result;
}
=head2 start_hsp
Title : start_hsp
Usage : $handler->start_hsp($name,$data)
Function: Begins processing a HSP event
Bio/SearchIO/blast.pm view on Meta::CPAN
-best => boolean. Only process the best hit of each report;
default = false.
=cut
sub _initialize {
my ( $self, @args ) = @_;
$self->SUPER::_initialize(@args);
# Blast reports require a specialized version of the SREB due to the
# possibility of iterations (PSI-BLAST). Forwarding all arguments to it. An
# issue here is that we want to set new default object factories if none are
# supplied.
my $handler = Bio::SearchIO::IteratedSearchResultEventBuilder->new(@args);
$self->attach_EventHandler($handler);
# 2006-04-26 move this to the attach_handler function in this module so we
# can really reset the handler
# Optimization: caching
# the EventHandler since it is used a lot during the parse.
Bio/SearchIO/blast.pm view on Meta::CPAN
$self->element(
{
'Name' => 'BlastOutput_rid',
'Data' => $rid
}
);
}
# added Windows workaround for bug 1985
elsif (/^(Searching|Results from round)/) {
next unless $1 =~ /Results from round/;
$self->debug("blast.pm: Possible psi blast iterations found...\n");
$self->in_element('hsp')
&& $self->end_element( { 'Name' => 'Hsp' } );
$self->in_element('hit')
&& $self->end_element( { 'Name' => 'Hit' } );
if ( defined $seeniteration ) {
$self->within_element('iteration')
&& $self->end_element( { 'Name' => 'Iteration' } );
$self->start_element( { 'Name' => 'Iteration' } );
}
Bio/SearchIO/cross_match.pm view on Meta::CPAN
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
Bio::SearchIO::cross_match - CrossMatch-specific subclass of Bio::SearchIO
=head1 SYNOPSIS
# Working with iterations (CrossMatch results)
my $searchIO = Bio::SearchIO->new( -format => 'cross_match',
-file => "$file.screen.out" )
while(my $r = $searchIO->next_result) {
while(my $hit = $r->next_hit) {
while(my $hsp = $hit->next_hsp) {
#Do the processing here.
}
}
}
Bio/SeqIO/agave.pm view on Meta::CPAN
Method(s) that this method calls : _helper_store_attribute_list ,
_process_bio_sequence
=cut
sub _process_fragment_orientation {
my ($self, $line, $data_structure) = @_;
# counter to determine the number of iterations within this while loop.
my $count = 0;
# One or more <fragment_orientation>
while ($$line =~ /<fragment_orientation\s?(.*?)\s?>/) {
my $fragment_orientation;
$self->_helper_store_attribute_list($1, \$fragment_orientation);
$$line = $self->_readline;
# One <bio_sequence>
Bio/SeqIO/agave.pm view on Meta::CPAN
sub _process_annotations {
my ($self, $line) = @_;
# ( seq_feature | gene | comp_result )+
my $annotations;
$$line = $self->_readline;
my $count = 0; # counter to keep track of number of iterations in the loop.
# One or more of these:
while ($$line =~ /<(seq_feature|gene|comp_result)\s?(.*?)\s?>/) {
if ($$line =~ /<seq_feature\s?(.*?)\s?>/) {
my $seq_feature = $self->_process_seq_feature($line, $1);
push @{$annotations->{'seq_feature'}}, $seq_feature;
} elsif ($$line =~ /<gene\s?(.*?)\s?>/) {
examples/root/exceptions2.pl
examples/root/exceptions3.pl
examples/root/exceptions4.pl
examples/root/README
examples/searchio/blast_example.pl
examples/searchio/custom_writer.pl
examples/searchio/hitwriter.pl
examples/searchio/hspwriter.pl
examples/searchio/htmlwriter.pl
examples/searchio/psiblast_features.pl
examples/searchio/psiblast_iterations.pl
examples/searchio/rawwriter.pl
examples/searchio/resultwriter.pl
examples/searchio/waba2gff.pl
examples/searchio/waba2gff3.pl
examples/sirna/rnai_finder.cgi
examples/sirna/TAG
examples/structure/structure-io.pl
examples/subsequence.cgi
examples/tk/gsequence.pl
examples/tk/hitdisplay.pl
examples/searchio/psiblast_iterations.pl view on Meta::CPAN
#!/usr/bin/perl
# Demonstrates the use of a SearchIO parser for processing
# the iterations within a PSI-BLAST report.
#
# Usage:
# STDIN: none; supply filename of PSI-BLAST report on command-line
# STDOUT: information parsed from the input data.
# STDERR: errors.
#
# For more documentation about working with Iteration objects,
# see docs for:
# Bio::Search::Iteration::IterationI
#
examples/searchio/psiblast_iterations.pl view on Meta::CPAN
my $file = shift or die "Usage: $0 <BLAST-report-file>\n";
my $in = new Bio::SearchIO(-format => 'blast',
-file => $file, #comment this out to read STDIN
#-fh => \*ARGV, #uncomment this to read STDIN
);
# Iterate over all results in the input stream
while (my $result = $in->next_result) {
printf "Result #%d: %s\n", $in->result_count, $result->to_string;
printf "Total Iterations: %d\n", $result->num_iterations();
# Iterate over all iterations and process old and new hits
# separately.
while( my $it = $result->next_iteration) {
printf "\nIteration %d\n", $it->number;
printf "Converged: %d\n", $it->converged;
# Print out the hits not found in previous iteration
printf "New hits: %d\n", $it->num_hits_new;
while( my $hit = $it->next_hit_new ) {
printf " %s, Expect=%g\n", $hit->name, $hit->expect;
examples/tools/standaloneblast.pl view on Meta::CPAN
#################################################
# aligned_blast ():
#
#
# args:
# $queryseq - query sequence (can be filename (fasta), or Bio:Seq object)
# $queryaln - file containing alignment to be used to "jumpstart" psiblast in "-B mode"
# $queryaln *must contain $queryseq with the same name and length
# (psiblast is very picky)
# $queryalnformat - format of alignment (can = "fasta", "msf", etc)
# $jiter - number of iterations in psiblast run
# $maskvalue - threshold indicating how similar residues must be at a sequence location
# before position-specific-scoring matrix is used
# : "0" => use position specific matrix at all residues, or
# "100" => use default (eg BLOSUM) at all residues
# returns: nothing
# For this example, we'll compare the results of psiblast depending on whether psiblast itself is
# used to identify an alignment to use for blasting or whether an external alignment is given to
examples/tools/standaloneblast.pl view on Meta::CPAN
}
# Then we do a "plain" psiblast multiple-iteration search
print "\nBeginning multiple-iteration psiblast ... \n";
my $undefineB ;
$factory->B($undefineB);
my $tag2 = 'iterated';
$factory->j($jiter); # 'j' is blast parameter for # of iterations
my $report1 = $factory->blastpgp($queryseq);
my $total_iterations = $report1->number_of_iterations;
my $last_iteration = $report1->round($total_iterations);
while($sbjct = $last_iteration->next_result) {
$hashhits->{$sbjct->name} .= "$tag2";
}
# Now we compare the results of the searches
my $tagtype = 'iterated_or_jumpstart';
my $values = [ $tag1, $tag2];
examples/tools/standaloneblast.pl view on Meta::CPAN
(default = $queryalnformat) .
-do <int> : Number of test to be executed ("1" => vary parameters,
"3" => compare iterated & jumpstart psiblast.) If omitted,
three default tests performed.
-exec <str> : Blast executable to be used in example 1. Can be "blastall" or
"blastpgp" (default is "blastpgp").
-param <str> : Parameter to be varied in example 1. Any blast parameter
can be varied (default = 'MATRIX')
-paramvals <str>: String containing parameter values in example 1, separated
by ":"'s. (default = 'BLOSUM62:BLOSUM80:PAM70')
-iter <int> : Maximum number of iterations in psiblast in example 3 (default = 2)
-maskvals <str>: String containing mask threshold values (in per-cents) for example 3,
separated by ":"'s. (default = '50:75:25')
In addition, any valid Blast parameter can be set using the syntax "parameter=>value" as in "database=>swissprot"
So some typical command lines might be:
>standaloneblast.pl -do 1 -param expectation -paramvals '1e-10:1e-5'
or
>standaloneblast.pl -do 1 -exec blastall -param q -paramvals '-1:-7' -in='t/dna1.fa' "pr=>blastn" "d=>ecoli.nt"
or
maintenance/big_split/file_classification.csv view on Meta::CPAN
,"doc/Deobfuscator/cgi-bin/deob_interface.cgi"
,"doc/Deobfuscator/cgi-bin/deob_help.html"
,"doc/Deobfuscator/cgi-bin/deob_flowchart.png"
,"doc/Deobfuscator/Changes"
,"doc/Deobfuscator/MANIFEST"
,"examples/bioperl.pl"
,"examples/subsequence.cgi"
,"examples/searchio/resultwriter.pl"
,"examples/searchio/waba2gff3.pl"
,"examples/searchio/custom_writer.pl"
,"examples/searchio/psiblast_iterations.pl"
,"examples/searchio/psiblast_features.pl"
,"examples/searchio/waba2gff.pl"
,"examples/searchio/htmlwriter.pl"
,"examples/searchio/blast_example.pl"
,"examples/searchio/hitwriter.pl"
,"examples/searchio/hspwriter.pl"
,"examples/searchio/rawwriter.pl"
,"examples/root/exceptions3.pl"
,"examples/root/README"
,"examples/root/exceptions1.pl"
scripts/popgen/bp_heterogeneity_test.pl view on Meta::CPAN
use strict;
use warnings;
=head1 NAME
bp_heterogeneity_test - a test for distinguishing between selection and population expansion.
=head1 SYNOPSIS
heterogenetity_test -mut_1/--mutsyn synonymous_mut_count -mut_2/--mutnon nonsyn_mut_count -s/--smaplesize sample_size [-i/--iterations iterations] [-o/--observed observed_D] [-v/--verbose] [--silent ] [-m/--method tajimaD or fuD] [--precision]
=head2 DESCRIPTION
This is an implementation of the Heterogenetity test as described in
Hahn MW, Rausher MD, and Cunningham CW. 2002. Genetics 161(1):11-20.
=head2 OPTIONS
Options in brackets above are optional
-s or --samplesize samplesize
-mut_1 or --mutsyn synonymous mutation count
-mut_2 or --mutnon nonsynonmous mutation count
-i or --iterations number of iterations
-o or --observed observed D
-m or --method tajimaD or fuD for Tajima's D or Fu and Li's D
-v or --verbose print out extra verbose messages
--silent Be extra quiet
--precision Level of precision - specify the number of digits
(default 4)
=head2 AUTHOR Matthew Hahn E<lt>matthew.hahn-at-duke.eduE<gt>
For more information contact:
scripts/popgen/bp_heterogeneity_test.pl view on Meta::CPAN
use Getopt::Long;
use Bio::PopGen::Simulation::Coalescent;
use Bio::PopGen::Statistics;
use Bio::PopGen::Individual;
use Bio::PopGen::Genotype;
my $sample_size = 4;
my $mut_count_1 = 10; # synonymous
my $mut_count_2 = 20; # non-synonymous
my $iterations = 1;
my $verbose = 0;
my $observedD = undef;
my $method = 'fuD';
my $help = 0;
my $precision = '4'; # Let's make the random precision between
# 0->1 to 1000th digits
GetOptions(
's|samplesize|samp_size:i' => \$sample_size,
'mut_1|mutsyn:i' => \$mut_count_1,
'mut_2|mutnon:i' => \$mut_count_2,
'i|iterations:i' => \$iterations,
'o|obsered|observedD:f' => \$observedD,
'v|verbose' => \$verbose,
'm|method:s' => \$method,
'h|help' => \$help,
'silent' => sub { $verbose = -1; },
'p|precision:i' => \$precision,
);
if( $help ) {
system("perldoc",$0);
exit(0);
}
if( $method ne 'fuD' and $method ne 'tajimaD' ) {
die("available methods are [fu and li's D] (fuD) and Tajima's D (tajimaD)");
}
my @D_distribution;
printf("sample size is %d iteration count = %d\n", $sample_size,
$iterations);
my $sim = new Bio::PopGen::Simulation::Coalescent
(-sample_size => $sample_size);
for(my $iter = 0; $iter < $iterations; $iter++ ) {
my $tree = $sim->next_tree($sample_size);
my $f1 = 0;
if( $mut_count_1 > 0 ) {
$sim->add_Mutations($tree,$mut_count_1,$precision);
my @leaves = $tree->get_leaf_nodes;
# the outgroup is just an individual with the ancestral state
# (no mutations)
my $outgroup = new Bio::PopGen::Individual();
foreach my $m ( $leaves[0]->get_marker_names ) {
scripts/popgen/bp_heterogeneity_test.pl view on Meta::CPAN
print "(mutation count = $mut_count_2) D=$f2\n" if( $verbose >= 0);
}
my $deltaD = ( $f1 - $f2 );
push @D_distribution, $deltaD;
if( $iter % 10 == 0 && $iter > 0 ) {
print STDERR "iter = $iter\n";
}
}
if( defined $observedD && $iterations > 1 ) {
my @sortedD = sort { $a <=> $b } @D_distribution;
my $i;
for($i = 0; $i < scalar @sortedD; $i++ ) {
if( $sortedD[$i] > $observedD ) {
last;
}
}
printf( "index %d value=%.4f out of %d total (obs=%.4f)\n",
$i, $sortedD[$i], scalar @sortedD, $observedD);