Bio-MUST-Apps-OmpaPa
view release on metacpan or search on metacpan
lib/Bio/MUST/Apps/OmpaPa/Blast.pm view on Meta::CPAN
package Bio::MUST::Apps::OmpaPa::Blast;
# ABSTRACT: internal class for XML BLAST parser
# CONTRIBUTOR: Amandine BERTRAND <amandine.bertrand@doct.uliege.be>
$Bio::MUST::Apps::OmpaPa::Blast::VERSION = '0.260260';
use Moose;
use namespace::autoclean;
use autodie;
use feature qw(say);
use Smart::Comments;
use Carp;
extends 'Bio::FastParsers::Blast::Xml';
with 'Bio::MUST::Apps::OmpaPa::Roles::Parsable';
sub collect_hits {
my $self = shift;
my @hits;
# parse BLAST report
my $iter = $self->blast_output->next_iteration;
my $qlen = $iter->query_len;
HIT:
while (my $hit = $iter->next_hit) {
# honor --max-hits limit
if (@hits >= $self->max_hits) {
carp 'Reached --max-hits limit; truncating report!';
last HIT;
}
# split hit desc on Ctrl-A and keep only first line (nr database)
# this is needed for table formatting as Ctrl-A has zero-width
my ($desc) = split /\cA.*/xms, ( $hit->def // $hit->id );
my $hsp = $hit->next_hsp; # workaround for XML report change
# collect useful hit/HSP attributes
push @hits, {
'acc' => ( $hit->id =~ m/^gnl\|/xms ? $hit->def : $hit->id ),
# workaround to accommodate change in BLAST XML report
'dsc' => $desc,
'exp' => $hsp->evalue,
'bit' => $hsp->bit_score,
'qlen' => $qlen,
'len' => $hit->len,
'hmm_from' => $hsp->query_start, # for consistent naming
'hmm_to' => $hsp->query_end,
};
}
return \@hits;
}
__PACKAGE__->meta->make_immutable;
1;
__END__
=pod
=head1 NAME
( run in 0.491 second using v1.01-cache-2.11-cpan-7f9471e7e0a )