blast_parse_2.pl
use lib '/usr/people/gbell/perl_modules/nhgri/';
use NHGRI::Blastall;
use GD;
if (! $ARGV[0])
{
print "What is the BLAST file to parse? ";
chomp ($inFile = <STDIN>);
}
else
{
$inFile = $ARGV[0];
}
my $b = new NHGRI::Blastall;
$b->read_report("$inFile");
@results = $b->result();
@ids = $b->result('id');
@query_defline = $b->result('query');
print "HIT_NUM\tQUERY\tQUERY_ID\tSUBJECT_LENGTH\tSCORE\tEXPECT\t";
print "MATCH_LENGTH\tIDENTITY\tQUERY_START\tQUERY_END\tSUBJECT_START\tSUBJECT_END\n";
print "\n**** DATA FOR QUERY $query_defline[0] ****\n\n";
for ($i = 0; $i <= $
{
$hit_num = $i + 1;
$this_id = $ids[$i];
@deflines = $b->result('defline', $ids[$i]);
for ($j = 0; $j <= $
{
$deflines[$j] =~ s/(\s){5,}/ /g;
}
@scores = $b->result('scores', $ids[$i]);
@expects = $b->result('expects', $ids[$i]);
@subject_length = $b->result('subject_length', $ids[$i]);
@match_lengths = $b->result('match_lengths', $ids[$i]);
@identities = $b->result('identities', $ids[$i]);
@query_starts = $b->result('query_starts', $ids[$i]);
@query_ends = $b->result('query_ends', $ids[$i]);
@subject_starts = $b->result('subject_starts', $ids[$i]);
@subject_ends = $b->result('subject_ends', $ids[$i]);
for ($k = 0; $k <= $
{
print "$hit_num\t$deflines[0]\t$this_id\t";
print "$subject_length[0]\t$scores[$k]\t$expects[$k]\t$match_lengths[$k]\t";
printf "%0.2f", $identities[$k];
print "\t$query_starts[$k]\t$query_ends[$k]\t$subject_starts[$k]\t$subject_ends[$k]\n";
}
}
sub dump_results
{
foreach $rh_r (@results)
{
while (($key,$value) = each %$rh_r)
{
if (ref($value) eq "ARRAY")
{
print "$key: ";
foreach $v (@$value)
{
print "$v ";
}
print "\n";
}
else
{
print "$key: $value\n";
}
}
print "\n";
}
}