[Bioperl-l] writing remote blasts to file

Jason Stajich jason@cgt.mc.duke.edu
Tue, 23 Jul 2002 13:03:29 -0400 (EDT)


This is a problem that keeps getting asked about - covered in the mailing
list archives about the different SearchIO blast paring implementation.

You can't use the HSPTableWriter with the current implementation of
Bio::Search::HSP::GenericHSP (which is produced from the
Bio::SearchIO::blast parser) because the HSPTableWriter was written to use
methods that are specific to BlastHSP and BlastHit objects not the
standard HSPI and HitI interface.  I would be more than happy for someone
to fix this because I think it is silly for us to have 2 different objects
produced by roughly equivalent parsers.


You can of course just call methods on the Hit and HSP objects yourself to
produce your own table without relying on the Writer object:

print join("\t", qw(HITNAME HITLEN EVALUE QSTART QEND HSTART HEND
PERCENTID)), "\n";
while( $hit = $result->next_hit ) {
 while( $hsp = $hit->next_hsp ) {
  print join("\t", $hit->name, $hit->length, $hsp->evalue,
 $hsp->query->start, $hsp->query->end,
 $hsp->hit->start,$hsp->hit->end,$hsp->percent_identity()), "\n";
 }
}

Another quick answer - get Bio/SearchIO/Writer/TextResultWriter.pm from
 ftp://bioperl.org/pub/SRC/bioperl-live
or more properly from CVS (see cvs.open-bio.org)

This can output a faux BLAST format report if you really wanted to see the
report.  There is also a HTMLResultWriter which can print a HTML-ized
BLAST report too.

You can also write an extension to the RemoteBlast module which provides
the outfile equivalent which is a very simple step that writes the data to
disk in-addition-to/instead-of using the Bio::SearchIO parser.

-jason

On Tue, 23 Jul 2002, Richard Adams wrote:

>    Hello,
> I'm sure I'm missing something obvious but am trying just to get a
> remote blast report to file for future
> import into SearchIO for parsing.  Since there doesn't seem to be the
> equivalent to the standaloneblast's
>     $factory->outfile('>OUT.blast')
> I'm trying to use the TableWriter modules
>
> e.g.,
> use Bio::Tools::RemoteBlast
> use Bio::SearchIO;
> use Bio::SearchIO::Writer::HSPTableWriter;
>
>     $report = $factory->retrieve_blast ($rid);
> #assuming retrieval has worked
>
> $factory->remove_rid($rid);
>     my $writer = Bio::SearchIO::Writer::HSPTableWriter->new();
>
>     my $out = Bio::SearchIO->new (-format =>'blast',
>                                                                -file =>
> ">OUT4.out",
>                                                                -writer
> => $writer);
>
>     while ( $result = $report->next_result) {
>                          $out->write_result($result);
>
> Examining the contents of OUT4.out shows a listing full of 0  or 0.00
> instead of the HSP details
> If I use ResultTableWriter this just outputs a single integer .
> But the blast did generate hits.
> How can I just send the whole report to file, and/or get the
> HSPTableWriter to access the data in the blast report?
> I'm sure this has a trivial answer but would greatly appreciate any
> assistance.
>
> Richard Adams
> Molecular Medicine Centre
> University of Edinburgh
> UK
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>

-- 
Jason Stajich
Duke University
jason at cgt.mc.duke.edu