Bio::EnsEMBL::Analysis::Tools::BPlite Iteration
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
Bio::Tools:: BPlite::Iteration - object for parsing single iteration
of a PSIBLAST report
Package variables
No package variables defined.
Included modules
Bio::EnsEMBL::Analysis::Tools::BPlite
Bio::EnsEMBL::Analysis::Tools::BPlite::Sbjct
Bio::EnsEMBL::Utils::Argument qw ( rearrange )
Bio::EnsEMBL::Utils::Exception qw ( throw warning )
Inherit
Unavailable
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
_fastForward
No description
Code
_parseHeader
No description
Code
new
No description
Code
newhitsDescriptionCode
nextSbjctDescriptionCode
oldhitsDescriptionCode
qlengthDescriptionCode
queryDescriptionCode
Methods description
newhitscode    nextTop
 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
nextSbjctcodeprevnextTop
 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 :
oldhitscodeprevnextTop
 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
qlengthcodeprevnextTop
 Title    : qlength
Usage : $len = $obj->qlength();
Returns : length of query
Args : none
querycodeprevnextTop
 Title    : query
Usage : $query = $obj->query();
Function : returns the query object
Example :
Returns : query object
Args :
Methods code
_fastForwarddescriptionprevnextTop
sub _fastForward {
  my ($self) = @_;
  return 0 if $self->{'REPORT_DONE'}; # empty report
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__
}
_parseHeaderdescriptionprevnextTop
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;	#not used currently
my $evalue= $3; #not used currently
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; # no sequences found in this iteration
} } return 0; # no sequences found in this iteration
}
newdescriptionprevnextTop
sub new {
    my ($caller, @args) = @_;
    # my $self = $class->SUPER::new(@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} # there are alignments
else {$self->{'REPORT_DONE'} = 1} # empty report
return $self; # success - we hope!
}
newhitsdescriptionprevnextTop
sub newhits {
shift->{'NEWHITS'}
}
nextSbjctdescriptionprevnextTop
sub nextSbjct {
  my ($self) = @_;
  $self->_fastForward or return undef;

  #######################
# get all sbjct lines #
#######################
my $def = $self->{'LASTLINE'}; my $FH = $self->{'FH'}; while(<$FH>) { if ($_ !~ /\w/) {next} elsif ($_ =~ /Strand HSP/) {next} # WU-BLAST non-data
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/^>//; ####################
# the Sbjct object #
####################
my $sbjct = new Bio::EnsEMBL::Analysis::Tools::BPlite::Sbjct('-name'=>$def, '-length'=>$length, '-fh'=>$self->{'FH'}, '-lastline'=>$self->{'LASTLINE'}, '-parent'=>$self); return $sbjct;
}
oldhitsdescriptionprevnextTop
sub oldhits {
shift->{'OLDHITS'}
}
qlengthdescriptionprevnextTop
sub qlength {
shift->{'LENGTH'}
}
querydescriptionprevnextTop
sub query {
shift->{'QUERY'}
}
General documentation
AUTHORS - Peter SchattnerTop
Email: schattner@alum.mit.edu
ACKNOWLEDGEMENTSTop
Based on work of:
Ian Korf (ikorf@sapiens.wustl.edu, http://sapiens.wustl.edu/~ikorf),
Lorenz Pollak (lorenz@ist.org, bioperl port)
COPYRIGHTTop
BPlite.pm is copyright (C) 1999 by Ian Korf.
DISCLAIMERTop
This software is provided "as is" without warranty of any kind.