Bio::EnsEMBL::Analysis::Tools::BPlite
Iteration
Toolbar
Summary
Bio::Tools:: BPlite::Iteration - object for parsing single iteration
of a PSIBLAST report
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
use Bio::Tools:: BPpsilite;
open FH, "t/psiblastreport.out";
$report = Bio::Tools::BPpsilite->new(-fh=>\*FH);
# determine number of iterations executed by psiblast
$total_iterations = $report->number_of_iterations;
$last_iteration = $report->round($total_iterations);
# Process only hits found in last iteration ...
$oldhitarray_ref = $last_iteration->oldhits;
HIT: while($sbjct = $last_iteration->nextSbjct) {
$id = $sbjct->name;
$is_old = grep /\Q$id\E/, @$oldhitarray_ref;
if ($is_old ){next HIT;}
# do something with new hit...
}
Description
See the documentation for BPpsilite.pm for a description of the
Iteration.pm module.
Methods
Methods description
Title : newhits Usage : $newhits = $obj->newhits(); Returns : reference to an array listing all the hits from the current iteration which were not identified in the previous iteration Args : none |
Title : nextSbjct Usage : $sbjct = $obj->nextSbjct(); Function : Method of iterating through all the Sbjct retrieved from parsing the report Example : while ( my $sbjct = $obj->nextSbjct ) {} Returns : next Sbjct object or undef if finished Args : |
Title : oldhits Usage : $oldhits = $obj->oldhits(); Returns : reference to an array listing all the hits from the current iteration which were identified and above threshold in the previous iteration Args : none |
Title : qlength Usage : $len = $obj->qlength(); Returns : length of query Args : none |
Title : query Usage : $query = $obj->query(); Function : returns the query object Example : Returns : query object Args : |
Methods code
sub _fastForward
{ my ($self) = @_;
return 0 if $self->{'REPORT_DONE'}; return 1 if $self->{'LASTLINE'} =~ /^>/;
my $FH = $self->{'FH'};
while(<$FH>) {
if ($_ =~ /^>|^Parameters|^\s+Database:/) {
$self->{'LASTLINE'} = $_;
return 1;
}
}
warning("Possible error while parsing BLAST report!");
}
1;
__END__ } |
sub _parseHeader
{ my ($self) = @_;
my (@old_hits, @new_hits);
my $FH = $self->{'FH'};
my $newhits_true = ($self->{'ROUND'} < 2) ? 1 : 0 ;
while(<$FH>) {
if ($_ =~ /(\w\w|.*|\w+.*)\s\s+(\d+)\s+([-\.e\d]+)$/) {
my $id= $1;
my $score= $2; my $evalue= $3; if ($newhits_true) { push ( @new_hits, $id);}
else { push (@old_hits, $id);}
}
elsif ($_ =~ /^Sequences not found previously/) {$newhits_true = 1 ;}
elsif ($_ =~ /^>/)
{$self->{'LASTLINE'} = $_;
$self->{'OLDHITS'} =\@ old_hits;
$self->{'NEWHITS'} =\@ new_hits;
$self->{'LASTLINE'} = $_;
return 1;
}
elsif ($_ =~ /^Parameters|^\s+Database:|^\s*Results from round\s+(d+)/) {
$self->{'LASTLINE'} = $_;
return 0; }
}
return 0;
} |
sub new
{ my ($caller, @args) = @_;
my $class = ref($caller) || $caller;
my $self = bless({}, $class);
($self->{'FH'},$self->{'PARENT'},$self->{'ROUND'}) =
rearrange([qw(FH
PARENT
ROUND
)],@args);
if((! ref($self->{'FH'})) ||
((ref($self->{'FH'}) ne 'GLOB') &&
(! $self->{'FH'}->isa('IO::Handle')))) {
throw("Expecting a GLOB reference, not $self->{'FH'} !");
}
$self->{'LASTLINE'} = "";
$self->{'QUERY'} = $self->{'PARENT'}->{'QUERY'};
$self->{'LENGTH'} = $self->{'PARENT'}->{'LENGTH'};
if ($self->_parseHeader) {$self->{'REPORT_DONE'} = 0} else {$self->{'REPORT_DONE'} = 1}
return $self;
} |
sub newhits
{shift->{'NEWHITS'} } |
sub nextSbjct
{ my ($self) = @_;
$self->_fastForward or return undef;
my $def = $self->{'LASTLINE'};
my $FH = $self->{'FH'};
while(<$FH>) {
if ($_ !~ /\w/) {next}
elsif ($_ =~ /Strand HSP/) {next} elsif ($_ =~ /^\s{0,2}Score/) {$self->{'LASTLINE'} = $_; last}
else {$def .= $_}
}
$def =~ s/\s+/ /g;
$def =~ s/\s+$//g;
$def =~ s/Length = ([\d,]+)$//g;
my $length = $1;
return 0 unless $def =~ /^>/;
$def =~ s/^>//;
my $sbjct = new Bio::EnsEMBL::Analysis::Tools::BPlite::Sbjct('-name'=>$def,
'-length'=>$length,
'-fh'=>$self->{'FH'},
'-lastline'=>$self->{'LASTLINE'},
'-parent'=>$self);
return $sbjct; } |
sub oldhits
{shift->{'OLDHITS'} } |
sub qlength
{shift->{'LENGTH'} } |
sub query
{shift->{'QUERY'} } |
General documentation
AUTHORS - Peter Schattner | Top |
BPlite.pm is copyright (C) 1999 by Ian Korf.
This software is provided "as is" without warranty of any kind.