in reply to BioPerl StandAloneBlast is returning unexpected undefined SearchIO object

I am not sure if i got it right but I believe the error is because Blastall expects a Bio::SeqIO object. To convert sequences to a Bio::SeqIO object which you can directly pass on to your blastall call, you may use IO::String (see bioperl documentation on SeqIO)

The following worked for me. First define a string variable to store sequences in fasta format my $sequence_string = "";
Then replace these lines in your code
push(@translated_seqs, $temp_seq) unless($temp_seq->seq() =~ /\*+/);
with
$sequence_string = $sequence_string.">".$temp_seq->display_id."\n".$temp_seq->seq."\n" unless($temp_seq->seq =~ /\*+/);
(As biohisham suggested Re^3: BioPerl StandAloneBlast is returning unexpected undefined SearchIO object, there may be better ways to select open reading frames.)

Before calling Blast, convert the string to SeqIO object as follows:
my $stringfh = new IO::String($sequence_string); my $seqio = new Bio::SeqIO(-fh => $stringfh, -format => 'fasta'); my $blaster = Bio::Tools::Run::StandAloneBlast->new(@params);
Loop through sequences to blast and continue with whatever you want to do with your blast report
while( my $seq = $seqio->next_seq ) { my $blast_report = $blaster->blastall($seq); ... while( my $BLAST_result = $blast_report->next_result ) { ... while( my $hit = $BLAST_result->next_hit ) { ... } } }
The parser worked fine with the blast report in default format but failed to read the ‘blasttable’ format. I haven't understand the reason for this.

Replies are listed 'Best First'.
Re^2: BioPerl StandAloneBlast is returning unexpected undefined SearchIO object
by stajich (Chaplain) on Jul 12, 2009 at 04:35 UTC
    You have to tell StandAloneBlast it will be returning blasttable format, the default is 'blast' format and the parser doesn't try to guess.

    I'm really confused why you are doing the translation yourself and not running BLASTX, but anyways the code for doing translation is described below?

    The StandAloneBlast module is pretty fragile unfortunately - I really prefer to just code the cmdline parameters myself. But I think the problem from before is that it assumes you are passing in a Bio::Seq object (or Bio::PrimarySeqI interface object).

    Here's a part of a script to generate your query sequences in FASTA format and then run your blast with a system call or better yet do the parsing on the fly... The translate function has a lot of capabilities as well like finding ORFs for you.

    use Bio::SeqIO; use Bio::SearchIO; my $input = Bio::SeqIO->new(-format => 'fasta', -file => "inputseqs.fa +"); my $output = Bio::SeqIO->new(-format => 'fasta', -file => ">translated +.fa"); while(my $seq = $input->next_seq ){ my $id = $seq->id; # fwd strand for my $frame ( 0..3 ) { my $translated = $seq->translate($frame); $translated->id($id. "_F$frame"); $output->write_seq($translated); } # rev strand my $revcom = $seq->revcom; for my $frame ( 0..3 ) { my $translated = $revcom->translate($frame); $translated->id($id. "_R$frame"); $output->write_seq($translated); } $output->close(); } my $blastexe = "blastall -p blastp -d swissprot -e 1e-3 -i translated. +fa -m 9"; open(my $fh => "$blastexe |" ) || die $!; my $blastparser = Bio::SearchIO->new(-format => 'blasttable', -fh => $ +fh); # now do something with this as a SearchIO object # if you wanted the full alignment details, change blasttable to 'blas +t' and remove the '-m 9' in the exe string. # OR `$blastexe -o result.BLASTP.tab`;