I opt to use the existing modules rather than reinventing wheels.
Code:
print "writing results";
our $filename;
while ( my @rids = $fac->each_rid ) {
die "No record found\n" unless @rids;
foreach my $rid ( @rids ) {
my $result = $fac->retrieve_blast( $rid );
if( ref( $result )) {
my $output = $result->next_result();
$filename = $output->query_name().".out";
$fac->save_output( $filename );
$fac->remove_rid( $rid );
my( $out ) = shift;
my $in_seqio = Bio::SeqIO->new( -file => $filename , -format => 'genbank' );
my $out_seqio = Bio::SeqIO->new( -file => ">$out" , -format => 'fasta' );
while( my $seq = $in_seqio->next_seq() ) {
$out_seqio->write_seq( $seq );
}
}
elsif( $result < 0 ) {
$fac->remove_rid( $rid );
}
else {
sleep 5;
}
}
}
I have tried this and am getting:
Use of uninitialized value in concatenation (.) or string at ./blast.pl line 61.
------------- EXCEPTION -------------
MSG: Could not open >: No such file or directory
STACK Bio::Root::IO::_initialize_io /usr/local/lib/perl5/site_perl/5.8.4/Bio/Root/IO.pm:313
STACK Bio::SeqIO::_initialize /usr/local/lib/perl5/site_perl/5.8.4/Bio/SeqIO.pm:451
STACK Bio::SeqIO::fasta::_initialize /usr/local/lib/perl5/site_perl/5.8.4/Bio/SeqIO/fasta.pm:83
STACK Bio::SeqIO::new /usr/local/lib/perl5/site_perl/5.8.4/Bio/SeqIO.pm:354
STACK Bio::SeqIO::new /usr/local/lib/perl5/site_perl/5.8.4/Bio/SeqIO.pm:380
STACK toplevel ./blast.pl:61
Code:
print "writing results";
our $filename;
while ( my @rids = $fac->each_rid ) {
die "No record found\n" unless @rids;
foreach my $rid ( @rids ) {
my $result = $fac->retrieve_blast( $rid );
if( ref( $result )) {
my $output = $result->next_result();
$filename = $output->query_name().".out";
$fac->save_output( $filename );
$fac->remove_rid( $rid );
}
elsif( $result < 0 ) {
$fac->remove_rid( $rid );
}
else {
sleep 5;
}
}
}
my( $out ) = shift;
my $in_seqio = Bio::SeqIO->new( -file => $filename , -format => 'genbank' );
my $out_seqio = Bio::SeqIO->new( -file => ">$out" , -format => 'fasta' );
while( my $seq = $in_seqio->next_seq() ) {
$out_seqio->write_seq( $seq );
}
I put the chuck outside of WHILE and am getting the same error.
Any idea why it is returning the error?
![[ponder] [ponder] [ponder]](/data/assets/smilies/ponder.gif)