annotate rpviz/main.py @ 16:fe78fd6b315a draft

planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
author pablocarb
date Tue, 11 Jun 2019 11:42:40 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
1 # -*- coding: utf-8 -*-
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
2 """
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
3 Created on Mon Jun 10 11:48:55 2019
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
4
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
5 @author: anael
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
6 """
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
7
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
8 import argparse
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
9 import os
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
10 from .sbml2lists import sbml2list
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
11 from .network2json import network2
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
12 from .py2html2 import html2
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
13
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
14 def arguments():
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
15 parser = argparse.ArgumentParser(description='Visualizing a network from sbml')
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
16 parser.add_argument('inputfolder',
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
17 help='Input folder with sbml files.')
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
18 parser.add_argument('outfile',
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
19 help='html file.')
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
20 return parser
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
21
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
22 def run(infolder,outfile,test=True):
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
23
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
24 if test:
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
25 folders=[infolder]
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
26 else:
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
27 folders=os.listdir(infolder)
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
28 json_elements={}
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
29 for f in folders:
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
30 if test:
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
31 file=f
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
32 else:
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
33 file=os.path.join(infolder,f)
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
34 output=sbml2list(file)
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
35 LR=output[0]
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
36 Lreact=output[1]
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
37 Lprod=output[2]
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
38 name=output[3]
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
39 species_smiles=output[4]
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
40 images=output[5]
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
41 species_names=output[6]
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
42 species_links=output[7]
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
43
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
44 #from smile2picture import picture
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
45 #image=picture(species_smiles)
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
46
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
47
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
48 json_elements[name]=network2(LR,Lreact,Lprod,name,species_smiles,images,species_names,species_links)
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
49
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
50
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
51 html2(json_elements,outfile)
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
52
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
53 if __name__ == '__main__':
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
54 parser = arguments()
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
55 arg = parser.parse_args()
fe78fd6b315a planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff changeset
56 run(arg.inputfolder,arg.outfile)