| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Sandy::Seq; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Base class to simulate seq entries |
|
3
|
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
4874
|
use App::Sandy::Base 'class'; |
|
|
6
|
|
|
|
|
22
|
|
|
|
6
|
|
|
|
|
72
|
|
|
5
|
6
|
|
|
6
|
|
2464
|
use App::Sandy::Quality; |
|
|
6
|
|
|
|
|
2297
|
|
|
|
6
|
|
|
|
|
291
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
63
|
use constant NUM_TRIES => 1000; |
|
|
6
|
|
|
|
|
22
|
|
|
|
6
|
|
|
|
|
8571
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with qw{ |
|
10
|
|
|
|
|
|
|
App::Sandy::Role::RunTimeTemplate |
|
11
|
|
|
|
|
|
|
App::Sandy::Role::Template::Fastq |
|
12
|
|
|
|
|
|
|
App::Sandy::Role::Template::Sam |
|
13
|
|
|
|
|
|
|
}; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.25'; # VERSION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'format' => ( |
|
18
|
|
|
|
|
|
|
is => 'ro', |
|
19
|
|
|
|
|
|
|
isa => 'My:Format', |
|
20
|
|
|
|
|
|
|
required => 1 |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'template_id' => ( |
|
24
|
|
|
|
|
|
|
is => 'ro', |
|
25
|
|
|
|
|
|
|
isa => 'Str', |
|
26
|
|
|
|
|
|
|
required => 1 |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'sequencing_error' => ( |
|
30
|
|
|
|
|
|
|
is => 'ro', |
|
31
|
|
|
|
|
|
|
isa => 'My:NumHS', |
|
32
|
|
|
|
|
|
|
required => 1 |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has 'quality_profile' => ( |
|
36
|
|
|
|
|
|
|
is => 'ro', |
|
37
|
|
|
|
|
|
|
isa => 'My:QualityP', |
|
38
|
|
|
|
|
|
|
required => 1, |
|
39
|
|
|
|
|
|
|
coerce => 1 |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has 'read_mean' => ( |
|
43
|
|
|
|
|
|
|
is => 'ro', |
|
44
|
|
|
|
|
|
|
isa => 'My:IntGt0', |
|
45
|
|
|
|
|
|
|
required => 1 |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has 'read_stdd' => ( |
|
49
|
|
|
|
|
|
|
is => 'ro', |
|
50
|
|
|
|
|
|
|
isa => 'My:IntGe0', |
|
51
|
|
|
|
|
|
|
required => 1 |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has '_template_id' => ( |
|
55
|
|
|
|
|
|
|
traits => ['Code'], |
|
56
|
|
|
|
|
|
|
is => 'ro', |
|
57
|
|
|
|
|
|
|
isa => 'CodeRef', |
|
58
|
|
|
|
|
|
|
builder => '_build_template_id', |
|
59
|
|
|
|
|
|
|
lazy_build => 1, |
|
60
|
|
|
|
|
|
|
handles => { |
|
61
|
|
|
|
|
|
|
_gen_id => 'execute' |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has '_template_seq' => ( |
|
66
|
|
|
|
|
|
|
traits => ['Code'], |
|
67
|
|
|
|
|
|
|
is => 'ro', |
|
68
|
|
|
|
|
|
|
isa => 'CodeRef', |
|
69
|
|
|
|
|
|
|
builder => '_build_template_seq', |
|
70
|
|
|
|
|
|
|
lazy_build => 1, |
|
71
|
|
|
|
|
|
|
handles => { |
|
72
|
|
|
|
|
|
|
_gen_seq => 'execute' |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
has '_info' => ( |
|
77
|
|
|
|
|
|
|
traits => ['Hash'], |
|
78
|
|
|
|
|
|
|
is => 'ro', |
|
79
|
|
|
|
|
|
|
isa => 'HashRef[Str]', |
|
80
|
|
|
|
|
|
|
builder => '_build_info', |
|
81
|
|
|
|
|
|
|
lazy_build => 1, |
|
82
|
|
|
|
|
|
|
handles => { |
|
83
|
|
|
|
|
|
|
_set_info => 'set', |
|
84
|
|
|
|
|
|
|
_get_info => 'get' |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
has '_read_size' => ( |
|
89
|
|
|
|
|
|
|
traits => ['Code'], |
|
90
|
|
|
|
|
|
|
is => 'ro', |
|
91
|
|
|
|
|
|
|
isa => 'CodeRef', |
|
92
|
|
|
|
|
|
|
builder => '_build_read_size', |
|
93
|
|
|
|
|
|
|
lazy_build => 1, |
|
94
|
|
|
|
|
|
|
handles => { |
|
95
|
|
|
|
|
|
|
_get_read_size => 'execute' |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
has '_quality' => ( |
|
100
|
|
|
|
|
|
|
is => 'ro', |
|
101
|
|
|
|
|
|
|
isa => 'App::Sandy::Quality', |
|
102
|
|
|
|
|
|
|
builder => '_build_quality', |
|
103
|
|
|
|
|
|
|
lazy_build => 1, |
|
104
|
|
|
|
|
|
|
handles => ['gen_quality'] |
|
105
|
|
|
|
|
|
|
); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
has '_sym_table' => ( |
|
108
|
|
|
|
|
|
|
is => 'ro', |
|
109
|
|
|
|
|
|
|
isa => 'HashRef[Str]', |
|
110
|
|
|
|
|
|
|
builder => '_build_sym_table', |
|
111
|
|
|
|
|
|
|
lazy_build => 1 |
|
112
|
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub BUILD { |
|
115
|
28
|
|
|
28
|
0
|
54
|
my $self = shift; |
|
116
|
|
|
|
|
|
|
## Just to ensure that the lazy attributes are built before &new returns |
|
117
|
28
|
|
|
|
|
840
|
$self->_quality; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub _build_sym_table { |
|
121
|
6
|
|
|
6
|
|
295
|
my $sym_table = { |
|
122
|
|
|
|
|
|
|
'%q' => '$info->{quality_profile}', |
|
123
|
|
|
|
|
|
|
'%m' => '$info->{read_mean}', |
|
124
|
|
|
|
|
|
|
'%d' => '$info->{read_stdd}', |
|
125
|
|
|
|
|
|
|
'%r' => '$info->{read_size}', |
|
126
|
|
|
|
|
|
|
'%e' => '$info->{sequencing_error}', |
|
127
|
|
|
|
|
|
|
'%c' => '$info->{seq_id}', |
|
128
|
|
|
|
|
|
|
'%C' => '$info->{seq_id_type}', |
|
129
|
|
|
|
|
|
|
'%a' => '$info->{start_ref}', |
|
130
|
|
|
|
|
|
|
'%b' => '$info->{end_ref}', |
|
131
|
|
|
|
|
|
|
'%t' => '$info->{start}', |
|
132
|
|
|
|
|
|
|
'%n' => '$info->{end}', |
|
133
|
|
|
|
|
|
|
'%i' => '$info->{instrument}', |
|
134
|
|
|
|
|
|
|
'%I' => '$info->{id}', |
|
135
|
|
|
|
|
|
|
'%R' => '$info->{read}', |
|
136
|
|
|
|
|
|
|
'%U' => '$info->{num}', |
|
137
|
|
|
|
|
|
|
'%s' => '$info->{strand}', |
|
138
|
|
|
|
|
|
|
'%x' => '$info->{error}', |
|
139
|
|
|
|
|
|
|
'%v' => '$info->{var}' |
|
140
|
|
|
|
|
|
|
}; |
|
141
|
|
|
|
|
|
|
|
|
142
|
6
|
|
|
|
|
113
|
return $sym_table; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub _build_template_id { |
|
146
|
6
|
|
|
6
|
|
63
|
my $self = shift; |
|
147
|
6
|
|
|
|
|
461
|
my $sym_table = $self->_sym_table; |
|
148
|
6
|
|
|
|
|
287
|
return $self->with_compile_template($self->template_id, 'info', $sym_table); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub _build_template_seq { |
|
152
|
9
|
|
|
9
|
|
28
|
my $self = shift; |
|
153
|
|
|
|
|
|
|
|
|
154
|
9
|
|
|
|
|
369
|
my $format = $self->format; |
|
155
|
9
|
|
|
|
|
35
|
my $gen_seq; |
|
156
|
|
|
|
|
|
|
|
|
157
|
9
|
50
|
|
|
|
64
|
if ($format =~ /fastq/) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
158
|
9
|
|
|
9129
|
|
73
|
$gen_seq = sub { $self->with_fastq_template(@_) }; |
|
|
9129
|
|
|
|
|
27904
|
|
|
159
|
|
|
|
|
|
|
} elsif ($format eq 'sam') { |
|
160
|
0
|
|
|
0
|
|
0
|
$gen_seq = sub { $self->with_sam_align_template(@_) }; |
|
|
0
|
|
|
|
|
0
|
|
|
161
|
|
|
|
|
|
|
} elsif ($format eq 'bam') { |
|
162
|
0
|
|
|
0
|
|
0
|
$gen_seq = sub { $self->with_bam_align_template(@_) }; |
|
|
0
|
|
|
|
|
0
|
|
|
163
|
|
|
|
|
|
|
} else { |
|
164
|
0
|
|
|
|
|
0
|
croak "No valid format: '$format'"; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
9
|
|
|
|
|
379
|
return $gen_seq; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub _build_info { |
|
171
|
6
|
|
|
6
|
|
456
|
my $self = shift; |
|
172
|
|
|
|
|
|
|
|
|
173
|
6
|
|
|
|
|
335
|
my $info = { |
|
174
|
|
|
|
|
|
|
instrument => 'SR', |
|
175
|
|
|
|
|
|
|
quality_profile => $self->quality_profile, |
|
176
|
|
|
|
|
|
|
sequencing_error => $self->sequencing_error, |
|
177
|
|
|
|
|
|
|
read_mean => $self->read_mean, |
|
178
|
|
|
|
|
|
|
read_stdd => $self->read_stdd |
|
179
|
|
|
|
|
|
|
}; |
|
180
|
|
|
|
|
|
|
|
|
181
|
6
|
|
|
|
|
148
|
return $info; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub _build_read_size { |
|
185
|
6
|
|
|
6
|
|
52
|
my $self = shift; |
|
186
|
6
|
|
|
|
|
40
|
my $fun; |
|
187
|
|
|
|
|
|
|
|
|
188
|
6
|
50
|
|
|
|
449
|
if ($self->read_stdd == 0) { |
|
189
|
6
|
|
|
6844
|
|
202
|
$fun = sub { $self->read_mean }; |
|
|
6844
|
|
|
|
|
160514
|
|
|
190
|
|
|
|
|
|
|
} else { |
|
191
|
|
|
|
|
|
|
$fun = sub { |
|
192
|
0
|
|
|
0
|
|
0
|
my $rng = shift; |
|
193
|
0
|
|
|
|
|
0
|
my $size = 0; |
|
194
|
0
|
|
|
|
|
0
|
my $random_tries = 0; |
|
195
|
0
|
|
|
|
|
0
|
until ($size > 0) { |
|
196
|
0
|
0
|
|
|
|
0
|
if (++$random_tries > NUM_TRIES) { |
|
197
|
0
|
|
|
|
|
0
|
croak "So many tries to calculate a seq size greater than zero ..."; |
|
198
|
|
|
|
|
|
|
} |
|
199
|
0
|
|
|
|
|
0
|
$size = $rng->get_norm($self->read_mean, $self->read_stdd); |
|
200
|
|
|
|
|
|
|
} |
|
201
|
0
|
|
|
|
|
0
|
return $size; |
|
202
|
0
|
|
|
|
|
0
|
}; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
6
|
|
|
|
|
330
|
return $fun; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub _build_quality { |
|
209
|
28
|
|
|
28
|
|
42
|
my $self = shift; |
|
210
|
28
|
|
|
|
|
776
|
App::Sandy::Quality->new( |
|
211
|
|
|
|
|
|
|
quality_profile => $self->quality_profile |
|
212
|
|
|
|
|
|
|
); |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub gen_sam_header { |
|
216
|
0
|
|
|
0
|
0
|
|
my ($self, $argv) = @_; |
|
217
|
0
|
|
|
|
|
|
my $format = $self->format; |
|
218
|
0
|
|
|
|
|
|
my $header; |
|
219
|
|
|
|
|
|
|
|
|
220
|
0
|
0
|
|
|
|
|
if ($format eq 'sam') { |
|
|
|
0
|
|
|
|
|
|
|
221
|
0
|
|
|
|
|
|
$header = $self->with_sam_header_template($argv); |
|
222
|
|
|
|
|
|
|
} elsif ($format eq 'bam') { |
|
223
|
0
|
|
|
|
|
|
$header = $self->with_bam_header_template($argv); |
|
224
|
|
|
|
|
|
|
} else { |
|
225
|
0
|
|
|
|
|
|
croak "No valid format: '$format'"; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
|
return $header; |
|
229
|
|
|
|
|
|
|
} |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub gen_eof_marker { |
|
232
|
0
|
|
|
0
|
0
|
|
my ($self, $file) = @_; |
|
233
|
|
|
|
|
|
|
|
|
234
|
0
|
0
|
|
|
|
|
open my $fh, ">>" => $file |
|
235
|
|
|
|
|
|
|
or croak "Cannot open '$file': $!"; |
|
236
|
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
binmode $fh; |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
my $eof_ref = $self->with_eof_marker; |
|
240
|
0
|
|
|
|
|
|
print {$fh} $$eof_ref; |
|
|
0
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
|
|
242
|
0
|
0
|
|
|
|
|
close $fh |
|
243
|
|
|
|
|
|
|
or croak "Cannot write to '$file': $!"; |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
__END__ |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=pod |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=encoding UTF-8 |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 NAME |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
App::Sandy::Seq - Base class to simulate seq entries |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 VERSION |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
version 0.25 |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 AUTHORS |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=over 4 |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=item * |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Thiago L. A. Miller <tmiller@mochsl.org.br> |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=item * |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
J. Leonel Buzzo <lbuzzo@mochsl.org.br> |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=item * |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Felipe R. C. dos Santos <fsantos@mochsl.org.br> |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=item * |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Helena B. Conceição <hconceicao@mochsl.org.br> |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=item * |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Rodrigo Barreiro <rbarreiro@mochsl.org.br> |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=item * |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Gabriela Guardia <gguardia@mochsl.org.br> |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=item * |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
Fernanda Orpinelli <forpinelli@mochsl.org.br> |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=item * |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
Rafael Mercuri <rmercuri@mochsl.org.br> |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=item * |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Rodrigo Barreiro <rbarreiro@mochsl.org.br> |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=item * |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
Pedro A. F. Galante <pgalante@mochsl.org.br> |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=back |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
This software is Copyright (c) 2023 by Teaching and Research Institute from Sírio-Libanês Hospital. |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
This is free software, licensed under: |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=cut |