Mercurial > repos > ggricourt > data_manager_bigg
annotate data_manager/bigg_model_sbml_fetcher.py @ 2:2be543b08426 draft
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit ca4bd5776dd6d4dc8493544f123ef09496902981"
author | ggricourt |
---|---|
date | Wed, 23 Feb 2022 16:09:22 +0000 |
parents | 5068c6484606 |
children | 2f837e65b33c |
rev | line source |
---|---|
0
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
1 import argparse |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
2 import json |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
3 import os |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
4 import sys |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
5 try: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
6 # For Python 3.0 and later |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
7 from urllib.request import Request, urlopen |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
8 except ImportError: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
9 # Fall back to Python 2 imports |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
10 from urllib2 import Request, urlopen |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
11 |
1
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
12 BASE_URL = 'http://bigg.ucsd.edu/static/models' |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
13 ID2ORG = { |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
14 "iCN718": "Acinetobacter baumannii AYE", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
15 "iYO844": "Bacillus subtilis subsp. subtilis str. 168", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
16 "iRC1080": "Chlamydomonas reinhardtii", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
17 "iCN900": "Clostridioides difficile 630", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
18 "iHN637": "Clostridium ljungdahlii DSM 13528", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
19 "iCHOv1_DG44": "Cricetulus griseus", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
20 "iCHOv1": "Cricetulus griseus", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
21 "iAF1260b": "Escherichia coli str. K-12 substr. MG1655", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
22 "iAF1260": "Escherichia coli str. K-12 substr. MG1655", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
23 "iML1515": "Escherichia coli str. K-12 substr. MG1655", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
24 "iJO1366": "Escherichia coli str. K-12 substr. MG1655", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
25 "iJR904": "Escherichia coli str. K-12 substr. MG1655", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
26 "e_coli_core": "Escherichia coli str. K-12 substr. MG1655", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
27 "iAF987": "Geobacter metallireducens GS-15", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
28 "iIT341": "Helicobacter pylori 26695", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
29 "iAT_PLT_636": "Homo sapiens", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
30 "Recon3D": "Homo sapiens", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
31 "iAB_RBC_283": "Homo sapiens", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
32 "RECON1": "Homo sapiens", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
33 "iYL1228": "Klebsiella pneumoniae subsp. pneumoniae MGH 78578", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
34 "iNF517": "Lactococcus lactis subsp. cremoris MG1363", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
35 "iAF692": "Methanosarcina barkeri str. Fusaro", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
36 "iMM1415": "Mus musculus", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
37 "iNJ661": "Mycobacterium tuberculosis H37Rv", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
38 "iEK1008": "Mycobacterium tuberculosis H37Rv", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
39 "iLB1027_lipid": "Phaeodactylum tricornutum CCAP 1055/1", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
40 "iAM_Pb448": "Plasmodium berghei", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
41 "iAM_Pc455": "Plasmodium cynomolgi strain B", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
42 "iAM_Pf480": "Plasmodium falciparum 3D7", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
43 "iAM_Pk459": "Plasmodium knowlesi strain H", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
44 "iAM_Pv461": "Plasmodium vivax Sal-1", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
45 "iJN746": "Pseudomonas putida KT2440", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
46 "iJN1463": "Pseudomonas putida KT2440", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
47 "iND750": "Saccharomyces cerevisiae S288C", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
48 "iMM904": "Saccharomyces cerevisiae S288C", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
49 "STM_v1_0": "Salmonella enterica subsp. enterica serovar Typhimurium str. LT2", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
50 "iYS1720": "Salmonella pan-reactome", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
51 "iSB619": "Staphylococcus aureus subsp. aureus N315", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
52 "iYS854": "Staphylococcus aureus subsp. aureus USA300_TCH1516", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
53 "iJB785": "Synechococcus elongatus PCC 7942", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
54 "iJN678": "Synechocystis sp. PCC 6803", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
55 "iSynCJ816": "Synechocystis sp. PCC 6803", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
56 "iLJ478": "Thermotoga maritima MSB8", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
57 "iIS312": "Trypanosoma cruzi Dm28c", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
58 "iIS312_Trypomastigote": "Trypanosoma cruzi Dm28c", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
59 "iIS312_Epimastigote": "Trypanosoma cruzi Dm28c", |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
60 "iIS312_Amastigote": "Trypanosoma cruzi Dm28c" |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
61 } |
0
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
62 |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
63 def url_download(url, workdir): |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
64 file_path = os.path.abspath(os.path.join(workdir, os.path.basename(url))) |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
65 src = None |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
66 dst = None |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
67 try: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
68 req = Request(url) |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
69 src = urlopen(req) |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
70 with open(file_path, 'wb') as dst: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
71 while True: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
72 chunk = src.read(2**10) |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
73 if chunk: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
74 dst.write(chunk) |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
75 else: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
76 break |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
77 except Exception as e: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
78 sys.exit(str(e)) |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
79 finally: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
80 if src: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
81 src.close() |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
82 return file_path |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
83 |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
84 |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
85 def download(model_id, out_file): |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
86 |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
87 with open(out_file) as fh: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
88 params = json.load(fh) |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
89 |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
90 workdir = params['output_data'][0]['extra_files_path'] |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
91 os.makedirs(workdir) |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
92 |
1
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
93 data_manager_json = {'data_tables': {}} |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
94 file_path = url_download(BASE_URL + '/' + model_id + '.xml', workdir) |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
95 |
0
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
96 data_manager_entry = {} |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
97 data_manager_entry['value'] = model_id |
1
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
98 data_manager_entry['name'] = MODELID2ORG.get(model_id, 'undefined') |
0
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
99 data_manager_entry['path'] = file_path |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
100 |
1
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
101 data_manager_json['data_tables']['bigg_model_sbml'] = data_manager_entry |
0
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
102 with open(out_file, 'w') as fh: |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
103 json.dump(data_manager_json, fh, sort_keys=True) |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
104 |
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
105 |
1
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
106 if __name__ == '__main__': |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
107 parser = argparse.ArgumentParser() |
2
2be543b08426
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit ca4bd5776dd6d4dc8493544f123ef09496902981"
ggricourt
parents:
1
diff
changeset
|
108 parser.add_argument('--model-id', help='Model BIGG id') |
1
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
109 parser.add_argument('--out-file', help='JSON output file') |
5068c6484606
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 8353ca81a49f5c8c7efb00cdf08710f916422a44-dirty"
ggricourt
parents:
0
diff
changeset
|
110 args = parser.parse_args() |
0
262b8d79bc08
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 19ad973add8651c1a18c1bda789e9296a57044b1"
ggricourt
parents:
diff
changeset
|
111 |
2
2be543b08426
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit ca4bd5776dd6d4dc8493544f123ef09496902981"
ggricourt
parents:
1
diff
changeset
|
112 download(args.model_id, args.out_file) |