Repository navigation
Expand file tree
/
Copy pathgemini_main.py
More file actions
executable file
·1130 lines (1056 loc) · 49 KB
/
Copy pathgemini_main.py
File metadata and controls
executable file
·1130 lines (1056 loc) · 49 KB
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
import os.path
import sys
import argparse
import gemini.version
def examples(parser, args):
print
print "[load] - load a VCF file into a gemini database:"
print " gemini load -v my.vcf my.db"
print " gemini load -v my.vcf -t snpEff my.db"
print " gemini load -v my.vcf -t VEP my.db"
print
print "[stats] - report basic statistics about your variants:"
print " gemini stats --tstv my.db"
print " gemini stats --tstv-coding my.db"
print " gemini stats --sfs my.db"
print " gemini stats --snp-counts my.db"
print
print "[query] - explore the database with ad hoc queries:"
print " gemini query -q \"select * from variants where is_lof = 1 and aaf <= 0.01\" my.db"
print " gemini query -q \"select chrom, pos, gt_bases.NA12878 from variants\" my.db"
print " gemini query -q \"select chrom, pos, in_omim, clin_sigs from variants\" my.db"
print
print "[dump] - convenient \"data dumps\":"
print " gemini dump --variants my.db"
print " gemini dump --genotypes my.db"
print " gemin
8000
i dump --samples my.db"
print
print "[region] - access variants in specific genomic regions:"
print " gemini region --reg chr1:100-200 my.db"
print " gemini region --gene TP53 my.db"
print
print "[tools] - there are also many specific tools available"
print " 1. Find compound heterozygotes."
print " gemini comp_hets my.db"
print
exit()
def main():
#########################################
# create the top-level parser
#########################################
parser = argparse.ArgumentParser(prog='gemini', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-v", "--version", help="Installed gemini version",
action="version",
version="%(prog)s " + str(gemini.version.__version__))
parser.add_argument('--annotation-dir', dest='annotation_dir',
help='Path to the annotation database.\n'
'This argument is optional and if given will take precedence over the default location stored in the gemini config file.')
subparsers = parser.add_subparsers(title='[sub-commands]', dest='command')
#########################################
# $ gemini examples
#########################################
parser_examples = subparsers.add_parser('examples',
help='show usage examples')
parser_examples.set_defaults(func=examples)
#########################################
# $ gemini load
#########################################
parser_load = subparsers.add_parser('load',
help='load a VCF file in gemini database')
parser_load.add_argument('db', metavar='db',
help='The name of the database to be created.')
parser_load.add_argument('-v', dest='vcf',
help='The VCF file to be loaded.')
parser_load.add_argument('-t', dest='anno_type',
default=None, choices=["snpEff", "VEP"],
help="The annotations to be used with the input vcf.")
parser_load.add_argument('-p', dest='ped_file',
help='Sample information file in PED+ format.',
default=None)
parser_load.add_argument('--skip-gerp-bp',
dest='skip_gerp_bp',
action='store_true',
help='Do not load GERP scores at base pair resolution. Loaded by default.',
default=False)
parser_load.add_argument('--skip-cadd',
dest='skip_cadd',
action='store_true',
help='Do not load CADD scores. Loaded by default',
default=False)
parser_load.add_argument('--skip-gene-tables',
dest='skip_gene_tables',
action='store_true',
help='Do not load gene tables. Loaded by default.',
default=False)
parser_load.add_argument('--skip-info-string',
dest='skip_info_string',
action='store_true',
help='Do not load INFO string from VCF file to reduce DB size. Loaded by default',
default=False)
parser_load.add_argument('--no-load-genotypes',
dest='no_load_genotypes',
action='store_true',
help='Genotypes exist in the file, but should not be stored.',
default=False)
parser_load.add_argument('--no-genotypes',
dest='no_genotypes',
action='store_true',
help='There are no genotypes in the file (e.g. some 1000G VCFs)',
default=False)
parser_load.add_argument('--cores', dest='cores',
default=1,
type=int,
help="Number of cores to use to load in parallel.")
parser_load.add_argument('--dbtype', dest='dbtype',
default="sqlite",
help="The type of database to use. Def=sqlite.")
parser_load.add_argument('--scheduler', dest='scheduler', default=None,
choices=["lsf", "sge", "slurm", "torque"],
action=IPythonAction,
help='Cluster scheduler to use.')
parser_load.add_argument('--queue', dest='queue',
default=None, help='Cluster queue to use.')
parser_load.add_argument('--passonly',
dest='passonly',
default=False,
action='store_true',
help="Keep only variants that pass all filters.")
parser_load.add_argument('--test-mode',
dest='test_mode',
action='store_true',
help='Load in test mode (faster)',
default=False)
def load_fn(parser, args):
import gemini_load
gemini_load.load(parser, args)
parser_load.set_defaults(func=load_fn)
#########################################
# $ gemini amend
#########################################
parser_amend = subparsers.add_parser('amend',
help="Amend an already loaded GEMINI database.")
parser_amend.add_argument('db',
metavar='db',
help='The name of the database to be amended.')
parser_amend.add_argument('--sample',
metavar='sample',
default=None,
help='New sample information file to load')
def amend_fn(parser, args):
import gemini_amend
gemini_amend.amend(parser, args)
parser_amend.set_defaults(func=amend_fn)
#########################################
# $ gemini load_chunk
#########################################
parser_loadchunk = subparsers.add_parser('load_chunk',
help='load a VCF file in gemini database')
parser_loadchunk.add_argument('db',
metavar='db',
help='The name of the database to be created.')
parser_loadchunk.add_argument('-v',
dest='vcf',
help='The VCF file to be loaded.')
parser_loadchunk.add_argument('-t',
dest='anno_type',
default=None,
metavar='STRING',
help="The annotations to be used with the input vcf. Options are:\n"
" snpEff - Annotations as reported by snpEff.\n"
" VEP - Annotations as reported by VEP.\n"
)
parser_loadchunk.add_argument('-o',
dest='offset',
help='The starting number for the variant_ids',
default=None)
parser_loadchunk.add_argument('--dbtype', dest='dbtype',
default="sqlite",
help="The type of database to use. Def=sqlite.")
parser_loadchunk.add_argument('-p',
dest='ped_file',
help='Sample information file in PED+ format.',
default=None)
parser_loadchunk.add_argument('--no-load-genotypes',
dest='no_load_genotypes',
action='store_true',
help='Genotypes exist in the file, but should not be stored.',
default=False)
parser_loadchunk.add_argument('--no-genotypes',
dest='no_genotypes',
action='store_true',
help='There are no genotypes in the file (e.g. some 1000G VCFs)',
default=False)
parser_loadchunk.add_argument('--skip-gerp-bp',
dest='skip_gerp_bp',
action='store_true',
help='Do not load GERP scores at base pair resolution. Loaded by default.',
default=False)
parser_loadchunk.add_argument('--skip-cadd',
dest='skip_cadd',
action='store_true',
help='Do not load CADD scores. Loaded by default',
default=False)
parser_loadchunk.add_argument('--skip-gene-tables',
dest='skip_gene_tables',
action='store_true',
help='Do not load gene tables. Loaded by default.',
default=False)
parser_loadchunk.add_argument('--skip-info-string',
dest='skip_info_string',
action='store_true',
help='Do not load INFO string from VCF file to reduce DB size. Loaded by default',
default=False)
parser_loadchunk.add_argument('--passonly',
dest='passonly',
default=False,
action='store_true',
help="Keep only variants that pass all filters.")
parser_loadchunk.add_argument('--test-mode',
dest='test_mode',
action='store_true',
help='Load in test mode (faster)',
default=False)
def loadchunk_fn(parser, args):
import gemini_load_chunk
gemini_load_chunk.load(parser, args)
parser_loadchunk.set_defaults(func=loadchunk_fn)
#########################################
# $ gemini merge_chunks
#########################################
parser_mergechunks = subparsers.add_parser('merge_chunks',
help='combine intermediate db files into the final gemini ')
parser_mergechunks.add_argument('--db',
dest='db',
help='The name of the final database to be loaded.')
parser_mergechunks.add_argument('--chunkdb',
nargs='*',
dest='chunkdbs',
action='append')
def mergechunk_fn(parser, args):
import gemini_merge_chunks
gemini_merge_chunks.merge_chunks(parser, args)
parser_mergechunks.set_defaults(func=mergechunk_fn)
#########################################
# $ gemini query
#########################################
parser_query = subparsers.add_parser('query',
help='issue ad hoc SQL queries to the DB')
parser_query.add_argument('db',
metavar='db',
help='The name of the database to be queried.')
parser_query.add_argument('--dbtype', dest='dbtype',
default="sqlite",
help="The type of database to use. Def=sqlite.")
parser_query.add_argument('-q',
dest='query',
metavar='QUERY_STR',
help='The query to be issued to the database')
parser_query.add_argument('--gt-filter',
dest='gt_filter',
metavar='STRING',
help='Restrictions to apply to genotype values')
parser_query.add_argument('--show-samples',
dest='show_variant_samples',
action='store_true',
default=False,
help=('Add a column of all sample names with a variant to each '
'variant.'))
parser_query.add_argument('--show-families',
dest='show_families',
action='store_true',
default=False,
help=('Add a column listing all of the families '
'with a variant to each variant.'))
parser_query.add_argument('--family-wise',
dest='family_wise',
default=False,
action='store_true',
help=('Perform the sample-filter on a family-wise '
'basis.'))
parser_query.add_argument('--min-kindreds',
dest='min_kindreds',
default=1,
type=int,
help=('Minimum number of families for a variant passing '
'a family-wise filter to be in.'))
parser_query.add_argument('--sample-delim',
dest='sample_delim',
metavar='STRING',
help='The delimiter to be used with the --show-samples option.',
default=',')
parser_query.add_argument('--header',
dest='use_header',
action='store_true',
help='Add a header of column names to the output.',
default=False)
parser_query.add_argument('--sample-filter',
dest='sample_filter',
help='SQL filter to use to filter the sample table',
default=None)
parser_query.add_argument('--in',
dest='in_subject',
nargs='*',
help=('A variant must be in either all, none or any '
'samples passing the --sample-query filter.'),
choices=['all', 'none', 'any', 'only'],
default=['any'])
parser_query.add_argument('--format',
dest='format',
default='default',
help='Format of output (JSON, TPED or default)')
parser_query.add_argument('--region',
dest='region',
default=None,
help=('Restrict query to this region, '
'e.g. chr1:10-20.'))
parser_query.add_argument('--carrier-summary-by-phenotype',
dest='carrier_summary',
default=None,
help=('Output columns of counts of carriers and '
'non-carriers stratified by the given '
'sample phenotype column'))
parser_query.add_argument('--dgidb',
dest='dgidb',
action='store_true',
help='Request drug-gene interaction info from DGIdb.',
default=False)
def query_fn(parser, args):
import gemini_query
gemini_query.query(parser, args)
parser_query.set_defaults(func=query_fn)
#########################################
# $ gemini dump
#########################################
parser_dump = subparsers.add_parser('dump',
help='shortcuts for extracting data from the DB')
parser_dump.add_argument('db',
metavar='db',
help='The name of the database to be queried.')
parser_dump.add_argument('--variants',
dest='variants',
action='store_true',
help='Report all rows/columns from the variants table.',
default=False)
parser_dump.add_argument('--genotypes',
dest='genotypes',
action='store_true',
help='Report all rows/columns from the variants table \nwith one line per sample/genotype.',
default=False)
parser_dump.add_argument('--samples',
dest='samples',
action='store_true',
help='Report all rows/columns from the samples table.',
default=False)
parser_dump.add_argument('--header',
dest='use_header',
action='store_true',
help='Add a header of column names to the output.',
default=False)
parser_dump.add_argument('--sep',
dest='separator',
metavar='STRING',
help='Output column separator',
default="\t")
parser_dump.add_argument('--tfam',
dest='tfam',
action='store_true',
default=False,
help='Output sample information to TFAM format.')
def dump_fn(parser, args):
import gemini_dump
gemini_dump.dump(parser, args)
parser_dump.set_defaults(func=dump_fn)
#########################################
# $ gemini region
#########################################
parser_region = subparsers.add_parser('region',
help='extract variants from specific genomic loci')
parser_region.add_argument('db',
metavar='db',
help='The name of the database to be queried.')
parser_region.add_argument('--reg',
dest='region',
metavar='STRING',
help='Specify a chromosomal region chr:start-end')
parser_region.add_argument('--gene',
dest='gene',
metavar='STRING',
help='Specify a gene of interest')
parser_region.add_argument('--header',
dest='use_header',
action='store_true',
help='Add a header of column names to the output.',
default=False)
parser_region.add_argument('--columns',
dest='columns',
metavar='STRING',
help='A list of columns that you would like returned. Def. = "*"',
)
parser_region.add_argument('--filter',
dest='filter',
metavar='STRING',
help='Restrictions to apply to variants (SQL syntax)')
parser_region.add_argument('--show-samples',
dest='show_variant_samples',
action='store_true',
default=False,
help=('Add a column of all sample names with a variant to each '
'variant.'))
parser_region.add_argument('--format',
dest='format',
default='default',
help='Format of output (JSON, TPED or default)')
def region_fn(parser, args):
import gemini_region
gemini_region.region(parser, args)
parser_region.set_defaults(func=region_fn)
#########################################
# $ gemini stats
#########################################
parser_stats = subparsers.add_parser('stats',
help='compute useful variant stastics')
parser_stats.add_argument('db',
metavar='db',
help='The name of the database to be queried.')
parser_stats.add_argument('--tstv',
dest='tstv',
action='store_true',
help='Report the overall ts/tv ratio.',
default=False)
parser_stats.add_argument('--tstv-coding',
dest='tstv_coding',
action='store_true',
help='Report the ts/tv ratio in coding regions.',
default=False)
parser_stats.add_argument('--tstv-noncoding',
dest='tstv_noncoding',
action='store_true',
help='Report the ts/tv ratio in non-coding regions.',
default=False)
parser_stats.add_argument('--snp-counts',
dest='snp_counts',
action='store_true',
help='Report the count of each type of SNP (A->G, G->T, etc.).',
default=False)
parser_stats.add_argument('--sfs',
dest='sfs',
action='store_true',
help='Report the site frequency spectrum of the variants.',
default=False)
parser_stats.add_argument('--mds',
dest='mds',
action='store_true',
help='Report the pairwise genetic distance between the samples.',
default=False)
parser_stats.add_argument('--vars-by-sample',
dest='variants_by_sample',
action='store_true',
help='Report the number of variants observed in each sample.',
default=False)
parser_stats.add_argument('--gts-by-sample',
dest='genotypes_by_sample',
action='store_true',
help='Report the count of each genotype class obs. per sample.',
default=False)
parser_stats.add_argument('--summarize',
dest='query',
metavar='QUERY_STR',
default=None,
help='The query to be issued to the database to summarize')
parser_stats.add_argument('--gt-filter',
dest='gt_filter',
metavar='STRING',
help='Restrictions to apply to genotype values')
def stats_fn(parser, args):
import gemini_stats
gemini_stats.stats(parser, args)
parser_stats.set_defaults(func=stats_fn)
#########################################
# gemini annotate
#########################################
parser_get = subparsers.add_parser('annotate',
help='Add new columns for custom annotations')
parser_get.add_argument('db',
metavar='db',
help='The name of the database to be updated.')
parser_get.add_argument('-f',
dest='anno_file',
help='The TABIX\'ed BED file containing the annotations')
parser_get.add_argument('-c',
dest='col_names',
help='The name(s) of the column(s) to be added to the variant table.')
parser_get.add_argument('-a',
dest='anno_type',
help='How should the annotation file be used? (def. extract)',
default="extract",
choices=['boolean', 'count', 'extract'])
parser_get.add_argument('-e',
dest='col_extracts',
help='Column(s) to extract information from for list annotations.')
parser_get.add_argument('-t',
dest='col_types',
help='What data type(s) should be used to represent the new values '
'in the database? '
'Any of {integer, float, text}')
parser_get.add_argument('-o',
dest='col_operations',
help='Operation(s) to apply to the extract column values '
'in the event that a variant overlaps multiple annotations '
'in your annotation file (-f).'
'Any of {mean, median, min, max, mode, list, uniq_list, first, last}')
def annotate_fn(parser, args):
import gemini_annotate
gemini_annotate.annotate(parser, args)
parser_get.set_defaults(func=annotate_fn)
#########################################
# gemini windower
#########################################
parser_get = subparsers.add_parser('windower',
help='Compute statistics across genome \"windows\"')
parser_get.add_argument('db',
metavar='db',
help='The name of the database to be updated.')
parser_get.add_argument('-w',
dest='window_size',
type=int,
default=1000000,
help='The name of the column to be added to the variant table.')
parser_get.add_argument('-s',
dest='step_size',
type=int,
default=0,
help="The step size for the windows in bp.\n")
parser_get.add_argument('-t',
dest='analysis_type',
help='The type of windowed analysis requested.',
choices=['nucl_div', 'hwe'],
default='hwe')
parser_get.add_argument('-o',
dest='op_type',
help='The operation that should be applied to the -t values.',
choices=['mean', 'median', 'min', 'max', 'collapse'],
default='mean')
def windower_fn(parser, args):
import gemini_windower
gemini_windower.windower(parser, args)
parser_get.set_defaults(func=windower_fn)
#########################################
# gemini db_info
#########################################
parser_get = subparsers.add_parser('db_info',
help='Get the names and types of cols. database tables')
parser_get.add_argument('db',
metavar='db',
help='The name of the database to be updated.')
def dbinfo_fn(parser, args):
import gemini_dbinfo
gemini_dbinfo.db_info(parser, args)
parser_get.set_defaults(func=dbinfo_fn)
#########################################
# $ gemini comp_hets
#########################################
parser_comp_hets = subparsers.add_parser('comp_hets',
help='Identify compound heterozygotes')
parser_comp_hets.add_argument('db',
metavar='db',
help='The name of the database to be created.')
parser_comp_hets.add_argument('--columns',
dest='columns',
metavar='STRING',
help='A list of columns that you would like returned. Def. = "*"',
)
parser_comp_hets.add_argument('--filter',
dest='filter',
metavar='STRING',
help='Restrictions to apply to variants (SQL syntax)')
parser_comp_hets.add_argument('--only-affected',
dest='only_affected',
action='store_true',
help='Report solely those compund heterozygotes impacted a sample \
labeled as affected.',
default=False)
parser_comp_hets.add_argument('--ignore-phasing',
dest='ignore_phasing',
action='store_true',
help='Ignore phasing when screening for compound hets. \
Candidates are inherently _putative_.',
default=False)
def comp_hets_fn(parser, args):
import tool_compound_hets
tool_compound_hets.run(parser, args)
parser_comp_hets.set_defaults(func=comp_hets_fn)
#########################################
# $ gemini pathways
#########################################
parser_pathway = subparsers.add_parser('pathways',
help='Map genes and variants to KEGG pathways')
parser_pathway.add_argument('db',
metavar='db',
help='The name of the database to be queried')
parser_pathway.add_argument('-v',
dest='version',
default='68',
metavar='STRING',
help="Version of ensembl genes to use. "
"Supported versions: 66 to 71\n"
)
parser_pathway.add_argument('--lof',
dest='lof',
action='store_true',
help='Report pathways for indivs/genes/sites with LoF variants',
default=False)
def pathway_fn(parser, args):
import tool_pathways
tool_pathways.pathways(parser, args)
parser_pathway.set_defaults(func=pathway_fn)
#########################################
# $ gemini lof_sieve
#########################################
parser_lof_sieve = subparsers.add_parser('lof_sieve',
help='Prioritize LoF mutations')
parser_lof_sieve.add_argument('db',
metavar='db',
help='The name of the database to be queried')
def lof_sieve_fn(parser, args):
import tool_lof_sieve
tool_lof_sieve.lof_sieve(parser, args)
parser_lof_sieve.set_defaults(func=lof_sieve_fn)
#########################################
# $ gemini burden
#########################################
burden_help = ("Gene-level genetic burden tests. By default counts all "
"variants with high impact in coding regions "
"as contributing to burden.")
parser_burden = subparsers.add_parser('burden',
help=burden_help)
parser_burden.add_argument('--nonsynonymous', action='store_true',
default=False,
help=("Count all nonsynonymous variants as "
"contributing burden."))
parser_burden.add_argument('--cases',
dest='cases',
nargs='*',
help=('Space separated list of cases for '
'association testing.'))
parser_burden.add_argument('--controls',
nargs='*',
dest='controls',
help=('Space separated list of controls for '
'association testing.'))
parser_burden.add_argument('--calpha',
action='store_true',
default=False,
help="Run the C-alpha association test.")
parser_burden.add_argument('--permutations',
default=0,
type=int,
help=("Number of permutations to run for the "
"C-alpha test (try 1000 to start)."))
parser_burden.add_argument('--min-aaf',
dest='min_aaf',
type=float,
default=0.0,
help='The min. alt. allele frequency for a '
'variant to be included.')
parser_burden.add_argument('--max-aaf',
dest='max_aaf',
type=float,
default=1.0,
help='The max. alt. allele frequency for a '
'variant to be included.')
parser_burden.add_argument('--save_tscores', default=False,
action='store_true',
help='Save the permuted T-scores to a file.')
parser_burden.add_argument('db',
metavar='db',
help='The name of the database to be queried.')
def burden_fn(parser, args):
import tool_burden_tests
tool_burden_tests.burden(parser, args)
parser_burden.set_defaults(func=burden_fn)
#########################################
# $ gemini interactions
#########################################
parser_interaction = subparsers.add_parser('interactions',
help='Find interaction partners for a gene in sample variants(default mode)')
parser_interaction.add_argument('db',
metavar='db',
help='The name of the database to be queried')
parser_interaction.add_argument('-g',
dest='gene',
help='Gene to be used as a root in BFS/shortest_path')
parser_interaction.add_argument('-r',
dest='radius',
type=int,
help="Set filter for BFS:\n"
"valid numbers starting from 0")
parser_interaction.add_argument('--var',
dest='var_mode',
help='var mode: Returns variant info (e.g. impact, biotype) for interacting genes',
action='store_true',
default=False)
def interactions_fn(parser, args):
import tool_interactions
tool_interactions.genequery(parser, args)
parser_interaction.set_defaults(func=interactions_fn)
#########################################
# gemini lof_interactions
#########################################
parser_interaction = subparsers.add_parser('lof_interactions',
help='Find interaction partners for a lof gene in sample variants(default mode)')
parser_interaction.add_argument('db',
metavar='db',
help='The name of the database to be queried')
parser_interaction.add_argument('-r',
dest='radius',
type=int,
help="set filter for BFS:\n")
parser_interaction.add_argument('--var',
dest='var_mode',
help='var mode: Returns variant info (e.g. impact, biotype) for interacting genes',
action='store_true',
default=False)
def lof_interactions_fn(parser, args):
import tool_interactions
tool_interactions.lofgenequery(parser, args)
parser_interaction.set_defaults(func=lof_interactions_fn)
#########################################
# $ gemini autosomal_recessive
#########################################
parser_auto_rec = subparsers.add_parser('autosomal_recessive',
help='Identify variants meeting an autosomal \
recessive inheritance model')
parser_auto_rec.add_argument('db',
metavar='db',
help='The name of the database to be queried.')
parser_auto_rec.add_argument('--columns',
dest='columns',
metavar='STRING',
help='A list of columns that you would like returned. Def. = "*"',
)
parser_auto_rec.add_argument('--filter',
dest='filter',
metavar='STRING',
help='Restrictions to apply to variants (SQL syntax)')
parser_auto_rec.add_argument('--min-kindreds',
dest='min_kindreds',
type=int,
default=1,
help='The min. number of kindreds that must have a candidate variant in a gene.')
parser_auto_rec.add_argument('-d',
dest='min_sample_depth',
type=int,
help="The minimum aligned\
sequence depth (genotype DP) req'd for\
each sample (def. = 0)",
default=0)
def autosomal_recessive_fn(parser, args):
import tool_autosomal_recessive
tool_autosomal_recessive.run(parser, args)
parser_auto_rec.set_defaults(func=autosomal_recessive_fn)
#########################################
# $ gemini autosomal_dominant
#########################################
parser_auto_dom = subparsers.add_parser('autosomal_dominant',
help='Identify variants meeting an autosomal \
dominant inheritance model')
parser_auto_dom.add_argument('db',
metavar='db',
help='The name of the database to be queried.')
parser_auto_dom.add_argument('--columns',
dest='columns',
metavar='STRING',
help='A list of columns that you would like returned. Def. = "*"',
)
parser_auto_dom.add_argument('--filter',
dest='filter',
metavar='STRING',
help='Restrictions to apply to variants (SQL syntax)')
parser_auto_dom.add_argument('--min-kindreds',
dest='min_kindreds',
type=int,
default=1,
help='The min. number of kindreds that must have a candidate variant in a gene.')
parser_auto_dom.add_argument('-d',
dest='min_sample_depth',
type=int,
help="The minimum aligned\
sequence depth (genotype DP) req'd for\
each sample (def. = 0)",
default=0)
def autosomal_dominant_fn(parser, args):
import tool_autosomal_dominant
tool_autosomal_dominant.run(parser, args)
parser_auto_dom.set_defaults(func=autosomal_dominant_fn)
#########################################
# $ gemini de_novo
#########################################
parser_de_novo = subparsers.add_parser('de_novo',
help='Identify candidate de novo mutations')
parser_de_novo.add_argument('db',
metavar='db',
help='The name of the database to be queried.')
parser_de_novo.add_argument('--columns',
dest='columns',
metavar='STRING',
help='A list of columns that you would like returned. Def. = "*"',
)
parser_de_novo.add_argument('--filter',
dest='filter',
metavar='STRING',
help='Restrictions to apply to variants (SQL syntax)')
parser_de_novo.add_argument('-d',
dest='min_sample_depth',
type=int,
help="The minimum aligned\
sequence depth (genotype DP) req'd for\
each sample (def. = 0)",
default=0)
def de_novo_fn(parser, args):
import tool_de_novo_mutations
tool_de_novo_mutations.run(parser, args)
parser_de_novo.set_defaults(func=de_novo_fn)
#########################################
# $ gemini mendel violations
#########################################
parser_mendel = subparsers.add_parser('mendel_errors',
help='Identify candidate violations of Mendelian inheritance')
parser_mendel.add_argument('db',
metavar='db',
help='The name of the database to be queried.')
parser_mendel.add_argument('--columns',
dest='columns',
metavar='STRING',
help='A list of columns that you would like returned. Def. = "*"',
)
parser_mendel.add_argument('--filter',
dest='filter',
metavar='STRING',
help='Restrictions to apply to variants (SQL syntax)')
parser_mendel.add_argument('-d',
dest='min_sample_depth',
type=int,
help="The minimum aligned\
sequence depth (genotype DP) req'd for\
each sample (def. = 0)",
default=0)
def mendel_fn(parser, args):
import tool_mendel_errors
tool_mendel_errors.run(parser, args)
parser_mendel.set_defaults(func=mendel_fn)
#########################################
# $ gemini browser
#########################################
parser_browser = subparsers.add_parser('browser',
help='Browser interface to gemini')
parser_browser.add_argument('db', metavar='db',
help='The name of the database to be queried.')
def browser_fn(parser, args):
import gemini_browser
gemini_browser.browser_main(parser, args)
parser_browser.set_defaults(func=browser_fn)
#########################################
# $ gemini set_somatic
#########################################
parser_set_somatic = subparsers.add_parser("set_somatic",
help="Tag somatic mutations (is_somatic) by comparint tumor/normal pairs.")
parser_set_somatic.add_argument('db', metavar='db',
help='The name of the database to be updated.')
parser_set_somatic.add_argument('--min-depth',
dest='min_depth',
type=float,
default=None,
help='The min combined depth for tumor + normal (def: %(default)s).')
parser_set_somatic.add_argument('--min-qual',
dest='min_qual',
type=float,
default=None,
help='The min variant quality (VCF QUAL) (def: %(default)s).')
parser_set_somatic.add_argument('--max-norm-alt-freq',
dest='max_norm_alt_freq',
type=float,
default=None,
help='The max freq. of the alt. allele in the normal sample (def: %(default)s).')
parser_set_somatic.add_argument('--max-norm-alt-count',
dest='max_norm_alt_count',
type=int,
default=None,
help='The max count. of the alt. allele in the normal sample (def: %(default)s).')
parser_set_somatic.add_argument('--min-norm-depth',
dest='min_norm_depth',
type=int,
default=None,
help='The minimum depth allowed in the normal sample to believe somatic (def: %(default)s).')
parser_set_somatic.add_argument('--min-tumor-alt-freq',
dest='min_tumor_alt_freq',
type=float,
default=None,
help='The min freq. of the alt. allele in the tumor sample (def: %(default)s).')
parser_set_somatic.add_argument('--min-tumor-alt-count',
dest='min_tumor_alt_count',
type=int,
default=None,
help='The min count. of the alt. allele in the tumor sample (def: %(default)s).')
parser_set_somatic.add_argument('--min-tumor-depth',
dest='min_tumor_depth',
type=int,
default=None,
help='The minimum depth allowed in the tumor sample to believe somatic (def: %(default)s).')
parser_set_somatic.add_argument('--chrom',
dest='chrom',
metavar='STRING',
help='A specific chromosome on which to tag somatic mutations. (def: %(default)s).',
default=None,
)
parser_set_somatic.add_argument('--dry-run',
dest='dry_run',
action='store_true',
help='Don\'t set the is_somatic flag, just report what _would_ be set. For testing parameters.',
default=False)
def set_somatic_fn(parser, args):
import gemini_set_somatic
gemini_set_somatic.set_somatic(parser, args)
parser_set_somatic.set_defaults(func=set_somatic_fn)
#########################################
# $ gemini actionable_mutations
#########################################
parser_actionable_mut = subparsers.add_parser("actionable_mutations",
help="Retrieve genes with actionable somatic mutations via COSMIC and DGIdb.")
parser_actionable_mut.add_argument('db', metavar='db',
help='The name of the database to be queried.')
def get_actionable_mut_fn(parser, args):
import gemini_actionable_mutations
gemini_actionable_mutations.get_actionable_mutations(parser, args)
parser_actionable_mut.set_defaults(func=get_actionable_mut_fn)
#########################################
# $ gemini update
#########################################
parser_update = subparsers.add_parser("update", help="Update gemini software and data files.")
parser_update.add_argument("--devel", help="Get the latest development version instead of the release",
action="store_true", default=False)
parser_update.add_argument("--dataonly", help="Only update data, not the underlying libraries.",
action="store_true", default=False)
parser_update.add_argument("--extra", help="Add additional non-standard genome annotations to include",
action="append", default=[], choices=["gerp_bp","cadd_score"])
parser_update.add_argument("--tooldir", help="Directory for third party tools (ie /usr/local) update")
parser_update.add_argument("--sudo", help="Use sudo for tool installation commands",
dest="sudo", action="store_true", default=False)
def update_fn(parser, args):
import gemini_update