| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::MUST::Drivers::Roles::Hmmerable; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: HMMER model-related methods |
|
3
|
|
|
|
|
|
|
# CONTRIBUTOR: Arnaud DI FRANCO <arnaud.difranco@gmail.com> |
|
4
|
|
|
|
|
|
|
$Bio::MUST::Drivers::Roles::Hmmerable::VERSION = '0.193030'; |
|
5
|
5
|
|
|
5
|
|
9463
|
use Moose::Role; |
|
|
5
|
|
|
|
|
13
|
|
|
|
5
|
|
|
|
|
44
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
27307
|
use autodie; |
|
|
5
|
|
|
|
|
13
|
|
|
|
5
|
|
|
|
|
42
|
|
|
8
|
5
|
|
|
5
|
|
24472
|
use feature qw(say); |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
443
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# use Smart::Comments; |
|
11
|
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
34
|
use Carp; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
367
|
|
|
13
|
5
|
|
|
5
|
|
38
|
use File::Temp; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
360
|
|
|
14
|
5
|
|
|
5
|
|
32
|
use IPC::System::Simple qw(system); |
|
|
5
|
|
|
|
|
124
|
|
|
|
5
|
|
|
|
|
341
|
|
|
15
|
5
|
|
|
5
|
|
43
|
use Module::Runtime qw(use_module); |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
42
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
5
|
|
|
5
|
|
2289
|
use Bio::FastParsers; |
|
|
5
|
|
|
|
|
3209798
|
|
|
|
5
|
|
|
|
|
206
|
|
|
18
|
5
|
|
|
5
|
|
37
|
use aliased 'Bio::MUST::Core::Ali::Stash'; |
|
|
5
|
|
|
|
|
17
|
|
|
|
5
|
|
|
|
|
49
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
5
|
|
|
5
|
|
1140
|
use Bio::MUST::Drivers::Utils qw(stringify_args); |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
3488
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub scan { ## no critic (RequireArgUnpacking) |
|
24
|
0
|
|
|
0
|
0
|
|
return shift->_search('hmmscan', @_); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub search { ## no critic (RequireArgUnpacking) |
|
28
|
0
|
|
|
0
|
0
|
|
return shift->_search('hmmsearch', @_); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _search { |
|
32
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
33
|
0
|
|
|
|
|
|
my $pgm = shift; |
|
34
|
0
|
|
|
|
|
|
my $target = shift; |
|
35
|
0
|
|
0
|
|
|
|
my $args = shift // {}; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# provision executable |
|
38
|
0
|
|
|
|
|
|
my $app = use_module('Bio::MUST::Provision::Hmmer')->new; |
|
39
|
0
|
|
|
|
|
|
$app->meet(); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# setup input/output files |
|
42
|
|
|
|
|
|
|
# Note: we handle both single models and model database... |
|
43
|
|
|
|
|
|
|
# ... as well as plain target filenames in addition to Ali-like objects |
|
44
|
0
|
0
|
|
|
|
|
my $model = $self->can('model') ? $self->model->filename : $self->filename; |
|
45
|
0
|
0
|
|
|
|
|
my $in = $target->can('filename') ? $target->filename : $target; |
|
46
|
0
|
|
|
|
|
|
my $out = File::Temp->new(UNLINK => 0, EXLOCK => 0, SUFFIX => ".$pgm"); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# setup output file format and parser subclass |
|
49
|
0
|
|
|
|
|
|
my $parser_class; |
|
50
|
0
|
0
|
0
|
|
|
|
if (exists $args->{'--domtblout'} || $pgm eq 'hmmscan') { |
|
|
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$args->{'--domtblout'} = $out->filename; |
|
52
|
0
|
|
|
|
|
|
$parser_class = 'Bio::FastParsers::Hmmer::DomTable'; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
elsif (exists $args->{'--tblout'} ) { |
|
55
|
0
|
|
|
|
|
|
$args->{'--tblout'} = $out->filename; |
|
56
|
0
|
|
|
|
|
|
$parser_class = 'Bio::FastParsers::Hmmer::Table'; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
else { |
|
59
|
0
|
|
|
|
|
|
$args->{'--notextw'} = undef; |
|
60
|
0
|
|
|
|
|
|
$args->{'-o'} = $out->filename; |
|
61
|
0
|
|
|
|
|
|
$parser_class = 'Bio::FastParsers::Hmmer::Standard'; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
0
|
0
|
|
|
|
|
unless ($parser_class) { |
|
64
|
0
|
|
|
|
|
|
carp '[BMD] Warning: cannot set parser subclass;' |
|
65
|
|
|
|
|
|
|
. ' returning without parser!'; |
|
66
|
0
|
|
|
|
|
|
return; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# create HMMER command |
|
70
|
0
|
|
|
|
|
|
my $args_str = stringify_args($args); |
|
71
|
0
|
|
|
|
|
|
my $cmd = "$pgm $args_str $model $in > /dev/null 2> /dev/null"; |
|
72
|
|
|
|
|
|
|
#### $cmd |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# try to robustly execute HMMER |
|
75
|
0
|
|
|
|
|
|
my $ret_code = system( [ 0, 127 ], $cmd); |
|
76
|
0
|
0
|
|
|
|
|
if ($ret_code == 127) { |
|
77
|
0
|
|
|
|
|
|
carp "[BMD] Warning: cannot execute $pgm command;" |
|
78
|
|
|
|
|
|
|
. ' returning without parser!'; |
|
79
|
0
|
|
|
|
|
|
return; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return $parser_class->new( file => $out->filename ); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub emit { |
|
86
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
87
|
0
|
|
0
|
|
|
|
my $args = shift // { '-C' => undef }; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# setup input/output files (outfile will be automatically unlinked) |
|
90
|
0
|
|
|
|
|
|
my $model = $self->model->filename; |
|
91
|
0
|
|
|
|
|
|
my $out = File::Temp->new(UNLINK => 1, EXLOCK => 0); |
|
92
|
|
|
|
|
|
|
# TODO: check if lifespan of $out temp file long enough for loading |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# create hmmemit command |
|
95
|
0
|
|
|
|
|
|
$args->{'-o'} = $out; |
|
96
|
0
|
|
|
|
|
|
my $args_str = stringify_args($args); |
|
97
|
0
|
|
|
|
|
|
my $pgm = 'hmmemit'; |
|
98
|
0
|
|
|
|
|
|
my $cmd = "$pgm $args_str $model > /dev/null 2> /dev/null"; |
|
99
|
|
|
|
|
|
|
# hmmemit -C -o hmmconsensus_GNTPAN12210.fasta test_emitGNT.hmm |
|
100
|
|
|
|
|
|
|
#### $cmd |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# try to robustly execute hmmemit |
|
103
|
0
|
|
|
|
|
|
my $ret_code = system( [ 0, 127 ], $cmd); |
|
104
|
0
|
0
|
|
|
|
|
if ($ret_code == 127) { |
|
105
|
0
|
|
|
|
|
|
carp "[BMD] Warning: cannot execute $pgm command;" |
|
106
|
|
|
|
|
|
|
. ' returning without seqs!'; |
|
107
|
0
|
|
|
|
|
|
return; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
return Stash->load( $out->filename ); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
5
|
|
|
5
|
|
39
|
no Moose::Role; |
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
46
|
|
|
114
|
|
|
|
|
|
|
1; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=pod |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 NAME |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Bio::MUST::Drivers::Roles::Hmmerable - HMMER model-related methods |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 VERSION |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
version 0.193030 |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# TODO |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# TODO |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 AUTHOR |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Denis BAURAIN <denis.baurain@uliege.be> |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=for stopwords Arnaud DI FRANCO |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Arnaud DI FRANCO <arnaud.difranco@gmail.com> |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
151
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |