-
Notifications
You must be signed in to change notification settings - Fork 1
/
process_flu.py
executable file
·48 lines (30 loc) · 1.18 KB
/
process_flu.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
from local_settings import *
from global_settings import *
from itertools import *
from utils import GetFluSeqs, DictFromGen
from optparse import OptionParser
from collections import defaultdict
import os, os.path, re, logging
import cloud
def take(n, iterable):
"Return first n items of the iterable as a list"
return list(islice(iterable, n))
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('-c', '--use-cloud', default = False, action = 'store_true',
dest = 'usecloud', help = 'Use PiCloud computing')
(options, args) = parser.parse_args()
cloud.setkey(CLOUD_KEY, CLOUD_SECRET)
if not options.usecloud: cloud.start_simulator()
for short_name in args:
logging.warning('Processing Genome: %s' % short_name)
flu_gen = GetFluSeqs(organism = FLU_NAMES[short_name])
outdata = DictFromGen(flu_gen, label = short_name)
logging.warning('writting data for %s' % short_name)
with open(os.path.join(RESULTSDIR, 'flu_elmdict_'+short_name), 'w') as handle:
l = outdata.keys()
l.sort()
for key in l:
count, frac = outdata[key]
elm, spec = key
handle.write('\t'.join(map(str, [elm, spec, count, '%.10f' % frac]))+'\n')