-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_Manta.py
111 lines (85 loc) · 2.74 KB
/
run_Manta.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import sys
import re
import os
filteredBam = "veritas_wgs.filter.bam"
ref = "hg19.fasta"
mantaDir = "manta"
threads = 2
mem = 5
command = "mkdir " + mantaDir
os.system(command)
command = "samtools faidx "+ref
os.system(command)
command = "/opt/manta-1.0.0.release_src/install/bin/configManta.py --bam "+filteredBam+" --referenceFasta "+ref+" --runDir " + mantaDir
os.system(command)
#you might have to re-run this command for WGS data
#not sure how starting from an intermediate step affects results...
command = mantaDir+"/runWorkflow.py -m local -j " + str(threads) + " -g " + str(mem)
os.system(command)
gzVCF = mantaDir + "/results/variants/candidateSmallIndels.vcf.gz"
command = "gunzip " + gzVCF
os.system(command)
gzVCF = mantaDir + "/results/variants/candidateSV.vcf.gz"
command = "gunzip " + gzVCF
os.system(command)
gzVCF = mantaDir + "/results/variants/diploidSV.vcf.gz"
command = "gunzip " + gzVCF
os.system(command)
#create deletion BED
#if you get an error after this point, you'll want to comment out earlier commands
mantraVCF = re.sub(".gz$","",gzVCF)
deletionBed = "Manta_DEL.bed"
filterOutHandle = open(deletionBed, 'w')
inHandle = open(mantraVCF)
line = inHandle.readline()
totalReads = ""
while line:
line = re.sub("\n","",line)
line = re.sub("\r","",line)
lineInfo = line.split("\t")
commentResult = re.search("^#", line)
if not commentResult:
chr = lineInfo[0]
start = lineInfo[1]
varID = lineInfo[2]
type = lineInfo[4]
varText = lineInfo[7]
genoLeg = lineInfo[8]
genoText = lineInfo[9]
if type == "<DEL>":
endResult = re.search("END=(\d+);", varText)
stop = endResult.group(1)
SR = 0
PR = 0
genoLegInfo = genoLeg.split(":")
genoTextInfo = genoText.split(":")
for i in xrange(0,len(genoLegInfo)):
id = genoLegInfo[i]
value = genoTextInfo[i]
srResult = re.search("SR",id)
prResult = re.search("PR",id)
#actually, all chromosomes assumed to be diploid
chrPloidy = 2
varIndex = chrPloidy - 1
if srResult:
covVal = value.split(",")
if(len(covVal) == chrPloidy):
SR = int(covVal[varIndex])
else:
print "Need to revise SR code for " + line
print id
print value
sys.exit()
if prResult:
covVal = value.split(",")
if(len(covVal) == chrPloidy):
PR = int(covVal[varIndex])
else:
print "Need to revise PR code for " + line
print id
print value
sys.exit()
supportingReads = SR + PR
text = chr + "\t" + str(start) + "\t" + str(stop) + "\t" + varID + "\t" + str(supportingReads) + "\n"
filterOutHandle.write(text)
line = inHandle.readline()