line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Sandy::Command::Variation::Add; |
2
|
|
|
|
|
|
|
# ABSTRACT: variation subcommand class. Add structural variation to the database. |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
2449
|
use App::Sandy::Base 'class'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'App::Sandy::Command::Variation'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.24'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use constant { |
11
|
1
|
|
|
|
|
682
|
TYPE_OPT => ['raw', 'vcf'] |
12
|
1
|
|
|
1
|
|
11
|
}; |
|
1
|
|
|
|
|
5
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
override 'opt_spec' => sub { |
15
|
|
|
|
|
|
|
super, |
16
|
|
|
|
|
|
|
'verbose|v', |
17
|
|
|
|
|
|
|
'structural-variation|a=s', |
18
|
|
|
|
|
|
|
'source|s=s', |
19
|
|
|
|
|
|
|
'sample-name|n=s' |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _default_opt { |
23
|
0
|
|
|
0
|
|
|
'verbose' => 0, |
24
|
|
|
|
|
|
|
'type' => 'raw', |
25
|
|
|
|
|
|
|
'source' => 'not defined' |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub validate_args { |
29
|
0
|
|
|
0
|
1
|
|
my ($self, $args) = @_; |
30
|
0
|
|
|
|
|
|
my $file = shift @$args; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Mandatory file |
33
|
0
|
0
|
|
|
|
|
if (not defined $file) { |
34
|
0
|
|
|
|
|
|
die "Missing file (a variation file or vcf file)\n"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Is it really a file? |
38
|
0
|
0
|
|
|
|
|
if (not -f $file) { |
39
|
0
|
|
|
|
|
|
die "'$file' is not a file. Please, give me a valid file\n"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
die "Too many arguments: '@$args'\n" if @$args; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub validate_opts { |
46
|
0
|
|
|
0
|
1
|
|
my ($self, $opts) = @_; |
47
|
0
|
|
|
|
|
|
my %default_opt = $self->_default_opt; |
48
|
0
|
|
|
|
|
|
$self->fill_opts($opts, \%default_opt); |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if (not exists $opts->{'structural-variation'}) { |
51
|
0
|
|
|
|
|
|
die "Mandatory option 'structural-variation' not defined\n"; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub execute { |
56
|
0
|
|
|
0
|
1
|
|
my ($self, $opts, $args) = @_; |
57
|
0
|
|
|
|
|
|
my $file = shift @$args; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my %default_opt = $self->_default_opt; |
60
|
0
|
|
|
|
|
|
$self->fill_opts($opts, \%default_opt); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Set the type of file |
63
|
0
|
0
|
|
|
|
|
if ($file =~ /^.+\.vcf(\.gz)?$/) { |
64
|
0
|
|
|
|
|
|
$opts->{'type'} = 'vcf'; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Set if user wants a verbose log |
68
|
0
|
|
|
|
|
|
$LOG_VERBOSE = $opts->{verbose}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Go go go |
71
|
0
|
|
|
|
|
|
log_msg ":: Inserting $opts->{'structural-variation'} from $file ..."; |
72
|
|
|
|
|
|
|
$self->insertdb( |
73
|
|
|
|
|
|
|
$file, |
74
|
|
|
|
|
|
|
$opts->{'structural-variation'}, |
75
|
|
|
|
|
|
|
$opts->{'source'}, |
76
|
|
|
|
|
|
|
1, |
77
|
|
|
|
|
|
|
$opts->{'type'}, |
78
|
0
|
|
|
|
|
|
$opts->{'sample-name'} |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
log_msg ":: Done!"; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=pod |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=encoding UTF-8 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
App::Sandy::Command::Variation::Add - variation subcommand class. Add structural variation to the database. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 VERSION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
version 0.24 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SYNOPSIS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sandy variation add -a <entry name> [-s <source>] FILE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Arguments: |
103
|
|
|
|
|
|
|
a file (vcf or a genomic-variation file) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Mandatory options: |
106
|
|
|
|
|
|
|
-a, --genomic-variation genomic-variation entries |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Options: |
109
|
|
|
|
|
|
|
-h, --help brief help message |
110
|
|
|
|
|
|
|
-H, --man full documentation |
111
|
|
|
|
|
|
|
-v, --verbose print log messages |
112
|
|
|
|
|
|
|
-s, --source genomic-variation source detail for database |
113
|
|
|
|
|
|
|
-n, --sample-name the sample-name present in one of the optional |
114
|
|
|
|
|
|
|
vcf columns SAMPLES from which the genotype |
115
|
|
|
|
|
|
|
will be extracted |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 DESCRIPTION |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Add genomic-variation to the database. A genomic-variation may be |
120
|
|
|
|
|
|
|
represented by a genomic position (seqid, position), a reference |
121
|
|
|
|
|
|
|
sequence at that postion, an alternate sequence and a genotype |
122
|
|
|
|
|
|
|
(homozygous or heterozygous). |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 INPUT |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The input file may be a vcf or a custom genomic-variation file. |
127
|
|
|
|
|
|
|
For vcf files, the user can point out the sample-name present in |
128
|
|
|
|
|
|
|
vcf header and then its column will be used to extract the |
129
|
|
|
|
|
|
|
genotype. if the user does not pass the option I<--sample-name>, |
130
|
|
|
|
|
|
|
then it will be used the first sample. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
===> my_variations.vcf |
133
|
|
|
|
|
|
|
##fileformat=VCFv4.3 |
134
|
|
|
|
|
|
|
... |
135
|
|
|
|
|
|
|
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA001 NA002 |
136
|
|
|
|
|
|
|
chr20 14370 rs81 G A 29 PASS NS=3;DP=14 GT 0/1 0/0 |
137
|
|
|
|
|
|
|
chr20 17330 rs82 T AAA 3 PASS NS=3;DP=20 GT 1/1 0/0 |
138
|
|
|
|
|
|
|
chr20 110696 rs83 A GTCT 10 PASS NS=2;DP=11 GT 0/1 1/1 |
139
|
|
|
|
|
|
|
... |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
In the I<my_variations.vcf> file, if the user does not point out the |
142
|
|
|
|
|
|
|
sample I<NA002> by passing the options I<--sample-name=NA002>, the |
143
|
|
|
|
|
|
|
sample I<NA001> will be used by default. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
A genomic-variation file is a representation of a reduced VCF, that |
146
|
|
|
|
|
|
|
is, without the columns: QUAL, FILTER, INFO and FORMAT. There is only |
147
|
|
|
|
|
|
|
one SAMPLE column with the genotype for the entry in the format I<HO> |
148
|
|
|
|
|
|
|
for homozygous and I<HE> for heterozygous. See the example bellow: |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
===> my_variations.txt |
151
|
|
|
|
|
|
|
#seqid position id reference alternate genotype |
152
|
|
|
|
|
|
|
chr20 14370 rs81 G A HE |
153
|
|
|
|
|
|
|
chr20 17330 rs82 T AAA HO |
154
|
|
|
|
|
|
|
chr20 110696 rs83 A GTCT HE |
155
|
|
|
|
|
|
|
... |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHORS |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=over 4 |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Thiago L. A. Miller <tmiller@mochsl.org.br> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
J. Leonel Buzzo <lbuzzo@mochsl.org.br> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Felipe R. C. dos Santos <fsantos@mochsl.org.br> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Helena B. Conceição <hconceicao@mochsl.org.br> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Rodrigo Barreiro <rbarreiro@mochsl.org.br> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Gabriela Guardia <gguardia@mochsl.org.br> |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Fernanda Orpinelli <forpinelli@mochsl.org.br> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item * |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Rafael Mercuri <rmercuri@mochsl.org.br> |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item * |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Rodrigo Barreiro <rbarreiro@mochsl.org.br> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Pedro A. F. Galante <pgalante@mochsl.org.br> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=back |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This software is Copyright (c) 2023 by Teaching and Research Institute from Sírio-Libanês Hospital. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
This is free software, licensed under: |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |