[Bioperl-l] blastxml to table

Robson de Souza robfsouza at gmail.com
Tue Jun 1 20:23:41 UTC 2010


Hello!

I'm trying to convert BLAST XML output to a BLAST table which should
be identical to a BLAST output generated using "-m 8".
In the script below, if $type is "BLAST", the script works if $writer
is TextResultWriter but when I try to generate BLAST compatible (i.e.
like "-m 8") tables using $writer = "HSPTableWriter" it fails with the
message

Using default column map.

------------- EXCEPTION: Bio::Root::Exception -------------
MSG: Trouble in ResultTableWriter::_set_row_data_func() eval: Can't
locate object method "iteration" via package
"Bio::Search::Hit::GenericHit" at (eval 58) line 1, <GEN50> line 3020.

STACK: Error::throw
STACK: Bio::Root::Root::throw
/panfs/pan1/proteinworld/tools/perl/lib/site_perl/5.8.8/Bio/Root/Root.pm:368
STACK: try{} block
/panfs/pan1/proteinworld/tools/perl/lib/site_perl/5.8.8/Bio/SearchIO/Writer/ResultTableWriter.pm:339
STACK: Bio::SearchIO::Writer::HSPTableWriter::to_string
/panfs/pan1/proteinworld/tools/perl/lib/site_perl/5.8.8/Bio/SearchIO/Writer/HSPTableWriter.pm:263
STACK: Bio::SearchIO::write_result
/panfs/pan1/proteinworld/tools/perl/lib/site_perl/5.8.8/Bio/SearchIO.pm:344
STACK: /home/desouza/projects/mytools/bin/blastxml2blast:22
-----------------------------------------------------------

Is there a way to fix this? Or should I use another approach to get
"-m 8" compatible tables?
Thanks,
Robson

#!/usr/bin/env perl
#====================

use strict;
use warnings;
use Bio::SearchIO;
use Getopt::Long;

my $writer = "TextResultWriter";
my $type = "PSIBLAST";
GetOptions("w=s"=>\$writer,
                  "t=s" => \$type);

# Load writer
use Module::Load;
my $writer = "Bio::SearchIO::Writer::".$writer;
load $writer;
$writer = $writer->new();

# Open and convert input
my $out = Bio::SearchIO->new(-writer => $writer);
foreach my $file (@ARGV) {
    my $in = Bio::SearchIO->new(-format => "blastxml",
				-file   => "<$file");
    $in->blasttype($type);
    while( my $r = $in->next_result) {
	$out->write_result($r);
    }
}

exit 0;



More information about the Bioperl-l mailing list