1 '''
2 'bpms.py' sets up the command line arguments for the 'genecentric-bpms'
3 program.
4
5 It can do quite a few things in parallel (like generating random bipartitions),
6 so this module also does some preprocessing to setup sane defaults for
7 parallelization.
8 '''
9 import argparse
10 import multiprocessing as mp
11
12 import bpm
13 from bpm.cmdargs import assert_read_access
14
15 try:
16 __cpus = mp.cpu_count()
17 except NotImplementedError:
18 __cpus = 1
19
20 parser = argparse.ArgumentParser(
21 description='BPM generator',
22 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
23 aa = parser.add_argument
24 aa('geneinter', type=str,
25 metavar='INPUT_GENETIC_INTERACTION_FILE', help='Location of the GI file.')
26 aa('bpm', type=str,
27 metavar='OUTPUT_BPM_FILE', help='Where the BPM output will be written.')
28 aa('-e', '--ignore-list', dest='ignore', type=str, default=None,
29 metavar='IGNORE_FILE',
30 help='The location of an ignore gene list file. (One gene per line.) '
31 'Any genes in this file will be excluded from the set of genes used '
32 'to generate BPMs.')
33 aa('-c', '--gene-ratio', dest='C', type=float, default=0.90,
34 metavar='RATIO', help='Gene ratio threshold')
35 aa('-j', '--jaccard', dest='jaccard', type=float, default=0.66,
36 metavar='JACCARD_INDEX', help='Jaccard Index threshold')
37 aa('-m', '--num-bipartitions', dest='M', type=int, default=250,
38 metavar='NUMBER_BIPARTITIONS', help='Number of bipartitions to generate')
39 aa('--emap', dest='emap_defaults', action='store_true',
40 help='If set, EMAP default parameters will be used. This overrides all '
41 'other parameters.')
42 aa('--squaring', dest='squaring', action='store_true',
43 help='If set, genetic interaction scores will be squared. '
44 'Squaring typically speeds convergence.')
45 aa('--minimum-size', dest='min_size', type=int, default=3,
46 metavar='MIN_SIZE',
47 help='Minimum size of BPM. Smaller BPMs are pruned. '
48 'Set to 0 to disable.')
49 aa('--maximum-size', dest='max_size', type=int, default=25,
50 metavar='MAX_SIZE',
51 help='Maximum size of BPM. Bigger BPMs are pruned. '
52 'Set to 0 to disable.')
53 aa('-p', '--processes', dest='processes', type=int, default=__cpus,
54 metavar='PROCESSES',
55 help='The number of processes to run concurrently. If set to '
56 '1, the multiprocessing module will not be used.')
57 aa('--no-jaccard', dest='pruning', action='store_false',
58 help='If set, no pruning will occur. Note that --minimum-size and '
59 '--maximum-size will still have an effect. Set those to 0 to '
60 'disable that pruning.')
61 aa('--no-progress', dest='progress', action='store_false',
62 help='If set, the progress bar will not be shown.')
63 aa('-v', '--verbose', dest='verbose', action='store_true',
64 help='If set, more output will be shown.')
65
66 conf = parser.parse_args()
67
68
69 if conf.emap_defaults:
70 conf.C = 0.9
71 conf.jaccard = 0.66
72 conf.M = 250
73 conf.squaring = True
74 conf.min_size = 3
75 conf.max_size = 25
76 conf.pruning = True
77
78
79
80
81 if conf.processes > __cpus:
82 conf.processes = __cpus
83
84
85 assert_read_access(conf.geneinter)
86 if conf.ignore:
87 assert_read_access(conf.ignore)
88
89
90 bpm.conf = conf
91