File tree Expand file tree Collapse file tree 1 file changed +77
-0
lines changed
Expand file tree Collapse file tree 1 file changed +77
-0
lines changed Original file line number Diff line number Diff line change 1+ version 1.0
2+
3+ workflow ExtractCnvsFromVcf {
4+ input {
5+ File vcf # Input VCF
6+ File vcf_idx # Input VCF index file
7+
8+ String gatk_docker # Docker image path for GATK
9+ }
10+
11+ call ExtractCnvs {
12+ input :
13+ vcf = vcf ,
14+ vcf_idx = vcf_idx
15+ }
16+
17+ output {
18+ File extracted_vcf = ExtractCnvs .extracted_vcf
19+ File extracted_vcf_idx = ExtractCnvs .extracted_vcf_idx
20+ }
21+ }
22+
23+ task ExtractCnvs {
24+ input {
25+ File vcf
26+ File vcf_idx
27+ String gatk_docker
28+ }
29+
30+ command <<<
31+ set -eu -o pipefail
32+
33+ python << CODE
34+ import pysam
35+ import copy
36+
37+ fin = pysam.VariantFile("~{vcf }")
38+ fout = pysam.VariantFile("extracted.vcf", 'w', header=fin.header)
39+
40+ for rec in fin:
41+ if rec.info.get("SVTYPE") == "CNV":
42+ rec_del = copy.copy(rec)
43+ rec_del.id = rec.id + "_DEL"
44+ rec_del.info["SVTYPE"] = "DEL"
45+ rec_del.alts = ("<DEL>",)
46+
47+ rec_dup = copy.copy(rec)
48+ rec_dup.id = rec.id + "_DUP"
49+ rec_dup.info["SVTYPE"] = "DUP"
50+ rec_dup.alts = ("<DUP>",)
51+
52+ fout.write(rec_del)
53+ fout.write(rec_dup)
54+ else:
55+ fout.write(rec)
56+
57+ fin.close()
58+ fout.close()
59+ CODE
60+
61+ bgzip extracted.vcf
62+
63+ tabix extracted.vcf.gz
64+ >>>
65+
66+ output {
67+ File extracted_vcf = "extracted.vcf.gz"
68+ File extracted_vcf_idx = "extracted.vcf.gz.tbi"
69+ }
70+
71+ runtime {
72+ cpu : 1
73+ memory : "4 GiB"
74+ disks : "local-disk 4 HDD"
75+ docker : gatk_docker
76+ }
77+ }
You can’t perform that action at this time.
0 commit comments