[Bioperl-l] Bio::DB::Fasta problem

Maxim deeepersound at googlemail.com
Tue Dec 7 20:00:35 UTC 2010


Hi,

I'm using Bio::DB::Fasta to retrieve sequences. This works like a charm
(super fast!!!), for example like in the script below, where bed-files are
taken as input.

My problem: as soon as the initialization of the fasta directory index is
called from within an if-statement, I get an error like:

Can't call method "get_Seq_by_id" on an undefined value at
extract_bed_bio_db_fasta_test.pl line 20, <INP> line 134.


The script is as simple as this, the error comes up when I use the full
script (including the 2 out-commented lines):

use Bio::Perl;
use Bio::DB::Fasta;

$bedFileName=@ARGV[0];
$genome = @ARGV[1];
#if ($genome eq "mm9") {
my $db      = Bio::DB::Fasta->new('/Users/Computing/BIODBFASTA/mm9_masked');
#}

open (INP, "$bedFileName");
foreach (<INP>)
{
@words = split /\s+/, $_; ### 0-chr 1-start 2-end
$chr = @words[0];$chr =~s/\s+//g;
$start = @words[1];$start =~s/\s+//g;
$end = @words[2];$end =~s/\s+//g;
   $fast_name = $chr . "_" . $start . "_" . $end;
my $obj     = $db->get_Seq_by_id($chr);
$subseq  = $obj->subseq($start => $end);
print ">", "$fast_name\n";
print "$subseq\n";
}

What is the problem when initializing from within the if-statement?

I really appreciate all kind of advice, I guess the reason is rather simple,
but I do not get it.
Regards
Maxim



More information about the Bioperl-l mailing list