comparison toolOptBioDes.py @ 8:6572347b3e1a draft

planemo upload commit 6a252d04f4b2f79606ab6679b6a91f957e33da7b-dirty
author pablocarb
date Thu, 02 May 2019 10:21:32 -0400
parents 93eb36300900
children f9aef3df1fc8
comparison
equal deleted inserted replaced
7:e328a5f60135 8:6572347b3e1a
14 import json 14 import json
15 15
16 def arguments(): 16 def arguments():
17 parser = argparse.ArgumentParser(description='toolOptBioDes: Optimal SynBio Design. Pablo Carbonell, SYNBIOCHEM, 2019') 17 parser = argparse.ArgumentParser(description='toolOptBioDes: Optimal SynBio Design. Pablo Carbonell, SYNBIOCHEM, 2019')
18 parser.add_argument('infile', 18 parser.add_argument('infile',
19 help='Input xlsx file (DoE specificiations).') 19 help='Input csv file (DoE specificiations).')
20 parser.add_argument('size', 20 parser.add_argument('size',
21 help='Library size.') 21 help='Library size.')
22 parser.add_argument('outfile', 22 parser.add_argument('outfile',
23 help='Output csv design file.') 23 help='Output csv design file.')
24 parser.add_argument('diagfile', 24 parser.add_argument('diagfile',
32 res = json.loads( r.content.decode('utf-8') ) 32 res = json.loads( r.content.decode('utf-8') )
33 print( res ) 33 print( res )
34 34
35 def sheetUpload(doefile, size, outfile, diagfile, url): 35 def sheetUpload(doefile, size, outfile, diagfile, url):
36 files = { 'file': open(doefile, 'rb' ) } 36 files = { 'file': open(doefile, 'rb' ) }
37 values = {'size': int(size)} 37 values = {'size': int(size), 'format': 'csv'}
38 r = requests.post( os.path.join(url, 'Query' ), files=files, data=values ) 38 r = requests.post( os.path.join(url, 'Query' ), files=files, data=values )
39 res = json.loads( r.content.decode('utf-8') ) 39 res = json.loads( r.content.decode('utf-8') )
40 M = res['data']['M'] 40 M = res['data']['M']
41 with open(outfile, 'w') as h: 41 with open(outfile, 'w') as h:
42 cw = csv.writer(h) 42 cw = csv.writer(h)
43 cw.writerow( res['data']['names'] ) 43 cw.writerow( res['data']['names'] )
44 for row in M: 44 for row in M:
45 cw.writerow( row ) 45 cw.writerow( row )
46 with open(diagfile. 'w') as h:
47 cw = csv.writer(h)
48 cw.writerow( ['Size', 'Efficiency'] )
49 cw.writerow( [res['data']['libsize'], res['data']['J']] )
46 print( 'Size:', res['data']['libsize'], 'Efficiency:', res['data']['J'] ) 50 print( 'Size:', res['data']['libsize'], 'Efficiency:', res['data']['J'] )
47 51
48 52
49 53
50 if __name__ == "__main__": 54 if __name__ == "__main__":