[Bioperl-l] Bio::AlignIO::bl2seq doesn't know when to stop...

Jonathan M. Manning jmanning at broad.mit.edu
Tue Nov 4 13:06:09 EST 2003


Hi,
If I try to parse a bl2seq alignment using align (using "while(my $aln = 
$str->next_aln())" ), when it runs out of alignments, I get:

Can't call method "querySeq" on an undefined value at 
~/perllib/Bio/AlignIO/bl2seq.pm line 134, <GEN5> line 6002.

If I look at the file I'm trying to parse, line 6002 is the end of the 
alignments. There is a "Lambda" line, and some summary information 
following it. I would expect next_aln to return false here.

The following patch to CVS head fixes this - and properly returns false 
when there is no next alignment. This fix can also be applied to 1.2.3. 
All tests in AlignIO.t pass.

I'm using blast tools 2.2.1, btw. It may only be a problem with this 
version of bl2seq. However, the fix below is a good safety check 
regardless of what blast version is used - but someone needs to test it 
against the latest version, just in case.

~Jonathan


Index: bl2seq.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/AlignIO/bl2seq.pm,v
retrieving revision 1.15
diff -c -r1.15 bl2seq.pm
*** bl2seq.pm   2003/10/28 13:52:03     1.15
--- bl2seq.pm   2003/11/04 15:54:16
***************
*** 131,136 ****
--- 131,137 ----
                                   -report_type => $self->report_type);
       my $bl2seqobj = $self->{'bl2seqobj'};
       my $hsp =   $bl2seqobj->next_feature;
+     unless($hsp) { return 0 };
       $seqchar = $hsp->querySeq;
       $start = $hsp->query->start;
       $end = $hsp->query->end;




More information about the Bioperl-l mailing list