Skip to content

Commit 8656eb4

Browse files
committed
answer to #2354 (comment) . Update help screen, added tests
1 parent e4e5e54 commit 8656eb4

File tree

4 files changed

+357
-17
lines changed

4 files changed

+357
-17
lines changed

plugins/vcf2table.c

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -661,20 +661,21 @@ const char* about(void) {
661661
"Author Pierre Lindenbaum PhD. Institut-du-Thorax. U1087. "
662662
"Nantes/France\n"
663663
"Options:\n"
664-
" --hide (string) comma separated of features to hide:\n"
665-
" HOM_REF or RR : genotypes with REF allele only\n"
666-
" HET or AR : heterozygous genotypes\n"
667-
" NO_CALL or MISSING : missing genotypes\n"
668-
" CSQ or VEP : VEP table\n"
669-
" SPLICEAI : SPLICEAI table\n"
670-
" ANN or SNPEFF : SNPEFF table\n"
671-
" LOF: SNPEFF LOF table\n"
672-
" VC: general table\n"
673-
" INFO: INFO table\n"
674-
" GT: Genotype table\n"
675-
" GTTYPES: Genotype count table\n"
676-
" URL: hyperlink table\n"
677-
"Example:\n"
664+
" -h|--help (string) help (this screen).\n"
665+
" -x|--hide (string) comma separated list of features to hide:\n"
666+
" HOM_REF or RR : genotypes with REF allele only\n"
667+
" HET or AR : heterozygous genotypes\n"
668+
" NO_CALL or MISSING : missing genotypes\n"
669+
" CSQ or VEP : VEP table\n"
670+
" SPLICEAI : SPLICEAI table\n"
671+
" ANN or SNPEFF : SNPEFF table\n"
672+
" LOF: SNPEFF LOF table\n"
673+
" VC: general table\n"
674+
" INFO: INFO table\n"
675+
" GT: Genotype table\n"
676+
" GTTYPES: Genotype count table\n"
677+
" URL: hyperlink table\n"
678+
"\nExample:\n"
678679
"$ wget -O - "
679680
"'http://ftp.1000genomes.ebi.ac.uk/vol1/ftp/data_collections/"
680681
"1000_genomes_project/release/20190312_biallelic_SNV_and_INDEL/"
@@ -745,8 +746,12 @@ int init(int argc, char** argv, bcf_hdr_t* hdr_in, bcf_hdr_t* out) {
745746
args.gtypeTable = TableNewStr("Type", "Count", "%", NULL);
746747
args.hyperlinksTable = TableNewStr("DB", "" /* empty/misc */, "URL", NULL);
747748

748-
static struct option loptions[] = {{"hide", required_argument, NULL, 'x'},
749-
{0, 0, 0, 0}};
749+
static struct option loptions[] =
750+
{
751+
{"help", required_argument, NULL, 'h'},
752+
{"hide", required_argument, NULL, 'x'},
753+
{0, 0, 0, 0}
754+
};
750755

751756
while ((c = getopt_long(argc, argv, "hx:", loptions, NULL)) >= 0) {
752757
switch (c) {
@@ -800,9 +805,13 @@ int init(int argc, char** argv, bcf_hdr_t* hdr_in, bcf_hdr_t* out) {
800805
break;
801806
}
802807
case 'h':
808+
fputs(about(), stdout);
809+
exit(EXIT_SUCCESS);
810+
break;
803811
case '?':
804812
default:
805-
error("wrong arguments");
813+
error("wrong arguments. Use option --help to get help.\n");
814+
exit(EXIT_FAILURE);
806815
break;
807816
}
808817
}

test/test.pl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,9 @@
10591059
run_test(\&test_gtcheck,$opts,in=>'gtcheck.5',gts=>'gtcheck.5.gts',out=>'gtcheck.5.1.out',args=>q[],grep=>'grep -v Time');
10601060
run_test(\&test_gtcheck,$opts,in=>'gtcheck.6',out=>'gtcheck.6.1.out',args=>q[-p A,B,B,C]);
10611061
run_test(\&test_gtcheck,$opts,in=>'gtcheck.3',out=>'gtcheck.3.1.out',args=>q[-t 11:33 -p A,D,A,E,D,E -u GT -e 10]);
1062+
run_test(\&test_vcf_plugin,$opts,in=>'merge.4.b',out=>'vcf2table.1.out',cmd=>'+vcf2table',args=>qq[]);
1063+
run_test(\&test_vcf_plugin,$opts,in=>'split-vep.2',out=>'vcf2table.2.out',cmd=>'+vcf2table',args=>qq[ -- --hide 'INFO,URL']);
1064+
10621065
10631066
print "\nNumber of tests:\n";
10641067
printf " total .. %d\n", $$opts{nok}+$$opts{nfailed};

test/vcf2table.1.out

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
<<< 1:3000000:C (n. 1)
2+
3+
# Variant
4+
+--------+---------+
5+
| KEY | VALUE |
6+
+--------+---------+
7+
| CHROM | 1 |
8+
| POS | 3000000 |
9+
| ID | . |
10+
| REF | C |
11+
| ALT | A |
12+
| QUAL | 59.2 |
13+
| FILTER | PASS |
14+
+--------+---------+
15+
16+
# INFO
17+
+-----+-----+-------+
18+
| KEY | IDX | VALUE |
19+
+-----+-----+-------+
20+
| AN | | 4 |
21+
| AC | | 2 |
22+
+-----+-----+-------+
23+
24+
# GENOTYPE TYPES
25+
+------+-------+-----+
26+
| Type | Count | % |
27+
+------+-------+-----+
28+
| HET | 2 | 100 |
29+
+------+-------+-----+
30+
31+
# GENOTYPES
32+
+--------+-------+-----+-----+
33+
| SAMPLE | GTYPE | GT | GQ |
34+
+--------+-------+-----+-----+
35+
| C | HET | 0/1 | 245 |
36+
| D | HET | 0/1 | 245 |
37+
+--------+-------+-----+-----+
38+
39+
>>> 1:3000000:C (n. 1)
40+
41+
<<< 1:3000000:C (n. 2)
42+
43+
# Variant
44+
+--------+---------+
45+
| KEY | VALUE |
46+
+--------+---------+
47+
| CHROM | 1 |
48+
| POS | 3000000 |
49+
| ID | id1 |
50+
| REF | C |
51+
| ALT | A |
52+
| QUAL | 59.2 |
53+
| FILTER | PASS |
54+
+--------+---------+
55+
56+
# INFO
57+
+-----+-----+-------+
58+
| KEY | IDX | VALUE |
59+
+-----+-----+-------+
60+
| AN | | 4 |
61+
| AC | | 2 |
62+
| TR | 1 | 1 |
63+
| TR | 2 | 2 |
64+
| TA | | 1 |
65+
| TG | 1 | 1 |
66+
| TG | 2 | 2 |
67+
| TG | 3 | 3 |
68+
+-----+-----+-------+
69+
70+
# GENOTYPE TYPES
71+
+------+-------+-----+
72+
| Type | Count | % |
73+
+------+-------+-----+
74+
| HET | 2 | 100 |
75+
+------+-------+-----+
76+
77+
# GENOTYPES
78+
+--------+-------+-----+-----+-----+-------+----+
79+
| SAMPLE | GTYPE | GT | GQ | XR | XG | XA |
80+
+--------+-------+-----+-----+-----+-------+----+
81+
| C | HET | 0/1 | 245 | 4,5 | 3,4,5 | 5 |
82+
| D | HET | 0/1 | 245 | 6,7 | 6,7,8 | 7 |
83+
+--------+-------+-----+-----+-----+-------+----+
84+
85+
>>> 1:3000000:C (n. 2)
86+
87+
<<< 1:3000002:C (n. 3)
88+
89+
# Variant
90+
+--------+---------+
91+
| KEY | VALUE |
92+
+--------+---------+
93+
| CHROM | 1 |
94+
| POS | 3000002 |
95+
| ID | id3 |
96+
| REF | C |
97+
| ALT | A |
98+
| QUAL | 59.2 |
99+
| FILTER | PASS |
100+
+--------+---------+
101+
102+
# INFO
103+
+-----+-----+-------+
104+
| KEY | IDX | VALUE |
105+
+-----+-----+-------+
106+
| AN | | 4 |
107+
| AC | | 2 |
108+
| TR | 1 | 1 |
109+
| TR | 2 | 2 |
110+
| TA | | 1 |
111+
| TG | 1 | 1 |
112+
| TG | 2 | 2 |
113+
| TG | 3 | 3 |
114+
+-----+-----+-------+
115+
116+
# GENOTYPE TYPES
117+
+------+-------+-----+
118+
| Type | Count | % |
119+
+------+-------+-----+
120+
| HET | 2 | 100 |
121+
+------+-------+-----+
122+
123+
# GENOTYPES
124+
+--------+-------+-----+-----+-----+-------+----+
125+
| SAMPLE | GTYPE | GT | GQ | XR | XG | XA |
126+
+--------+-------+-----+-----+-----+-------+----+
127+
| C | HET | 0/1 | 245 | . | . | . |
128+
| D | HET | 0/1 | 245 | 1,2 | 1,2,3 | 2 |
129+
+--------+-------+-----+-----+-----+-------+----+
130+
131+
>>> 1:3000002:C (n. 3)
132+
133+
<<< 1:3000002:C (n. 4)
134+
135+
# Variant
136+
+--------+---------+
137+
| KEY | VALUE |
138+
+--------+---------+
139+
| CHROM | 1 |
140+
| POS | 3000002 |
141+
| ID | id2 |
142+
| REF | C |
143+
| ALT | A |
144+
| QUAL | 59.2 |
145+
| FILTER | PASS |
146+
+--------+---------+
147+
148+
# INFO
149+
+-----+-----+-------+
150+
| KEY | IDX | VALUE |
151+
+-----+-----+-------+
152+
| AN | | 4 |
153+
| AC | | 2 |
154+
| TR | 1 | 1 |
155+
| TR | 2 | 2 |
156+
| TA | | 1 |
157+
| TG | 1 | 1 |
158+
| TG | 2 | 2 |
159+
| TG | 3 | 3 |
160+
+-----+-----+-------+
161+
162+
# GENOTYPE TYPES
163+
+------+-------+-----+
164+
| Type | Count | % |
165+
+------+-------+-----+
166+
| HET | 2 | 100 |
167+
+------+-------+-----+
168+
169+
# GENOTYPES
170+
+--------+-------+-----+-----+----+----+----+
171+
| SAMPLE | GTYPE | GT | GQ | XR | XG | XA |
172+
+--------+-------+-----+-----+----+----+----+
173+
| C | HET | 0/1 | 245 | . | . | . |
174+
| D | HET | 0/1 | 245 | . | . | . |
175+
+--------+-------+-----+-----+----+----+----+
176+
177+
>>> 1:3000002:C (n. 4)
178+
179+
<<< 1:3000002:C (n. 5)
180+
181+
# Variant
182+
+--------+---------+
183+
| KEY | VALUE |
184+
+--------+---------+
185+
| CHROM | 1 |
186+
| POS | 3000002 |
187+
| ID | . |
188+
| REF | C |
189+
| ALT | A |
190+
| QUAL | 59.2 |
191+
| FILTER | PASS |
192+
+--------+---------+
193+
194+
# INFO
195+
+-----+-----+-------+
196+
| KEY | IDX | VALUE |
197+
+-----+-----+-------+
198+
| AN | | 4 |
199+
| AC | | 2 |
200+
+-----+-----+-------+
201+
202+
# GENOTYPE TYPES
203+
+------+-------+-----+
204+
| Type | Count | % |
205+
+------+-------+-----+
206+
| HET | 2 | 100 |
207+
+------+-------+-----+
208+
209+
# GENOTYPES
210+
+--------+-------+-----+-----+
211+
| SAMPLE | GTYPE | GT | GQ |
212+
+--------+-------+-----+-----+
213+
| C | HET | 0/1 | 245 |
214+
| D | HET | 0/1 | 245 |
215+
+--------+-------+-----+-----+
216+
217+
>>> 1:3000002:C (n. 5)
218+

0 commit comments

Comments
 (0)