-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-neo-makefile.py
executable file
·67 lines (55 loc) · 1.89 KB
/
build-neo-makefile.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
#!/usr/bin/env python3
__author__ = 'cjm'
import argparse
import sys
import os
import json
def main():
parser = argparse.ArgumentParser(description='NEO'
'NEO Builder',
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-i', '--input', type=str, default='datasets.json', required=False,
help='Input metadata file')
args = parser.parse_args()
f = open(args.input, 'r')
datasets = json.loads(f.read())
f.close()
build(datasets, args)
def build(datasets, args):
#print("Datasets: "+str(datasets))
smap = {}
for d in datasets:
dn = d['dataset']
t = d['type']
if t == 'gpi':
smap[dn] = d
elif t == 'gaf':
if dn not in smap:
smap[dn] = d
for (db,obj) in smap.items():
sp = db ## TODO
if 'species_code' in obj:
sp = obj['species_code']
if sp is None:
sp = db
if 'source' not in obj:
print("No URL: {} {}".format(db, obj))
url = obj['source']
toks = url.split("/")
bn = "mirror/"+toks[-1]
cmd = "./" + obj['type'] +"2ofn.pl"
extra_args = ""
if 'isoform' in bn:
extra_args += " -I"
target(bn,[],
"wget --no-check-certificate "+url+" -O [email protected] && mv [email protected] $@")
if 'compression' in obj:
target("target/neo-"+db+".ofn",[bn], "gzip -dc "+bn+" | " + cmd + " -s "+ sp + " -n " + db + extra_args + " > [email protected] && mv [email protected] $@")
else:
target("target/neo-"+db+".ofn",[bn], "cat "+bn+" | " + cmd + " -s "+ sp + " -n " + db + extra_args + " > [email protected] && mv [email protected] $@")
def target(tgt,deps,cmd):
print(tgt+": "+" ".join(deps))
print("\t"+cmd)
print("\n")
if __name__ == "__main__":
main()