[Bioperl-l] possible filehandle out of scope bug between Bio::AlignIO and Bio::Tools::Run::Hmmer

Scott Markel smarkel at scitegic.com
Mon Apr 18 15:17:10 EDT 2005


Note: The context for this message assumes the code change
to Bio::Tools::Run::Hmmer that I just sent to the mailing
list.

I'm running BioPerl-1.4 on both Windows XP (Perl 5.8.0) and
cygwin (Perl 5.8.5).  I get the same behavior when I use
BioPerl-1.5.

When I run the following code, I get the error message

   Can't call method "consensus_string" on an undefined value
   at runHmmAlign.pl line 14.

If I change $factory to $::factory, so that it doesn't go out
of scope when the subroutine is done, then everything is fine.

My Perl debugging skills aren't what they should be, so I'm
not sure how to verify the following, but it looks like the
destructor for Bio::Tools::Run::Hmmer clobbers the filehandle
in Bio::AlignIO.  Similar code involving Bio::Tools::Run::Hmmer
and Bio::SearchIO (for hmmsearch) does not have this problem.

I checked the bug list, but didn't find anything for AlignIO
and filehandle.

Scott

==============================
use strict;
use warnings;

use Bio::Tools::Run::Hmmer;

my $hmmFile = shift;
my $sequenceFile = shift;

my $in = Bio::SeqIO->new(-file => $sequenceFile , -format => "fasta");
my $sequence = $in->next_seq();

my $hmmResults = runHmmAlign($hmmFile, $sequence);
my $alignment = $hmmResults->next_aln();
my $consensusString = $alignment->consensus_string();
print("$consensusString\n");

sub runHmmAlign
{
     my ($hmmFile, $sequence) = @_;

     my $hmmResults;

     eval
     {
         my $factory = Bio::Tools::Run::Hmmer->new("program" => "hmmalign",
                                                   "hmm"     => $hmmFile);
         $hmmResults = $factory->run($sequence);
     };

     if ($@)
     {
         die("hmmalign failed: $@\n");
     }

     return $hmmResults;
}
==============================

-- 
Scott Markel, Ph.D.
Principal Bioinformatics Architect  email:  smarkel at scitegic.com
SciTegic Inc.                       mobile: +1 858 205 3653
9665 Chesapeake Drive, Suite 401    voice:  +1 858 279 8800, ext. 253
San Diego, CA 92123                 fax:    +1 858 279 8804
USA                                 web:    http://www.scitegic.com



More information about the Bioperl-l mailing list