line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::MUST::Drivers::Cap3; |
2
|
|
|
|
|
|
|
# ABSTRACT: Bio::MUST driver for running the CAP3 assembly program |
3
|
|
|
|
|
|
|
$Bio::MUST::Drivers::Cap3::VERSION = '0.210160'; |
4
|
5
|
|
|
5
|
|
41
|
use Moose; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
41
|
|
5
|
5
|
|
|
5
|
|
36526
|
use namespace::autoclean; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
48
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
494
|
use autodie; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
48
|
|
8
|
5
|
|
|
5
|
|
28529
|
use feature qw(say); |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
504
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# use Smart::Comments; |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
39
|
use Carp; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
447
|
|
13
|
5
|
|
|
5
|
|
40
|
use IPC::System::Simple qw(system); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
323
|
|
14
|
5
|
|
|
5
|
|
40
|
use Module::Runtime qw(use_module); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
50
|
|
15
|
5
|
|
|
5
|
|
468
|
use Path::Class qw(file); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
299
|
|
16
|
5
|
|
|
5
|
|
44
|
use Tie::IxHash; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
198
|
|
17
|
|
|
|
|
|
|
|
18
|
5
|
|
|
5
|
|
39
|
use Bio::MUST::Core; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
231
|
|
19
|
|
|
|
|
|
|
extends 'Bio::MUST::Core::Ali::Temporary'; |
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
5
|
|
45
|
use Bio::MUST::Core::Constants qw(:files); |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
1080
|
|
22
|
5
|
|
|
5
|
|
39
|
use aliased 'Bio::MUST::Core::Ali'; |
|
5
|
|
|
|
|
23
|
|
|
5
|
|
|
|
|
49
|
|
23
|
5
|
|
|
5
|
|
1229
|
use aliased 'Bio::MUST::Core::SeqId'; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
77
|
|
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
5
|
|
1197
|
use Bio::MUST::Drivers::Utils qw(stringify_args); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
4625
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'cap3_args' => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => 'HashRef', |
31
|
|
|
|
|
|
|
default => sub { {} }, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has '_contig_seq_ids' => ( |
35
|
|
|
|
|
|
|
traits => ['Hash'], |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
isa => 'HashRef[ArrayRef[Bio::MUST::Core::SeqId]]', |
38
|
|
|
|
|
|
|
init_arg => undef, |
39
|
|
|
|
|
|
|
writer => '_set_contig_seq_ids', |
40
|
|
|
|
|
|
|
handles => { |
41
|
|
|
|
|
|
|
all_contig_names => 'keys', |
42
|
|
|
|
|
|
|
all_contig_seq_ids => 'values', |
43
|
|
|
|
|
|
|
seq_ids_for => 'get', |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has '_contigs' => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
isa => 'Bio::MUST::Core::Ali', |
50
|
|
|
|
|
|
|
init_arg => undef, |
51
|
|
|
|
|
|
|
writer => '_set_contigs', |
52
|
|
|
|
|
|
|
handles => { |
53
|
|
|
|
|
|
|
all_contigs => 'all_seqs', |
54
|
|
|
|
|
|
|
count_contigs => 'count_seqs', |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has '_singlets' => ( |
59
|
|
|
|
|
|
|
is => 'ro', |
60
|
|
|
|
|
|
|
isa => 'Bio::MUST::Core::Ali', |
61
|
|
|
|
|
|
|
init_arg => undef, |
62
|
|
|
|
|
|
|
writer => '_set_singlets', |
63
|
|
|
|
|
|
|
handles => { |
64
|
|
|
|
|
|
|
all_singlets => 'all_seqs', |
65
|
|
|
|
|
|
|
count_singlets => 'count_seqs', |
66
|
|
|
|
|
|
|
}, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub BUILD { |
71
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# provision executable |
74
|
0
|
|
|
|
|
|
my $app = use_module('Bio::MUST::Provision::Cap3')->new; |
75
|
0
|
|
|
|
|
|
$app->meet(); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# setup output files |
78
|
0
|
|
|
|
|
|
my $infile = $self->filename; |
79
|
0
|
|
|
|
|
|
my $basename = $infile . '.cap'; |
80
|
0
|
|
|
|
|
|
my $outfile = $basename . '.out'; |
81
|
0
|
|
|
|
|
|
my $outfile_contigs = $basename . '.contigs'; |
82
|
0
|
|
|
|
|
|
my $outfile_singlets = $basename . '.singlets'; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# format CAP3 (optional) arguments |
85
|
0
|
|
|
|
|
|
my $args = $self->cap3_args; |
86
|
0
|
|
|
|
|
|
my $args_str = stringify_args($args); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# create CAP3 command |
89
|
0
|
|
|
|
|
|
my $pgm = 'cap3'; |
90
|
0
|
|
|
|
|
|
my $cmd = "$pgm $infile $args_str > $outfile 2> /dev/null"; |
91
|
|
|
|
|
|
|
#### $cmd |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# try to robustly execute CAP3 |
94
|
0
|
|
|
|
|
|
my $ret_code = system( [ 0, 127 ], $cmd); |
95
|
0
|
0
|
|
|
|
|
if ($ret_code == 127) { |
96
|
0
|
|
|
|
|
|
carp "[BMD] Warning: cannot execute $pgm command;" |
97
|
|
|
|
|
|
|
. ' returning without contigs!'; |
98
|
0
|
|
|
|
|
|
return; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
# TODO: try to bypass shell (need for absolute path to executable then) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# parse output file |
103
|
0
|
|
|
|
|
|
open my $out, '<', $outfile; |
104
|
0
|
|
|
|
|
|
tie my %ids_for, 'Tie::IxHash'; |
105
|
0
|
|
|
|
|
|
my $contig_id; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# CAP3 output file extract |
108
|
|
|
|
|
|
|
# |
109
|
|
|
|
|
|
|
# Number of segment pairs = 342; number of pairwise comparisons = 8 |
110
|
|
|
|
|
|
|
# '+' means given segment; '-' means reverse complement |
111
|
|
|
|
|
|
|
# |
112
|
|
|
|
|
|
|
# Overlaps Containments No. of Constraints Supporting Overlap |
113
|
|
|
|
|
|
|
# |
114
|
|
|
|
|
|
|
# ******************* Contig 1 ******************** |
115
|
|
|
|
|
|
|
# seq8+ |
116
|
|
|
|
|
|
|
# seq9+ is in seq8+ |
117
|
|
|
|
|
|
|
# ******************* Contig 2 ******************** |
118
|
|
|
|
|
|
|
# seq10+ |
119
|
|
|
|
|
|
|
# seq11+ |
120
|
|
|
|
|
|
|
# ******************* Contig 3 ******************** |
121
|
|
|
|
|
|
|
# seq12+ |
122
|
|
|
|
|
|
|
# seq13+ is in seq12+ |
123
|
|
|
|
|
|
|
# seq14+ is in seq13+ |
124
|
|
|
|
|
|
|
# ******************* Contig 4 ******************** |
125
|
|
|
|
|
|
|
# seq15+ |
126
|
|
|
|
|
|
|
# seq16+ |
127
|
|
|
|
|
|
|
# ******************* Contig 5 ******************** |
128
|
|
|
|
|
|
|
# seq17+ |
129
|
|
|
|
|
|
|
# seq18+ |
130
|
|
|
|
|
|
|
# seq19+ is in seq18+ |
131
|
|
|
|
|
|
|
# |
132
|
|
|
|
|
|
|
# DETAILED DISPLAY OF CONTIGS |
133
|
|
|
|
|
|
|
# ******************* Contig 1 ******************** |
134
|
|
|
|
|
|
|
# . : . : . : . : . : . : |
135
|
|
|
|
|
|
|
# seq8+ CTGGACGAGCTGCAGGAGGAGGCGCTGGCGCTGGTGGCGCAGGCCCGACGAGAGGGCGAC |
136
|
|
|
|
|
|
|
# ____________________________________________________________ |
137
|
|
|
|
|
|
|
# consensus CTGGACGAGCTGCAGGAGGAGGCGCTGGCGCTGGTGGCGCAGGCCCGACGAGAGGGCGAC |
138
|
|
|
|
|
|
|
# |
139
|
|
|
|
|
|
|
# ... |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
LINE: |
142
|
0
|
|
|
|
|
|
while (my $line = <$out>) { |
143
|
0
|
|
|
|
|
|
chomp $line; |
144
|
|
|
|
|
|
|
|
145
|
0
|
0
|
|
|
|
|
next LINE if $line =~ $EMPTY_LINE; |
146
|
0
|
0
|
|
|
|
|
last LINE if $line =~ m{\A DETAILED \s+ DISPLAY \s+ OF \s+ CONTIGS}xms; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# capture next contig id |
149
|
0
|
0
|
0
|
|
|
|
if ($line =~ m{\A \*+ \s+ (Contig\s+\d+) \s+ \*+}xms) { |
|
|
0
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
($contig_id = $1) =~ tr/ //d; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# capture fragment ids for current contig... |
154
|
|
|
|
|
|
|
elsif ($line =~ m{\A ([^\'\+\-\ ]+)[+-]}xms |
155
|
|
|
|
|
|
|
|| $line =~ m{\A \s+ (\S+?)[+-]}xms) { |
156
|
0
|
|
|
|
|
|
my $fragment_id = $1; |
157
|
0
|
|
|
|
|
|
push @{ $ids_for{$contig_id} }, |
|
0
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
SeqId->new( full_id => $self->long_id_for($fragment_id) ); |
159
|
|
|
|
|
|
|
} # ... and restore original id on the fly from IdMapper |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# store contig and fragment ids |
163
|
0
|
|
|
|
|
|
$self->_set_contig_seq_ids(\%ids_for); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# read and store contig seqs |
166
|
0
|
|
|
|
|
|
my $contigs = Ali->load($outfile_contigs); |
167
|
0
|
|
|
|
|
|
$contigs->dont_guess; |
168
|
0
|
|
|
|
|
|
$self->_set_contigs($contigs); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# read and store singlet seqs... |
171
|
0
|
|
|
|
|
|
my $singlets = Ali->load($outfile_singlets); |
172
|
0
|
|
|
|
|
|
$singlets->dont_guess; |
173
|
0
|
|
|
|
|
|
$singlets->restore_ids($self->mapper); # ... restoring original ids |
174
|
0
|
|
|
|
|
|
$self->_set_singlets($singlets); |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# unlink temp files |
177
|
|
|
|
|
|
|
my @files2rm = ( |
178
|
|
|
|
|
|
|
$outfile, $outfile_contigs, $outfile_singlets, |
179
|
0
|
|
|
|
|
|
map { $basename . '.' . $_ } qw(info ace contigs.links contigs.qual) |
|
0
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
); |
181
|
0
|
|
|
|
|
|
file($_)->remove for @files2rm; |
182
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
return; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
187
|
|
|
|
|
|
|
1; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
__END__ |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=pod |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 NAME |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Bio::MUST::Drivers::Cap3 - Bio::MUST driver for running the CAP3 assembly program |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 VERSION |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
version 0.210160 |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 SYNOPSIS |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
# TODO |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 DESCRIPTION |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# TODO |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 AUTHOR |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Denis BAURAIN <denis.baurain@uliege.be> |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
218
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=cut |