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

Changeset 19:dbc40b306014 (2019-06-13)
Previous changeset 18:612a2f94522f (2019-06-11) Next changeset 20:f3a219de2d1b (2019-06-13)
Commit message:
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5-dirty
modified:
rpviz.xml
added:
outfile.html
rpVisualizer.xml
toolRPViz.py
b
diff -r 612a2f94522f -r dbc40b306014 outfile.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/outfile.html Thu Jun 13 08:56:51 2019 -0400
[
b'@@ -0,0 +1,139 @@\n+<!DOCTYPE doctype html>\n+<html>\n+ <head>\n+  <meta charset="utf-8"/>\n+  <title>\n+   Viewer\n+  </title>\n+  <script id="elements">\n+   var obj ={"rp_2": {"nodes": [{"data": {"category": "reactions", "id": "<Reaction RP1>", "value": "<Reaction RP1>", "name": "<Reaction RP1>"}}, {"data": {"category": "reactions", "id": "<Reaction RP0>", "value": "<Reaction RP0>", "name": "<Reaction RP0>"}}, {"data": {"category": "reactions", "id": "<Reaction targetSink>", "value": "<Reaction targetSink>", "name": "<Reaction targetSink>"}}, {"data": {"category": "reactant", "name": "anthranilate", "link": "http://identifiers.org/metanetx.chemical/MNXM188", "root": "root", "id": "MNXM188__64__MNXC3", "value": "MNXM188__64__MNXC3"}}, {"data": {"category": "reactant", "name": "O2", "link": "http://identifiers.org/metanetx.chemical/MNXM4", "root": "root", "id": "MNXM4__64__MNXC3", "value": "MNXM4__64__MNXC3"}}, {"data": {"category": "reactant", "name": "NADPH", "link": "http://identifiers.org/metanetx.chemical/MNXM6", "root": "root", "id": "MNXM6__64__MNXC3", "value": "MNXM6__64__MNXC3"}}, {"data": {"category": "product", "smiles": "[H]Oc1c([H])c([H])c([H])c([H])c1O[H]", "image": "<svg version=\'1.1\' baseProfile=\'full\'\\n              xmlns=\'http://www.w3.org/2000/svg\'\\n                      xmlns:rdkit=\'http://www.rdkit.org/xml\'\\n                      xmlns:xlink=\'http://www.w3.org/1999/xlink\'\\n                  xml:space=\'preserve\'\\nwidth=\'200px\' height=\'200px\' >\\n<!-- END OF HEADER -->\\n<rect style=\'opacity:1.0;fill:#FFFFFF;stroke:none\' width=\'200\' height=\'200\' x=\'0\' y=\'0\'> </rect>\\n<path class=\'bond-0\' d=\'M 140.376,147.373 123.965,137.899\' style=\'fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\' />\\n<path class=\'bond-0\' d=\'M 123.965,137.899 107.555,128.424\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\' />\\n<path class=\'bond-1\' d=\'M 107.555,128.424 58.3228,156.848\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\' />\\n<path class=\'bond-1\' d=\'M 94.4851,122.841 60.0228,142.738\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-dasharray:6,6\' />\\n<path class=\'bond-7\' d=\'M 107.555,128.424 107.555,71.576\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\' />\\n<path class=\'bond-7\' d=\'M 96.1851,119.897 96.1851,80.1032\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-dasharray:6,6\' />\\n<path class=\'bond-2\' d=\'M 58.3228,156.848 9.09091,128.424\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\' />\\n<path class=\'bond-2\' d=\'M 56.6228,142.738 22.1605,122.841\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-dasharray:6,6\' />\\n<path class=\'bond-3\' d=\'M 9.09091,128.424 9.09091,71.576\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\' />\\n<path class=\'bond-3\' d=\'M 20.4605,119.897 20.4605,80.1032\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-dasharray:6,6\' />\\n<path class=\'bond-4\' d=\'M 9.09091,71.576 58.3228,43.1519\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\' />\\n<path class=\'bond-4\' d=\'M 22.1605,77.1587 56.6228,57.2619\' style=\'fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-dasharray:6,6\' />\\n<path class=\'b'..b'", "target": "CMPD_0000000049__64__MNXC3"}}, {"data": {"source": "<Reaction RP3>", "target": "CMPD_0000000029__64__MNXC3"}}, {"data": {"source": "<Reaction RP2>", "target": "CMPD_0000000012__64__MNXC3"}}, {"data": {"source": "<Reaction RP1>", "target": "CMPD_0000000003__64__MNXC3"}}, {"data": {"source": "<Reaction RP0>", "target": "TARGET_0000000001__64__MNXC3"}}, {"data": {"source": "MNXM164__64__MNXC3", "target": "<Reaction RP4>"}}, {"data": {"source": "MNXM6__64__MNXC3", "target": "<Reaction RP4>"}}, {"data": {"source": "CMPD_0000000049__64__MNXC3", "target": "<Reaction RP3>"}}, {"data": {"source": "MNXM4__64__MNXC3", "target": "<Reaction RP3>"}}, {"data": {"source": "MNXM4__64__MNXC3", "target": "<Reaction RP0>"}}, {"data": {"source": "CMPD_0000000029__64__MNXC3", "target": "<Reaction RP2>"}}, {"data": {"source": "MNXM2__64__MNXC3", "target": "<Reaction RP2>"}}, {"data": {"source": "CMPD_0000000012__64__MNXC3", "target": "<Reaction RP1>"}}, {"data": {"source": "CMPD_0000000003__64__MNXC3", "target": "<Reaction RP0>"}}, {"data": {"source": "TARGET_0000000001__64__MNXC3", "target": "<Reaction targetSink>"}}]}}\n+  </script>\n+  <script id="svg">\n+  </script>\n+  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">\n+  </script>\n+  <script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.7.0/cytoscape.min.js">\n+  </script>\n+  <script>\n+   function displaynet(network){\n+      var cy = cytoscape({\n+        container: $(\'#cy\'),\n+\n+        elements:network\n+      ,\n+\n+      layout: {\n+            name: \'breadthfirst\',\n+            roots: "node[root = \'root\']"\n+          },\n+\n+        style: [\n+          {\n+          selector: "node",\n+          style: {\n+              "background-color": \'#80D0D0\',\n+              "label": "data(name)",\n+              "font-size": "7px"\n+              }\n+          },\n+          {selector: "node[category=\'reactions\']",\n+          style: {\n+            \'background-color\': \'#FA8072\',\n+            \'shape\': \'roundrectangle\'\n+             }},\n+         {selector: "node[category=\'reactant\']",\n+         style: {\n+           \'background-color\': \'#52be80\',\n+            }},\n+         {\n+          selector: \'edge\',\n+          style: {\n+            \'curve-style\': \'bezier\',\n+            \'width\': \'3px\',\n+            \'target-arrow-shape\': \'triangle\',\n+          }\n+        }]\n+      });\n+\n+      cy.on(\'mouseover\',\'node\',function(e){\n+        var node_select=e.target;\n+        molecule=node_select.data("image");\n+        if(molecule){\n+        $("#molecule").append(molecule)};\n+      });\n+\n+      cy.on(\'mouseout\',\'node\',function(e){\n+        $("#molecule").empty();\n+      });\n+\n+      cy.on(\'tap\',\'node\',function(e){\n+        var node_select=e.target;\n+        console.log(node_select.data("name"));\n+        link=node_select.data("link");\n+        if(link){\n+          window.open(link)\n+        };\n+      });\n+      };\n+\n+    $(function() {\n+      $("#selectbox").change(function(){\n+        value=$("#selectbox :selected").val();\n+        displaynet(obj[value]);\n+      });\n+    });\n+  </script>\n+ </head>\n+ <style>\n+  #cy {\n+        width: 80%;\n+        height: 100%;\n+        position: absolute;\n+        left : 20%;\n+    }\n+\n+.interact{\n+  position:relative;\n+  width: 19%;\n+  height:100%;\n+}\n+#molecule{\n+  position : absolute;\n+  top : 80px;\n+}\n+ </style>\n+ <body>\n+  <div id="cy">\n+  </div>\n+  <div class="interact" id="interaction">\n+   <div id="molecule">\n+   </div>\n+   <form>\n+    Choose a pathway :\n+    <select id="selectbox">\n+     <option value="select">\n+      Select a pathway\n+     </option>\n+     <option value="rp_2">\n+      rp_2\n+     </option>\n+     <option value="rp_3">\n+      rp_3\n+     </option>\n+     <option value="rp_4">\n+      rp_4\n+     </option>\n+     <option value="rp_63">\n+      rp_63\n+     </option>\n+     <option value="rp_64">\n+      rp_64\n+     </option>\n+     <option value="rp_65">\n+      rp_65\n+     </option>\n+    </select>\n+   </form>\n+  </div>\n+ </body>\n+</html>\n'
b
diff -r 612a2f94522f -r dbc40b306014 rpVisualizer.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rpVisualizer.xml Thu Jun 13 08:56:51 2019 -0400
[
@@ -0,0 +1,25 @@
+<tool id="rpviz" name="rpVisualizer" version="0.1.0" python_template_version="3.5">
+    <description>Pathway visualizer</description>
+    <requirements>
+        <requirement type="package">python-libsbml</requirement>
+        <requirement type="package">networkx</requirement>
+        <requirement type="package">beautifulsoup4</requirement>
+        <requirement type="package">rdkit</requirement>
+    </requirements>
+    <command detect_errors="exit_code"><![CDATA[
+     git clone https://github.com/pablocarb/rpviz.git $__tool_directory__/rpviz;
+     cd $__tool_directory__/rpviz; git pull; cd ..;
+     cd $__tool_directory__;
+     echo `which python` > $__tool_directory__/info.log;
+     PYTHONPATH="$__tool_directory__" python $__tool_directory__/toolVisualizer.py $input1 $output1
+   ]]></command>
+    <inputs>
+        <param type="data" name="input1" format="xml" />
+    </inputs>
+    <outputs>
+        <data name="output1" format="html" from_work_dir="out.html" />
+    </outputs>
+    <help><![CDATA[
+        python3 toolVisualizer.py inputfile outputfile
+    ]]></help>
+</tool>
b
diff -r 612a2f94522f -r dbc40b306014 rpviz.xml
--- a/rpviz.xml Tue Jun 11 12:09:38 2019 -0400
+++ b/rpviz.xml Thu Jun 13 08:56:51 2019 -0400
[
@@ -1,25 +1,19 @@
-<tool id="rpviz" name="rpVisualizer" version="0.1.0" python_template_version="3.5">
+<tool id="rpviz" name="rpviz" version="0.1.0" python_template_version="3.5">
     <description>Pathway visualizer</description>
     <requirements>
-        <requirement type="package">python-libsbml</requirement>
-        <requirement type="package">networkx</requirement>
-        <requirement type="package">beautifulsoup4</requirement>
-        <requirement type="package">rdkit</requirement>
+        <requirement type="package">requests</requirement>
     </requirements>
     <command detect_errors="exit_code"><![CDATA[
-     git clone https://github.com/pablocarb/rpviz.git $__tool_directory__/rpviz;
-     cd $__tool_directory__/rpviz; git pull; cd ..;
-     cd $__tool_directory__;
-     echo `which python` > $__tool_directory__/info.log;
-     PYTHONPATH="$__tool_directory__" python $__tool_directory__/toolVisualizer.py $input1 $output1
+     python $__tool_directory__/toolRPViz.py $input1 $output1 -server $server
    ]]></command>
     <inputs>
         <param type="data" name="input1" format="xml" />
+     <param name="server" type="text" label="RPViz RES server" value="http://rpviz.synbiochem.co.uk/REST" help="RPviz REST server" />
     </inputs>
     <outputs>
         <data name="output1" format="html" from_work_dir="out.html" />
     </outputs>
     <help><![CDATA[
-        python3 toolVisualizer.py inputfile outputfile
+        python3 toolRPViz.py [server SERVER] inputfile outputfile
     ]]></help>
 </tool>
b
diff -r 612a2f94522f -r dbc40b306014 toolRPViz.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/toolRPViz.py Thu Jun 13 08:56:51 2019 -0400
[
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Mar 19
+
+@author: Pablo Carbonell
+@description: Query RPViz: pathway visualizer.
+
+"""
+import requests
+import argparse
+import csv
+import os
+import json
+
+def arguments():
+    parser = argparse.ArgumentParser(description='toolRPViz: Pathway visualizer. Pablo Carbonell, SYNBIOCHEM, 2019')
+    parser.add_argument('infile', 
+                        help='Pathways in SBML format.')
+    parser.add_argument('outfile', 
+                        help='HTML visualizer file.')
+    parser.add_argument('-server', default='http://rpviz.synbiochem.co.uk/REST',
+                        help='RPViz server.')
+    return parser
+
+def testApp(url):
+    r = requests.get( url )
+    res = json.loads( r.content.decode('utf-8') )
+    print( res )
+    
+def pathwayUpload(infile, outfile, url):
+    files = { 'file': open(infile, 'rb' ) }
+    r = requests.post( os.path.join(url, 'Query' ), files=files )
+    res = json.loads( r.content.decode('utf-8') )
+    html = res['data']['html']
+    with open(outfile, 'w') as h:
+        h.write(html)
+    print( 'Success!')
+
+def testHTML(f='outfile.html', outfile):
+    content = open(f).read()
+    with open(outfile, 'w') as h:
+        outfile.write(content)
+
+
+if __name__ == "__main__":
+    parser = arguments()
+    arg = parser.parse_args()
+    assert os.path.exists(arg.infile)
+    testHTML( 'outfile.html', arg.outfile )
+#    pathwayUpload( arg.infile, arg.outfile, arg.server )