Mercurial > repos > pablocarb > synbiodesign
comparison toolOptBioDes.py @ 2:856bd14e6e96 draft
planemo upload commit 6a252d04f4b2f79606ab6679b6a91f957e33da7b-dirty
author | pablocarb |
---|---|
date | Thu, 02 May 2019 07:16:40 -0400 |
parents | |
children | f3771c0a2327 |
comparison
equal
deleted
inserted
replaced
1:b0b7deebb71e | 2:856bd14e6e96 |
---|---|
1 #!/usr/bin/env python3 | |
2 # -*- coding: utf-8 -*- | |
3 """ | |
4 Created on Mar 19 | |
5 | |
6 @author: Pablo Carbonell | |
7 @description: Query OptBioDes: optimal synbio design. | |
8 | |
9 """ | |
10 import requests | |
11 import argparse | |
12 import csv | |
13 import os | |
14 import json | |
15 | |
16 def arguments(): | |
17 parser = argparse.ArgumentParser(description='toolOptBioDes: Optimal SynBio Design. Pablo Carbonell, SYNBIOCHEM, 2019') | |
18 parser.add_argument('infile', | |
19 help='Input xlsx file (DoE specificiations).') | |
20 parser.add_argument('outfile', | |
21 help='Output csv design file.') | |
22 parser.add_argument('diagfile', | |
23 help='Output csv diagnostics file.') | |
24 parser.add_argument('-server', default='http://doe.synbiochem.co.uk/REST', | |
25 help='OptBioDes server.') | |
26 return parser | |
27 | |
28 def testApp(url): | |
29 r = requests.get( url ) | |
30 res = json.loads( r.content.decode('utf-8') ) | |
31 print( res ) | |
32 | |
33 def sheetUpload(doefile, outfile, diagfile, url): | |
34 files = { 'file': open(doefile, 'rb' ) } | |
35 values = {'size': 64} | |
36 r = requests.post( os.path.join(url, 'Query' ), files=files, data=values ) | |
37 res = json.loads( r.content.decode('utf-8') ) | |
38 M = res['data']['M'] | |
39 with open(outfile, 'w') as h: | |
40 cw = csv.writer(h) | |
41 cw.writerow( res['data']['names'] ) | |
42 for row in M: | |
43 cw.writerow( row ) | |
44 print( 'Size:', res['data']['libsize'], 'Efficiency:', res['data']['J'] ) | |
45 | |
46 | |
47 | |
48 if __name__ == "__main__": | |
49 parser = arguments() | |
50 arg = parser.parse_args() | |
51 assert os.path.exists(arg.infile) | |
52 sheetUpload( arg.infile, arg.outfile, arg.diagfile, arg.url ) |