[Bioperl-l] blastxml to table

Robson de Souza robfsouza at gmail.com
Tue Jun 1 16:23:41 EDT 2010


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

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
STACK: try{} block
STACK: Bio::SearchIO::Writer::HSPTableWriter::to_string
STACK: Bio::SearchIO::write_result
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?

#!/usr/bin/env perl

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

my $writer = "TextResultWriter";
my $type = "PSIBLAST";
                  "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");
    while( my $r = $in->next_result) {

exit 0;

More information about the Bioperl-l mailing list