-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathneoag-tools.py
174 lines (157 loc) · 7.54 KB
/
neoag-tools.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env/python3
# author: Junko Tsuji
import os
import sys
import logging
import argparse
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/")
import phase.phase
import epitope.epitope
def build_parser():
parser = argparse.ArgumentParser(description='Run neoantigen generation tools')
# common parameters
base_parser = argparse.ArgumentParser(add_help=False)
base_parser.add_argument('-r', '--ref-fasta',
type=str,
action='store',
help='Reference fasta, required')
base_parser.add_argument('-m', '--input-maf',
type=str,
action='store',
help='Input MAF, required')
base_parser.add_argument('-t', '--tumor-name',
type=str,
action='store',
help='Tumor sample name (it has to match with "Tumor_Sample_Barcode" in MAF), required')
base_parser.add_argument('-n', '--normal-name',
type=str,
action='store',
help='Normal sample name')
# tool specific parser
subparsers = parser.add_subparsers(title='neoag-tools',
description='Choose a tool to run',
help='')
phasing = subparsers.add_parser('phase',
help='Generate phased somatic (and germline) mutations',
parents=[base_parser])
# change 'optional arguments' to 'input arguments'
phasing._action_groups[1].title = 'input arguments'
phasing.add_argument('--tumor-bam',
type=str,
action='store',
help='Tumor BAM, required')
phasing.add_argument('--normal-bam',
type=str,
action='store',
help='Normal BAM, optional')
phasing.add_argument('--tumor-vcf',
type=str,
action='store',
help='Somatic variant VCF, optional')
phasing.add_argument('--normal-vcf',
type=str,
action='store',
help='Germline variant VCF, optional')
phasing.add_argument('--phylogic-ccfs',
type=str,
action='store',
help='Clustered somatic mutations \'mut_ccfs\' from PhylogicNDT, optional')
phasing.add_argument('--phylogic-tree',
type=str,
action='store',
help='Clonal tree information \'build_tree_posteriors\' from PhylogicNDT, optional')
phasing.add_argument('--phylogic-index',
type=int,
action='store',
default=1,
help='N-th tree in PhylogicNDT for clonal structure (default=%(default)s)')
phasing.add_argument('--vaf-skew-pval',
type=float,
action='store',
default=0.05,
help='P-values to evaluate if a pair of mutation VAFs is skewed (default=%(default)s)')
phasing.add_argument('--max-mnp-size',
type=int,
action='store',
default=10,
help='Maximum length of phased somatic mutations to chain as MNP/ONP (default=%(default)s)')
phasing.add_argument('--max-phase-radius',
type=int,
action='store',
default=120,
help='Maximum radius from somatic mutations to incorporate phased germline mutations (default=%(default)s)')
phasing.add_argument('--min-coverage',
type=int,
action='store',
default=10,
help='Minimum coverage to investigate phasing (default=%(default)s)')
phasing.add_argument('--min-phased-altc',
type=int,
action='store',
default=3,
help='Minimum alt counts of phased mutation (default=%(default)s)')
phasing.add_argument('--min-base-quality',
type=int,
action='store',
default=5,
help='Minimum base quality to investigate phasing (default=%(default)s)')
phasing.add_argument('--min-map-quality',
type=int,
action='store',
default=5,
help='Minimum mapping quality to investigate phasing (default=%(default)s)')
phasing.set_defaults(func=phase.phase.run)
antigen = subparsers.add_parser('epitope',
help='Construct neoantigens with supplied mutations',
parents=[base_parser])
# change 'optional arguments' to 'input arguments'
antigen._action_groups[1].title = 'input arguments'
antigen.add_argument('--gtf',
type=str,
action='store',
help='GENCODE gene annotation GTF, required')
antigen.add_argument('--germline-maf',
type=str,
action='store',
help='Phased germline MAF, optional')
antigen.add_argument('--gene-expr',
type=str,
action='store',
help='RSEM gene expression matrix, optional')
antigen.add_argument('--codon-table',
type=str,
action='store',
help='Codon table to use, see "epitope/seq.py" for details (default="standard genetic code")')
antigen.add_argument('--peptide-length',
type=str,
action='store',
default='8,9,10,11',
help='Comma-separated list of peptide lengths. Lengths 8, 9, 10, and 11 are supported (default=%(default)s)')
antigen.add_argument('--flank-peplen',
type=int,
action='store',
default=30,
help='Upstream and downstream peptide lengths to report (default=%(default)s)')
antigen.add_argument('--ignore-clones',
action='store_true',
help='Ignore mutation clonal structure during peptide translation (default=off)')
antigen.add_argument('--ignore-phasing',
action='store_true',
help='Ignore phasing information during peptide translation (default=off)')
antigen.set_defaults(func=epitope.epitope.run)
if len(sys.argv) < 2:
parser.print_help(sys.stderr)
sys.exit()
print_help = '-h' in sys.argv or '--help' in sys.argv
if 'phase' in sys.argv:
if len(sys.argv) < 3 or print_help:
phasing.print_help(sys.stderr)
sys.exit()
if 'epitope' in sys.argv:
if len(sys.argv) < 3 or print_help:
antigen.print_help(sys.stderr)
sys.exit()
return parser.parse_args()
if __name__ == '__main__':
args = build_parser()
args.func(args)