FastParsers/Hmmer/Standard/Domain.pm

filter: Statementstmt 96.4% 55 / 57 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 5 totaltotal 88.0% 66 / 75 CC 3 SCAR 4.4
CC
3
Cov
97%
__ANON__
2.0
get_degap_scoreseq
2.0
num
2.0
CRAP 1.5
« FastParsers/Blast/Xml/Parameters.pm ↑ Summary FastParsers/Roles/Domainable.pm »
1 package Bio::FastParsers::Hmmer::Standard::Domain;
2 # ABSTRACT: Internal class for standard HMMER parser
3 # CONTRIBUTOR: Arnaud DI FRANCO <arnaud.difranco@gmail.com>
4 7 $Bio::FastParsers::Hmmer::Standard::Domain::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(mesh);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 # public attributes
12  
13 has $_ => (
14 is => 'ro',
15 isa => 'Str',
16 required => 1,
17 7 ) for qw(seq scoreseq profile probabilities);
18  
19 7 with 'Bio::FastParsers::Roles::Domainable';
20  
21 50 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
22 50 my ($orig, $class, $inargs) = @_;
23  
24 50 my @raw = @{ $inargs->{raw} };
25 50 my $summary = $inargs->{summary};
26  
27 50 my %outargs;
28  
29 # parse header
30 50 my @header_vals = $raw[0] =~ m/([\d\.]+)/xmsg;
31 50 $outargs{'rank'} = $header_vals[0];
32 50 $outargs{'dom_score'} = $header_vals[1];
33 50 ▶ $outargs{'c_evalue'}
Branch: 1 branch
BranchTrueFalseTotal
@header_vals == 3 ? : 42 8 50
34 = @header_vals == 3 ? $header_vals[2] : join 'e-', @header_vals[2,3]
35 ;
36  
37 # coerce numeric fields to numbers
38 50 %outargs = map { $_ => 0 + $outargs{$_} } keys %outargs;
39  
40 # parse domain alignment
41  
42 # Alignment is made of 4 lines: best match to profile, scoring
43 # correspondance, sequence alignment and posterior predictive. Each line
44 # is shifted to the right by the same amount of characters, which is
45 # different for each target. To get the size of the shift, I insert
46 # special characters on the seqline and split on hit. Each part gives the
47 # right length to extract correctly the information.
48  
49 50 my $profileline = $raw[1];
50 50 my $scoreline = $raw[2];
51 50 my $probline = $raw[4];
52 50 ( my $seqline = $raw[3] )
53 =~ s{(^\s+.*\s+\d+\s+)(\S+)\s\d+\s*$}{$1\|\|\|$2}xms;
54 50 chomp $seqline;
55 50 my ($skip, $tmpseq) = split /\|{3}/xms, $seqline;
56 50 my $scoreseq = substr $scoreline, length $skip, length $tmpseq;
57 50 my $profileseq = substr $profileline, length $skip, length $tmpseq;
58 50 my $probabilities = substr $probline, length $skip, length $tmpseq;
59 50 $outargs{'seq'} = $tmpseq;
60 50 $outargs{'scoreseq'} = $scoreseq;
61 50 $outargs{'profile'} = $profileseq;
62 50 $outargs{'probabilities'} = $probabilities;
63  
64 # attributes from summary domtbl
65 50 my @summary_attrs = qw(
66 dom_bias i_evalue
67 hmm_from hmm_to
68 ali_from ali_to
69 env_from env_to
70 acc
71 );
72 50 my @summary_slots = qw(4 6 7 8 10 11 13 14 16);
73  
74 # parse summary
75 # and coerce numeric fields to numbers
76 50 my @fields = split /\s+/xms, $summary;
77 50 my @summary_vals = map { 0 + $fields[$_] } @summary_slots;
78 50 my %summary_hash = mesh @summary_attrs, @summary_vals;
79  
80 # return expected constructor hash
81 50 return $class->$orig( %outargs, %summary_hash );
82 7 };
83  
84 # TODO: check if this could not be avoided
85 # as this looks like code duplication with Bio::MUST::Core
86 # This one too ?
87  
88 3 ▶sub get_degap_scoreseq {
Subroutine get_degap_scoreseq: called CC=2 SCAR=6.9
Pod undocumented
89 3 my $self = shift;
90 3 my $tmpseq = $self->seq;
91 3 my $score = $self->scoreseq;
92  
93 # Need brackets or else pos == 1
94 3 ▶ while ( (my $pos = index($tmpseq, '-') ) != -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((my $pos = index($tmpseq, "-")) != -1) 87 3 90
95 87 substr $tmpseq, $pos, 1, q{};
96 87 substr $score, $pos, 1, q{};
97 }
98  
99 3 return $score;
100 }
101  
102  
103 # aliases
104  
105 12 ▶sub expect {
Subroutine expect: called CC=1 SCAR=0.0
Pod undocumented
106 12 return shift->c_evalue;
107 }
108  
109 12 ▶sub score {
Subroutine score: called CC=1 SCAR=0.0
Pod undocumented
110 12 return shift->dom_score;
111 }
112  
113 0 ▶sub num {
Subroutine num: not called CC=1 SCAR=6.9
Pod undocumented
114 0 return shift->number;
115 }
116  
117 0 ▶sub idx {
Subroutine idx: not called CC=1 SCAR=6.9
Pod undocumented
118 0 return shift->number-1;
119 }
120  
121 7 __PACKAGE__->meta->make_immutable;
122 7 1;
123  
124 __END__
« FastParsers/Blast/Xml/Parameters.pm ↑ Summary FastParsers/Roles/Domainable.pm »