Repository 'synbiodesign'
hg clone https://toolshed.g2.bx.psu.edu/repos/pablocarb/synbiodesign

Changeset 24:8f42eba7e2eb (2019-07-05)
Previous changeset 23:635b76a9bd7a (2019-07-05) Next changeset 25:2f8af738e139 (2019-07-05)
Commit message:
planemo upload commit 2414e76bee8adbe48fee12b14b13a743a03b9748-dirty
modified:
toolOptBioDes.py
added:
optbiodes2.xml
b
diff -r 635b76a9bd7a -r 8f42eba7e2eb optbiodes2.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/optbiodes2.xml Fri Jul 05 17:18:26 2019 -0400
[
@@ -0,0 +1,38 @@
+<tool id="optbiodes" name="OptBioDes" version="0.1.0">
+    <description>Optimal synbio design: from genetic parts to SBOL-compliant constructs description</description>
+    <requirements>
+        <requirement type="package" version="2">requests</requirement>
+    </requirements>
+    <command detect_errors="exit_code"><![CDATA[
+        python $__tool_directory__/toolOptBioDes.py $input1 -partsfile $input2 -genesfile $input3 $output1 $output2 -sbolOut $output3 -server $server
+    ]]></command>
+    <inputs>
+        <param type="integer" name="input1" value="48" label="Library size" help="Library size" />
+        <param type="data" name="input2" format="csv" />
+        <param type="data" name="input3" format="csv" />
+     <param name="server" type="text" label="OptBioDes RES server" value="http://optbiodes.synbiochem.co.uk/REST" help="OptBioDes REST server" />
+    </inputs>
+    <outputs>
+        <data name="output1" format="csv" from_work_dir="out1.csv" />
+        <data name="output2" format="csv" from_work_dir="out2.csv" />
+        <data name="output3" format="csv" from_work_dir="out3.csv" />
+    </outputs>
+    <help><![CDATA[
+        usage: toolOptBioDes.py [-h] [-server SERVER] infile outfile diagfile
+
+toolOptBioDes: Optimal SynBio Design. Pablo Carbonell, SYNBIOCHEM, 2019
+
+arguments:
+  size            Library size
+  partsfile       Input genetic parts csv file.
+  genesfile       Input gene list csv file.
+  outfile         Output csv design file.
+  diagfile        Output csv diagnostics file.
+  sbolfile        Output SBOL combinatorial genetic library
+
+optional arguments:
+  -h, --help      show this help message and exit
+  -server SERVER  OptBioDes server.
+
+    ]]></help>
+</tool>
b
diff -r 635b76a9bd7a -r 8f42eba7e2eb toolOptBioDes.py
--- a/toolOptBioDes.py Fri Jul 05 06:26:22 2019 -0400
+++ b/toolOptBioDes.py Fri Jul 05 17:18:26 2019 -0400
[
@@ -15,14 +15,20 @@
 
 def arguments():
     parser = argparse.ArgumentParser(description='toolOptBioDes: Optimal SynBio Design. Pablo Carbonell, SYNBIOCHEM, 2019')
-    parser.add_argument('infile', 
-                        help='Input csv file (DoE specificiations).')
     parser.add_argument('size', 
                         help='Library size.')
     parser.add_argument('outfile', 
                         help='Output csv design file.')
     parser.add_argument('diagfile', 
                         help='Output csv diagnostics file.')
+    parser.add_argument('-infile', default=None,
+                        help='Input csv file (DoE specifications sheet).')
+    parser.add_argument('-partsfile', default=None,
+                        help='Input csv file (Regulartory parts).')
+    parser.add_argument('-genesfile', default=None,
+                        help='Input csv file (Genetic parts).')
+    parser.add_argument('-sbolOut', default=None,
+                        help='Output design in SBOL format.')
     parser.add_argument('-server', default='http://optbiodes.synbiochem.co.uk/REST',
                         help='OptBioDes server.')
     return parser
@@ -49,10 +55,33 @@
         cw.writerow( [res['data']['libsize'], res['data']['J']] )
     print( 'Size:', res['data']['libsize'], 'Efficiency:', res['data']['J'] )
 
+def partsUploadSbol( partsfile, genesfile, size, outfile, diagfile, sbolOut, server ):
+    files = { 
+        'parts': open(partsfile, 'rb' ),
+        'genes': open(genesfile, 'rb')
+    }
+    values = {'size': size}
+    r = requests.post( os.path.join(url, 'Parts' ), files=files, data=values )
+    res = json.loads( r.content.decode('utf-8') )
+    M = res['data']['M']
+    with open(outfile, 'w') as h:
+        cw = csv.writer(h)      
+        cw.writerow( res['data']['names'] )
+        for row in M:
+            cw.writerow( row )
+    with open(diagfile, 'w') as h:
+        cw = csv.writer(h)
+        cw.writerow( ['Size', 'Efficiency'] )
+        cw.writerow( [res['data']['libsize'], res['data']['J']] )
+    open(sbolOut, 'w').write(res['data']['sbol'])
+    print( 'Size:', res['data']['libsize'], 'Efficiency:', res['data']['J'] )
 
 
 if __name__ == "__main__":
     parser = arguments()
     arg = parser.parse_args()
     assert os.path.exists(arg.infile)
-    sheetUpload( arg.infile, arg.size, arg.outfile, arg.diagfile, arg.server )
+    if arg.sbolOut is None:
+        sheetUpload( arg.infile, arg.size, arg.outfile, arg.diagfile, arg.server )
+    else:
+        partsUploadSbol(  arg.partsfile, arg.genesfile, arg.size, arg.outfile, arg.diagfile, arg.sbolOut, arg.server )