Bio-FastParsers
view release on metacpan or search on metacpan
lib/Bio/FastParsers/Hmmer/Standard/Iteration.pm view on Meta::CPAN
package Bio::FastParsers::Hmmer::Standard::Iteration;
# ABSTRACT: Front-end class for standard HMMER parser
# CONTRIBUTOR: Arnaud DI FRANCO <arnaud.difranco@gmail.com>
$Bio::FastParsers::Hmmer::Standard::Iteration::VERSION = '0.221230';
use Moose;
use namespace::autoclean;
use autodie;
use List::AllUtils qw(indexes firstidx mesh);
use Bio::FastParsers::Constants qw(:files);
use aliased 'Bio::FastParsers::Hmmer::Standard::Target';
# public attributes
has 'query' => (
is => 'ro',
isa => 'Str',
required => 1,
);
has 'query_length' => (
is => 'ro',
isa => 'Int',
required => 1,
);
has 'targets' => (
traits => ['Array'],
is => 'ro',
isa => 'ArrayRef[Bio::FastParsers::Hmmer::Standard::Target]',
required => 1,
handles => {
next_target => 'shift',
get_target => 'get',
all_targets => 'elements',
count_targets => 'count',
},
);
## no critic (ProhibitUnusedPrivateSubroutines)
around BUILDARGS => sub {
my ($orig, $class, $iter_block) = @_;
my %outargs;
my @hits;
# Parse Iteration to separate header information (q, qlen), header hit
# table (Hit) and main output information per target (Target).
# Hit and Target are the same entity but Hit is close to what is retrieved
# from a Hmmer::Table output. For now, we chose to conserve Target as
# primary name since it is how it is called in the file.
my @lines = split /\n/xms, $iter_block;
LINE:
for my $line (@lines) {
# parse header
if ($line =~ m/Query:/xms) {
my @fields = split /\s+/xms, $line;
$outargs{'query'} = $fields[1];
( $outargs{'query_length'} = $fields[2] ) =~ s/\D//xmsg;
( run in 1.663 second using v1.01-cache-2.11-cpan-a49fcb8fa48 )