| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::FastParsers::Hmmer::Table; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Front-end class for tabular HMMER parser |
|
3
|
|
|
|
|
|
|
# CONTRIBUTOR: Arnaud DI FRANCO <arnaud.difranco@gmail.com> |
|
4
|
|
|
|
|
|
|
$Bio::FastParsers::Hmmer::Table::VERSION = '0.201110'; |
|
5
|
7
|
|
|
7
|
|
54
|
use Moose; |
|
|
7
|
|
|
|
|
17
|
|
|
|
7
|
|
|
|
|
63
|
|
|
6
|
7
|
|
|
7
|
|
51326
|
use namespace::autoclean; |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
78
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
7
|
|
|
7
|
|
710
|
use autodie; |
|
|
7
|
|
|
|
|
19
|
|
|
|
7
|
|
|
|
|
65
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
39531
|
use List::AllUtils qw(mesh); |
|
|
7
|
|
|
|
|
25
|
|
|
|
7
|
|
|
|
|
700
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
extends 'Bio::FastParsers::Base'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
7
|
|
|
7
|
|
54
|
use Bio::FastParsers::Constants qw(:files); |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
1119
|
|
|
15
|
7
|
|
|
7
|
|
54
|
use aliased 'Bio::FastParsers::Hmmer::Table::Hit'; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
57
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# public attributes (inherited) |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# private attributes |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has '_line_iterator' => ( |
|
24
|
|
|
|
|
|
|
traits => ['Code'], |
|
25
|
|
|
|
|
|
|
is => 'ro', |
|
26
|
|
|
|
|
|
|
isa => 'CodeRef', |
|
27
|
|
|
|
|
|
|
init_arg => undef, |
|
28
|
|
|
|
|
|
|
lazy => 1, |
|
29
|
|
|
|
|
|
|
builder => '_build_line_iterator', |
|
30
|
|
|
|
|
|
|
handles => { |
|
31
|
|
|
|
|
|
|
_next_line => 'execute', |
|
32
|
|
|
|
|
|
|
}, |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
## no critic (ProhibitUnusedPrivateSubroutines) |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _build_line_iterator { |
|
38
|
2
|
|
|
2
|
|
6
|
my $self = shift; |
|
39
|
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
109
|
open my $fh, '<', $self->file; # autodie |
|
41
|
2
|
|
|
66
|
|
2763
|
return sub { <$fh> }; # return closure |
|
|
66
|
|
|
|
|
468
|
|
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
## use critic |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my @attrs = qw( |
|
47
|
|
|
|
|
|
|
target_name target_accession |
|
48
|
|
|
|
|
|
|
query_name query_accession |
|
49
|
|
|
|
|
|
|
evalue score bias |
|
50
|
|
|
|
|
|
|
best_dom_evalue best_dom_score best_dom_bias |
|
51
|
|
|
|
|
|
|
exp reg clu ov env dom rep inc |
|
52
|
|
|
|
|
|
|
target_description |
|
53
|
|
|
|
|
|
|
); # DID try to use MOP to get Hit attrs but order was not preserved |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub next_hit { |
|
57
|
60
|
|
|
60
|
1
|
127
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
LINE: |
|
60
|
60
|
|
|
|
|
2469
|
while (my $line = $self->_next_line) { |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# skip header/comments and empty lines |
|
63
|
64
|
|
|
|
|
150
|
chomp $line; |
|
64
|
64
|
100
|
66
|
|
|
796
|
next LINE if $line =~ $COMMENT_LINE |
|
65
|
|
|
|
|
|
|
|| $line =~ $EMPTY_LINE; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# process Hit line |
|
68
|
58
|
|
|
|
|
657
|
my @fields = split(/\s+/xms, $line, 19); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Fields |
|
71
|
|
|
|
|
|
|
# 0. target name |
|
72
|
|
|
|
|
|
|
# 1. accession |
|
73
|
|
|
|
|
|
|
# 2. query name |
|
74
|
|
|
|
|
|
|
# 3. accession |
|
75
|
|
|
|
|
|
|
# 4. E-value |
|
76
|
|
|
|
|
|
|
# 5. score |
|
77
|
|
|
|
|
|
|
# 6. bias |
|
78
|
|
|
|
|
|
|
# 7. E-value |
|
79
|
|
|
|
|
|
|
# 8. score |
|
80
|
|
|
|
|
|
|
# 9. bias |
|
81
|
|
|
|
|
|
|
# 10. exp |
|
82
|
|
|
|
|
|
|
# 11. reg |
|
83
|
|
|
|
|
|
|
# 12. clu |
|
84
|
|
|
|
|
|
|
# 13. ov |
|
85
|
|
|
|
|
|
|
# 14. env |
|
86
|
|
|
|
|
|
|
# 15. dom |
|
87
|
|
|
|
|
|
|
# 16. rep |
|
88
|
|
|
|
|
|
|
# 17. inc |
|
89
|
|
|
|
|
|
|
# 18. description of target |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# coerce numeric fields to numbers |
|
92
|
58
|
|
|
|
|
182
|
@fields[4..17] = map { 0 + $_ } @fields[4..17]; |
|
|
812
|
|
|
|
|
1687
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# set missing field values to undef |
|
95
|
58
|
100
|
|
|
|
134
|
@fields[1,3,18] = map { $_ eq '-' ? undef : $_ } @fields[1,3,18]; |
|
|
174
|
|
|
|
|
405
|
|
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# return Hit object |
|
98
|
58
|
|
|
|
|
3235
|
return Hit->new( { mesh @attrs, @fields } ); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
2
|
|
|
|
|
10
|
return; # no more line to read |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
105
|
|
|
|
|
|
|
1; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=pod |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 NAME |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Bio::FastParsers::Hmmer::Table - Front-end class for tabular HMMER parser |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 VERSION |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
version 0.201110 |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
use aliased 'Bio::FastParsers::Hmmer::Table'; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# open and parse HMMER report in tabular format |
|
124
|
|
|
|
|
|
|
my $infile = 'test/hmmer.tblout'; |
|
125
|
|
|
|
|
|
|
my $report = Table->new( file => $infile ); |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# loop through hits |
|
128
|
|
|
|
|
|
|
while (my $hit = $hit->next_hit) { |
|
129
|
|
|
|
|
|
|
my ($target_name, $evalue) = ($hit->target_name, $hit->evalue); |
|
130
|
|
|
|
|
|
|
# ... |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# TODO |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 file |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Path to HMMER report file in tabular format (--tblout) to be parsed |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 METHODS |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 next_hit |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Shifts the first Hit of the report off and returns it, shortening the report |
|
148
|
|
|
|
|
|
|
by 1 and moving everything down. If there are no more Hits in the report, |
|
149
|
|
|
|
|
|
|
returns C<undef>. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# $report is a Bio::FastParsers::Hmmer::Table |
|
152
|
|
|
|
|
|
|
while (my $hit = $report->next_hit) { |
|
153
|
|
|
|
|
|
|
# process $hit |
|
154
|
|
|
|
|
|
|
# ... |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This method does not accept any arguments. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 AUTHOR |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Denis BAURAIN <denis.baurain@uliege.be> |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=for stopwords Arnaud DI FRANCO |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Arnaud DI FRANCO <arnaud.difranco@gmail.com> |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
174
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |