annotate data_manager/metanetx_chem_prop_fetcher.py @ 14:8e8a9e51f1d7 draft

"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
author ggricourt
date Wed, 09 Mar 2022 15:18:07 +0000
parents c1d4f14dc768
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
1 import argparse
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
2 import json
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
3 import os
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
4 import shutil
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
5 import sys
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
6 import tempfile
14
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
7 # import pandas as pd
13
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
8 try:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
9 # For Python 3.0 and later
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
10 from urllib.request import Request, urlopen
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
11 except ImportError:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
12 # Fall back to Python 2 imports
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
13 from urllib2 import Request, urlopen
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
14
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
15
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
16 METANETX_URL = "https://www.metanetx.org/ftp/"
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
17
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
18
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
19 def url_download(url, path):
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
20 try:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
21 with urlopen(Request(url)) as fod:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
22 with open(path, "wb") as dst:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
23 while True:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
24 chunk = fod.read(2**10)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
25 if chunk:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
26 dst.write(chunk)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
27 else:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
28 break
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
29 except Exception as e:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
30 sys.exit(str(e))
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
31
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
32
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
33 def clean_metanetx_file(path):
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
34 ftmp = tempfile.NamedTemporaryFile()
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
35 isHeaderFound = False
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
36 with open(path) as fid, open(ftmp.name, 'w') as fod:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
37 for line in fid:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
38 if line.startswith("#"):
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
39 last_line = line
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
40 else:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
41 if not isHeaderFound:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
42 last_line = last_line.replace("#", "")
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
43 fod.write(last_line)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
44 isHeaderFound = True
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
45 fod.write(line)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
46 shutil.copyfile(ftmp.name, path)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
47
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
48
14
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
49 # def records_chem_prop_pandas(path):
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
50 # df = pd.read_csv(path, sep="\t")
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
51 # df["name"] = df.apply(lambda x: "%s: %s (%s)" % (x["ID"], x["name"], x["formula"]), axis=1)
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
52 # df.drop(columns=["reference", "formula", "charge", "mass", "InChIKey", "SMILES"], inplace=True)
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
53 # df.rename(columns={"ID": "value", "InChI": "inchi"})
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
54 # return df.to_dict('records')
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
55
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
56
13
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
57 def records_chem_prop(path):
14
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
58 records = []
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
59 with open(path) as fid:
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
60 for ix, line in enumerate(fid):
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
61 if ix == 0:
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
62 continue
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
63 line = line.split("\t")
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
64 if line[7] != '':
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
65 records.append({
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
66 "value": line[0],
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
67 "name": "%s: %s (%s)" % (line[0], line[1], line[3]),
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
68 "inchi": line[7],
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
69 })
8e8a9e51f1d7 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents: 13
diff changeset
70 return records
13
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
71
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
72
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
73 if __name__ == "__main__":
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
74 parser = argparse.ArgumentParser()
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
75 pinput = parser.add_mutually_exclusive_group(required=True)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
76 pinput.add_argument("--version", help="Version to download")
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
77 parser.add_argument("--out-file", help="JSON output file")
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
78 args = parser.parse_args()
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
79
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
80 # Init.
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
81 data_manager_json = {"data_tables": {}}
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
82 with open(args.out_file) as fh:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
83 params = json.load(fh)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
84
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
85 workdir = params["output_data"][0]["extra_files_path"]
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
86 os.makedirs(workdir)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
87
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
88 # Load models and models metadata.
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
89 ftmp = tempfile.NamedTemporaryFile()
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
90 url = '/'.join([METANETX_URL, args.version, 'chem_prop.tsv'])
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
91 url_download(url, ftmp.name)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
92
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
93 # Clean header
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
94 clean_metanetx_file(ftmp.name)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
95
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
96 # Select records.
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
97 records = records_chem_prop(ftmp.name)
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
98
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
99 # Write data.
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
100 data_manager_json["data_tables"]["metanetx_chem_prop"] = records
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
101 with open(args.out_file, "w") as fh:
c1d4f14dc768 "planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
ggricourt
parents:
diff changeset
102 json.dump(data_manager_json, fh, sort_keys=True)