forked from oncokb/oncokb-annotator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CnaAnnotator.py
72 lines (60 loc) · 2.32 KB
/
CnaAnnotator.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
#!/usr/bin/python
import sys
import getopt
from AnnotatorCore import *
def main(argv):
baseurl = 'http://oncokb.org'
inputcnafile = ''
inputclinicalfile = ''
outputcnafile = ''
previousresultfile = ''
defaultcancertype = 'cancer'
try:
opts, args = getopt.getopt(argv, "hi:o:p:c:s:d:t:u:")
except getopt.GetoptError:
print 'for help: python CnaAnnotator.py -h'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'CnaAnnotator.py -i <input cNA file> -o <output MAF file> [-p previous results] [-c <input clinical file>] [-s sample list filter] [-t <default tumor type>] [-u base-url]'
print ' Input CNA file should follow the GISTIC output (https://cbioportal.readthedocs.io/en/latest/File-Formats.html#discrete-copy-number-data)'
print ' Essential clinical columns:'
print ' SAMPLE_ID: sample ID'
print ' Cancer type will be assigned based on the following priority:'
print ' 1) ONCOTREE_CODE in clinical data file'
print ' 2) ONCOTREE_CODE exist in MAF'
print ' 3) default tumor type (-t)'
print ' Default OncoKB base url is http://oncokb.org'
sys.exit()
elif opt in ("-i"):
inputcnafile = arg
elif opt in ("-o"):
outputcnafile = arg
elif opt in ("-p"):
previousresultfile = arg
elif opt in ("-c"):
inputclinicalfile = arg
elif opt in ("-s"):
setsampleidsfileterfile(arg)
elif opt in ("-t"):
defaultcancertype = arg
elif opt in ("-u"):
setoncokbbaseurl(arg)
if inputcnafile == '' or outputcnafile=='':
print 'for help: python MafAnnotator.py -h'
sys.exit(2)
cancertypemap = {}
if inputclinicalfile != '':
readCancerTypes(inputclinicalfile, cancertypemap)
print 'annotating '+inputcnafile+"..."
processcnagisticdata(inputcnafile, outputcnafile, previousresultfile, defaultcancertype, cancertypemap, False)
print 'done!'
if __name__ == "__main__":
# argv = [
# '-i', 'data/example_cna.txt',
# '-o', 'data/example_cna.oncokb.txt',
# '-c', 'data/example_clinical.txt',
# ]
# main(argv)
# print sys.argv[1:]
main(sys.argv[1:])