[Bioperl-l] use threads to get seq file error.

Zhang_tao Zhang_tao at uestc.edu.cn
Mon Mar 1 05:02:12 UTC 2010


Hi all,

When I use threads to get Genbank format file, show some error. It is
shown as:

"Can't call method "get_taxon" on unblessed reference at
/opt/local/lib/perl5/site_perl/5.8.9/Bio/Taxon.pm line 671."


#!/usr/bin/perl -w
use strict;
use Bio::SeqIO;
use Bio::Seq;
use Bio::DB::GenBank;
use threads;


my @id =
("AK287649","AF031249","EZ238383","BLYDHN5","AY895908","EF409493","AY895886","AF181455","AY895930","EF409498");


my $seq_out = Bio::SeqIO->new(-format => "genbank",
-file => ">dhn_all.gb");
my @seq;

my $number = @id;

my $max_threads = 6;

for (my $thread_number=0;$thread_number<$number;){
my %threads_seq_hash;

if ($number - $thread_number > $max_threads){
for (my $thread=0;$thread<$max_threads;){
$threads_seq_hash{$thread} = threads->new(sub {
my $gb = Bio::DB::GenBank->new;
my $seq = $gb->get_Seq_by_acc($id[$thread_number]);
});
$thread_number++;
$thread++;

}
}else{
my $else_number = $number % $max_threads;
for (my $thread=0;$thread<$else_number;){
$threads_seq_hash{$thread} = threads->new(sub {
my $gb = Bio::DB::GenBank->new;
my $seq = $gb->get_Seq_by_acc($id[$thread_number]);
});
$thread_number++;
$thread++;

}


}

foreach my $thread (sort keys %threads_seq_hash){
my ($seq) = $threads_seq_hash{$thread}->join;
push (@seq,$seq);
}
}

foreach (@seq){
$seq_out->write_seq($_);
}




How can I fix this error?
Thanks.


Zhang Tao







More information about the Bioperl-l mailing list