line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Front-end class for standard HMMER parser |
2
|
|
|
|
|
|
|
# CONTRIBUTOR: Arnaud DI FRANCO <arnaud.difranco@gmail.com> |
3
|
|
|
|
|
|
|
$Bio::FastParsers::Hmmer::Standard::Iteration::VERSION = '0.221230'; |
4
|
|
|
|
|
|
|
use Moose; |
5
|
7
|
|
|
7
|
|
4388
|
use namespace::autoclean; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
38
|
|
6
|
7
|
|
|
7
|
|
41277
|
|
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
44
|
|
7
|
|
|
|
|
|
|
use autodie; |
8
|
7
|
|
|
7
|
|
499
|
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
40
|
|
9
|
|
|
|
|
|
|
use List::AllUtils qw(indexes firstidx mesh); |
10
|
7
|
|
|
7
|
|
32443
|
|
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
471
|
|
11
|
|
|
|
|
|
|
use Bio::FastParsers::Constants qw(:files); |
12
|
7
|
|
|
7
|
|
48
|
use aliased 'Bio::FastParsers::Hmmer::Standard::Target'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
719
|
|
13
|
7
|
|
|
7
|
|
55
|
|
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
48
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# public attributes |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'query' => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'Str', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'query_length' => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
isa => 'Int', |
26
|
|
|
|
|
|
|
required => 1, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'targets' => ( |
30
|
|
|
|
|
|
|
traits => ['Array'], |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => 'ArrayRef[Bio::FastParsers::Hmmer::Standard::Target]', |
33
|
|
|
|
|
|
|
required => 1, |
34
|
|
|
|
|
|
|
handles => { |
35
|
|
|
|
|
|
|
next_target => 'shift', |
36
|
|
|
|
|
|
|
get_target => 'get', |
37
|
|
|
|
|
|
|
all_targets => 'elements', |
38
|
|
|
|
|
|
|
count_targets => 'count', |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
## no critic (ProhibitUnusedPrivateSubroutines) |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
around BUILDARGS => sub { |
45
|
|
|
|
|
|
|
my ($orig, $class, $iter_block) = @_; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my %outargs; |
48
|
|
|
|
|
|
|
my @hits; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Parse Iteration to separate header information (q, qlen), header hit |
51
|
|
|
|
|
|
|
# table (Hit) and main output information per target (Target). |
52
|
|
|
|
|
|
|
# Hit and Target are the same entity but Hit is close to what is retrieved |
53
|
|
|
|
|
|
|
# from a Hmmer::Table output. For now, we chose to conserve Target as |
54
|
|
|
|
|
|
|
# primary name since it is how it is called in the file. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my @lines = split /\n/xms, $iter_block; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
LINE: |
59
|
|
|
|
|
|
|
for my $line (@lines) { |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# parse header |
62
|
|
|
|
|
|
|
if ($line =~ m/Query:/xms) { |
63
|
|
|
|
|
|
|
my @fields = split /\s+/xms, $line; |
64
|
|
|
|
|
|
|
$outargs{'query'} = $fields[1]; |
65
|
|
|
|
|
|
|
( $outargs{'query_length'} = $fields[2] ) =~ s/\D//xmsg; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# parse Hit |
69
|
|
|
|
|
|
|
my @attrs = qw( |
70
|
|
|
|
|
|
|
evalue score bias |
71
|
|
|
|
|
|
|
best_dom_evalue best_dom_score best_dom_bias |
72
|
|
|
|
|
|
|
exp dom query_name target_description |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
if ($line =~ m/^\s+ (\d .*)/xms) { |
76
|
|
|
|
|
|
|
my @fields = split /\s+/xms, $1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Fields |
79
|
|
|
|
|
|
|
# 0. full seq - evalue |
80
|
|
|
|
|
|
|
# 1. full seq - score |
81
|
|
|
|
|
|
|
# 2. full seq - bias |
82
|
|
|
|
|
|
|
# 3. best domain - evalue |
83
|
|
|
|
|
|
|
# 4. best domain - score |
84
|
|
|
|
|
|
|
# 5. best domain - bias |
85
|
|
|
|
|
|
|
# 6. #domain - exp |
86
|
|
|
|
|
|
|
# 7. #domain - N |
87
|
|
|
|
|
|
|
# 8. sequence |
88
|
|
|
|
|
|
|
# 9. description |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# coerce numeric fields to numbers |
91
|
|
|
|
|
|
|
@fields[0..7] = map { 0 + $_ } @fields[0..7]; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# fixing description |
94
|
|
|
|
|
|
|
$fields[9] = join q{ }, @fields[9..$#fields]; |
95
|
|
|
|
|
|
|
# set missing/empty field values to undef |
96
|
|
|
|
|
|
|
@fields[8..9] = map { $_ || undef } @fields[8..9]; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my @wanted = @fields[0..9]; |
99
|
|
|
|
|
|
|
push @hits, { mesh @attrs, @wanted }; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# process only header |
103
|
|
|
|
|
|
|
last LINE if $line =~ m/^\>\>/xms; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# split Targets (Hits) |
107
|
|
|
|
|
|
|
my @target_indexes = indexes { m/^\>\>/xms } @lines; |
108
|
|
|
|
|
|
|
my @targets; |
109
|
|
|
|
|
|
|
for (my $i = 0; $i < @target_indexes; $i++) { |
110
|
|
|
|
|
|
|
my @block = defined $target_indexes[$i+1] |
111
|
|
|
|
|
|
|
? @lines[ $target_indexes[$i] .. $target_indexes[$i+1] ] |
112
|
|
|
|
|
|
|
: splice @lines, $target_indexes[$i] |
113
|
|
|
|
|
|
|
; |
114
|
|
|
|
|
|
|
push @targets, Target->new( { raw => \@block, hit => $hits[$i] } ); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
$outargs{targets} = \@targets; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# return expected constructor hash |
119
|
|
|
|
|
|
|
return $class->$orig(%outargs); |
120
|
|
|
|
|
|
|
}; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# aliases for Target/Hit |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
return shift->next_target; |
126
|
|
|
|
|
|
|
} |
127
|
0
|
|
|
0
|
0
|
|
|
128
|
|
|
|
|
|
|
return shift->get_target(@_); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
0
|
0
|
|
return shift->all_targets; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
return shift->count_targets; |
135
|
0
|
|
|
0
|
0
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
138
|
|
|
|
|
|
|
1; |
139
|
0
|
|
|
0
|
0
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=pod |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 NAME |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Bio::FastParsers::Hmmer::Standard::Iteration - Front-end class for standard HMMER parser |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 VERSION |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
version 0.221230 |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 SYNOPSIS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
use aliased 'Bio::FastParsers::Hmmer::Standard'; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# open and parse hmmsearch output |
156
|
|
|
|
|
|
|
my $infile = 'test/hmmer.out'; |
157
|
|
|
|
|
|
|
my $parser = Standard->new(file => $infile); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 DESCRIPTION |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# TODO |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHOR |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Denis BAURAIN <denis.baurain@uliege.be> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=for stopwords Arnaud DI FRANCO |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Arnaud DI FRANCO <arnaud.difranco@gmail.com> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
178
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |