-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpvizServeTest.py
58 lines (47 loc) · 2.11 KB
/
rpvizServeTest.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
rpvizTest (c) University of Manchester 2019
rpvizTest is licensed under the MIT License.
To view a copy of this license, visit <http://opensource.org/licenses/MIT/>.
Created on Wed May 1 09:54:39 2019
@author: Pablo Carbonell, SYNBIOCHEM
@description: Test the rpviz server
"""
import requests
import json
import argparse
def arguments():
parser = argparse.ArgumentParser(description='toolRPViz: Pathway visualizer. Pablo Carbonell, SYNBIOCHEM, 2019')
parser.add_argument('infile',
help='Input folder with sbml files as in tar format.')
parser.add_argument('outfile',
help='tar file.')
parser.add_argument('--choice',
default="5",
help='What kind of input do you want ? \n 1/Single HTML file \n 2/Separated HTML files \n 3/View directly in Cytoscape \n 4/Generate a file readable in Cytoscape \n')
parser.add_argument('--format',
help='What kind of input is it ? sbml/csv')
parser.add_argument('--selenzyme_table',
default="N",
help='Do you want to display the selenzyme information ? Y/N')
parser.add_argument('--filenames',
help='import a csv file matching smiles and products names')
parser.add_argument('-server', default='http://localhost:8998/REST',
help='RPViz server.')
return parser
def testApp(url):
r = requests.get( url )
res = json.loads( r.content.decode('utf-8') )
print( res )
def testUpload(infile, outfile,choice,selenzyme_table,url, informat):
data = {'selenzyme_table': 'N', 'input_format': informat}
files = { 'file': open(infile, 'rb' ), 'data': ('data.json', json.dumps(data)) }
r=requests.post(url+'/Query',files=files)
open(outfile,'wb').write( r.content )
print( 'Success!' )
if __name__ == '__main__':
parser = arguments()
arg = parser.parse_args()
testApp(arg.server)
testUpload(arg.infile,arg.outfile,arg.choice, arg.selenzyme_table,arg.server,arg.format,arg.filenames)