-
Notifications
You must be signed in to change notification settings - Fork 11
/
pypgatk_tests.py
288 lines (262 loc) · 14.1 KB
/
pypgatk_tests.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
import unittest
from click.testing import CliRunner
from pypgatk.pypgatk_cli import cli
class PypgatkRunnerTests(unittest.TestCase):
def test_peptide_class_group_fdr(self):
runner = CliRunner()
result = runner.invoke(cli,
['peptide-class-fdr',
'-in', 'testdata/20151020_QE3_UPLC8_DBJ_SA_HCT116_Rep2_46frac_10_consensus.idxml',
'-out',
'testdata/20151020_QE3_UPLC8_DBJ_SA_HCT116_Rep2_46frac_10_consensus_filter.idxml',
'--peptide-groups-prefix',
'"{non_canonical:[altorf,pseudo,ncRNA];mutations:[COSMIC,cbiomut];variants:[var_mut,var_rs]}"'])
self.assertEqual(result.exit_code, 0)
def test_peptide_classes_fdr(self):
runner = CliRunner()
result = runner.invoke(cli,
['peptide-class-fdr',
'-in', 'testdata/20151020_QE3_UPLC8_DBJ_SA_HCT116_Rep2_46frac_10_consensus.idxml',
'-out',
'testdata/20151020_QE3_UPLC8_DBJ_SA_HCT116_Rep2_46frac_10_consensus_filter.idxml',
'--peptide-classes-prefix', '"altorf,pseudo,ncRNA,COSMIC,cbiomut,var_mut,var_rs"'])
self.assertEqual(result.exit_code, 0)
def test_vcf_to_proteindb(self):
"""
Test the default behaviour of the vcf-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['vcf-to-proteindb', '--config_file', 'config/ensembl_config.yaml',
'--vcf', 'testdata/test.vcf',
'--input_fasta', 'testdata/test.fa',
'--gene_annotations_gtf', 'testdata/test.gtf',
'--var_prefix', 'ensvar',
'--af_field', 'MAF',
'--output_proteindb', 'testdata/proteindb_from_ENSEMBL_VCF.fa',
'--annotation_field_name', 'CSQ',
'--biotype_str', 'feature_type',
'--include_biotypes', 'mRNA,ncRNA'])
self.assertEqual(result.exit_code, 0)
def test_vcf_to_proteindb_notannotated(self):
"""
Test the default behaviour of the vcf-to-proteindb tool using not-annotated vcf
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['vcf-to-proteindb', '--config_file', 'config/ensembl_config.yaml',
'--vcf', 'testdata/test.vcf',
'--input_fasta', 'testdata/test.fa',
'--gene_annotations_gtf', 'testdata/test.gtf',
'--var_prefix', 'varsample',
'--output_proteindb', 'testdata/proteindb_from_custom_VCF.fa',
'--annotation_field_name', ""])
if result.exit_code != 0:
print(result)
self.assertEqual(result.exit_code, 0)
def test_vcf_gnomad_to_proteindb(self):
"""
Test the default behaviour of the vcf-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['vcf-to-proteindb', '--config_file', 'config/ensembl_config.yaml',
'--vcf', 'testdata/test_gnomad.vcf',
'--input_fasta', 'testdata/test_gencode.fa',
'--gene_annotations_gtf', 'testdata/test_gencode.gtf',
'--output_proteindb', 'testdata/proteindb_from_gnomad_VCF.fa',
'--af_field', 'controls_AF',
'--af_threshold', '0.001',
'--var_prefix', 'gnomvar',
'--annotation_field_name', 'vep', ])
self.assertEqual(result.exit_code, 0)
def test_dnaseq_to_proteindb(self):
"""
Test the default behaviour (translate CDSs) of the dnaseq-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['dnaseq-to-proteindb', '--config_file', 'config/ensembl_config.yaml',
'--input_fasta', 'testdata/test.fa',
'--output_proteindb', 'testdata/proteindb_from_CDSs_DNAseq.fa'])
self.assertEqual(result.exit_code, 0)
def test_dnaseq_ncrnas_to_proteindb(self):
"""
Test generation of proteinDB from short noncoding RNAs using dnaseq-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['dnaseq-to-proteindb', '--config_file', 'config/ensembl_config.yaml',
'--input_fasta', 'testdata/test.fa',
'--output_proteindb', 'testdata/proteindb_from_ncRNAs_DNAseq.fa',
'--var_prefix', 'ncRNA_',
'--include_biotypes',
'lncRNA,retained_intron,Mt_rRNA,Mt_tRNA,miRNA,misc_RNA,rRNA,ribozyme,sRNA,scRNA,scaRNA,snRNA,snoRNA,vaultRNA',
'--skip_including_all_cds'])
self.assertEqual(result.exit_code, 0)
def test_dnaseq_lncrnas_to_proteindb(self):
"""
Test generation of proteinDB from long noncoding RNAs using dnaseq-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['dnaseq-to-proteindb', '--config_file', 'config/ensembl_config.yaml',
'--input_fasta', 'testdata/test.fa',
'--output_proteindb', 'testdata/proteindb_from_lncRNAs_DNAseq.fa',
'--var_prefix', 'lncRNA_',
'--include_biotypes',
'lncRNA,retained_intron',
'--skip_including_all_cds'])
self.assertEqual(result.exit_code, 0)
def test_dnaseq_sncrnas_to_proteindb(self):
"""
Test generation of proteinDB from short noncoding RNAs using dnaseq-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['dnaseq-to-proteindb', '--config_file', 'config/ensembl_config.yaml',
'--input_fasta', 'testdata/test.fa',
'--output_proteindb', 'testdata/proteindb_from_sncRNAs_DNAseq.fa',
'--var_prefix', 'sncRNA_',
'--include_biotypes',
'Mt_rRNA,Mt_tRNA,miRNA,misc_RNA,rRNA,ribozyme,sRNA,scRNA,scaRNA,snRNA,snoRNA,vaultRNA',
'--skip_including_all_cds'])
self.assertEqual(result.exit_code, 0)
def test_dnaseq_pseudogenes_to_proteindb(self):
"""
Test generation of proteinDB from pseudogenes using dnaseq-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['dnaseq-to-proteindb', '--config_file', 'config/ensembl_config.yaml',
'--input_fasta', 'testdata/test.fa',
'--output_proteindb', 'testdata/proteindb_from_pseudogenes_DNAseq.fa',
'--var_prefix', 'pseudo_',
'--include_biotypes',
'disrupted_domain, IGC_pseudogene, IGJ_pseudogene, IG_pseudogene, IGV_pseudogene, processed_pseudogene, transcribed_processed_pseudogene, transcribed_unitary_pseudogene, transcribed_unprocessed_pseudogene, translated_processed_pseudogene, TRJ_pseudogene, unprocessed_pseudogene',
'--skip_including_all_cds'])
self.assertEqual(result.exit_code, 0)
def test_dnaseq_altorfs_to_proteindb(self):
"""
Test generation proteinDB from altORFs using dnaseq-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['dnaseq-to-proteindb', '--config_file', 'config/ensembl_config.yaml',
'--input_fasta', 'testdata/test.fa',
'--output_proteindb', 'testdata/proteindb_from_altORFs_DNAseq.fa',
'--var_prefix', 'altorf_',
'--include_biotypes', 'altORFs', '--skip_including_all_cds'])
self.assertEqual(result.exit_code, 0)
def test_cbioportal_to_proteindb(self):
"""
Test generation proteinDB from cBioportal mutations using cbioportal-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['cbioportal-to-proteindb', '--config_file', 'config/cbioportal_config.yaml',
'--input_mutation', 'testdata/test_cbioportal_data_mutations_mskcc.txt',
'--input_cds', 'testdata/test_cbioportal_genes.fa',
'--output_db', 'testdata/test_cbioportal_data_mutations_mskcc_proteindb.fa',
'--clinical_sample_file', 'testdata/test_cbioportal_data_clinical_sample.txt',
'--filter_column', 'CANCER_TYPE'
'--split_by_filter_column', '--accepted_values', 'all'])
self.assertEqual(result.exit_code, 0)
def test_cosmic_to_proteindb(self):
"""
Test generation proteinDB from altORFs using dnaseq-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['cosmic-to-proteindb', '--config_file', 'config/cosmic_config.yaml',
'--input_mutation', 'testdata/test_cosmic_mutations.tsv',
'--input_genes', 'testdata/test_cosmic_genes.fa',
'--output_db', 'testdata/test_cosmic_mutations_proteindb.fa',
'--filter_column', 'Primary site',
'--split_by_filter_column', '--accepted_values', 'all'])
if result.exit_code != 0:
print(result.exception)
self.assertEqual(result.exit_code, 0)
def test_generate_decoy_database(self):
"""
Test generation proteinDB from altORFs using dnaseq-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['generate-decoy', '--config_file', 'config/protein_decoy.yaml',
'-in', 'testdata/test_db.fa', '-out', 'testdata/output_decoy.fa', '--method',
'protein-reverse'])
self.assertEqual(result.exit_code, 0)
def test_generate_decoy_database_noconfig(self):
"""
Test generation proteinDB from altORFs using dnaseq-to-proteindb tool
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['generate-decoy', '-in', 'testdata/test_db.fa', '-out', 'testdata/output_decoy.fa',
'--method',
'protein-reverse'])
self.assertEqual(result.exit_code, 0)
def test_download_ensembl_data(self):
"""
Test downloading ensembl data for species with taxonomy identifer = 9103
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['ensembl-downloader', '--config_file', 'config/ensembl_downloader_config.yaml',
'--skip_dna',
'--taxonomy', '9103', '--output_directory', 'testdata'])
self.assertEqual(result.exit_code, 0)
def test_download_ensembl_data_37(self):
"""
Test downloading ensembl data for species with taxonomy identifier = 9606
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['ensembl-downloader', '--taxonomy', '9103', '--output_directory', 'testdata',
'--grch37'])
self.assertEqual(result.exit_code, 0)
def test_download_cbioportal_data(self):
"""
Test downloading cbioportal data for study id: paac_jhu_2014
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['cbioportal-downloader', '--config_file', 'config/cbioportal_config.yaml',
'--download_study', 'paac_jhu_2014', '--output_directory', 'testdata'])
self.assertEqual(result.exit_code, 0)
def test_download_cbioportal_data_noconfig(self):
"""
Test downloading cbioportal data for study id: paac_jhu_2014
:return:
"""
runner = CliRunner()
result = runner.invoke(cli,
['cbioportal-downloader', '--download_study', 'paac_jhu_2014', '--output_directory',
'testdata'])
self.assertEqual(result.exit_code, 0)
def test_check_ensembl_database(self):
runner = CliRunner()
result = runner.invoke(cli,
['ensembl-check', '--config_file', 'config/ensembl_config.yaml',
'--input_fasta', 'testdata/proteindb_from_ENSEMBL_VCF.fa', '--output',
'testdata/proteindb_from_ENSEMBL_VCF-clean.fa', '--add_stop_codons', '--num_aa', '6'])
self.assertEqual(result.exit_code, 0)
if __name__ == '__main__':
unittest.main()