FastParsers/Hmmer/Standard/Target.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 47 / 47 CC 4 SCAR 8.5
CC
4
Cov
100%
__ANON__
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« FastParsers/Uclust.pm ↑ Summary FastParsers/Blast/Xml.pm »
1 package Bio::FastParsers::Hmmer::Standard::Target;
2 # ABSTRACT: Internal class for standard HMMER parser
3 # CONTRIBUTOR: Arnaud DI FRANCO <arnaud.difranco@gmail.com>
4 7 $Bio::FastParsers::Hmmer::Standard::Target::VERSION = '0.221230';
5 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶use List::AllUtils qw(indexes);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 ▶use aliased 'Bio::FastParsers::Hmmer::Standard::Domain';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 # public attributes
14  
15 # TODO: check if this an empty ArrayRef would not make more sense than Maybe
16 # We dont want smth else than a Domain in this ArrayRef
17 # so it is more a matter of precision than sense
18 7 has 'domains' => (
19 traits => ['Array'],
20 is => 'ro',
21 isa => 'ArrayRef[Maybe[Bio::FastParsers::Hmmer::Standard::Domain]]',
22 required => 1,
23 handles => {
24 next_domain => 'shift',
25 get_domain => 'get',
26 all_domains => 'elements',
27 count_domains => 'count',
28 },
29 );
30  
31 7 with 'Bio::FastParsers::Roles::Targetable';
32  
33 # parse Target block (raw)...
34 # ... and retrieve attrs from the corresponding line of hit table (Hit)
35  
36 20 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
37 20 my ($orig, $class, $inargs) = @_;
38  
39 # retrieve lines still to parse as @raw...
40 20 my @raw = @{ $inargs->{raw} };
41  
42 # recycle the anonymous HashRef already containing old Hit information
43 # as the foundation for the new Target object
44 20 my %outargs = %{ $inargs->{hit} };
45  
46 # add Target name
47 20 ( $outargs{target_name} = $raw[0] ) =~ s/[\>\s+]//xmsg;
48  
49 # split Domain blocks
50 20 ▶ my @domain_indexes = indexes { m/^\s+==/xms } @raw;
Subroutine __ANON__: called CC=1 SCAR=0.0
51  
52 # set as empty ArrayRef as --domE option can report Target without domain
53 20 $outargs{domains} = [];
54 20 ▶ if (@domain_indexes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@domain_indexes) 18 2 20
55 my @summary = grep {
56 18 $_ =~ m/^\s+\d/xms
57 } @raw[ 1 .. $domain_indexes[0]-1 ];
58  
59 18 ▶ for (my $i = 0; $i < @domain_indexes; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @domain_indexes) 50 18 68
60 50 ▶ my @block = defined $domain_indexes[$i+1]
Branch: 1 branch
BranchTrueFalseTotal
defined $domain_indexes[$i + 1] ? : 32 18 50
61 ? @raw[ $domain_indexes[$i] .. $domain_indexes[$i+1] ]
62 : splice @raw, $domain_indexes[$i]
63 ;
64 50 push @{ $outargs{domains} },
65 Domain->new( { raw => \@block, summary => $summary[$i] } );
66 }
67 }
68  
69 # return expected constructor hash
70 20 return $class->$orig(%outargs);
71 7 };
72  
73 7 __PACKAGE__->meta->make_immutable;
74 7 1;
75  
76 __END__
« FastParsers/Uclust.pm ↑ Summary FastParsers/Blast/Xml.pm »