changeset 29:d854b21ada0c draft

planemo upload commit c56eddc745b70354680c2a2b605840ed72bb98ef
author pablocarb
date Wed, 07 Aug 2019 05:13:27 -0400
parents 501f39987c9b
children 0ad6fda90f41
files README.md rpVisualizer.xml rpviz.xml toolRPViz.py toolVisualizer.py
diffstat 5 files changed, 19 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/README.md	Fri Aug 02 05:27:32 2019 -0400
+++ b/README.md	Wed Aug 07 05:13:27 2019 -0400
@@ -36,4 +36,13 @@
 - [x] Use planemo in order to create a repository in the toolshed.
 - [x] Register in the toolshed.
 - [x] Install in the Galaxy container from the toolshed.
-- [ ] Write documentiation about the design specifications sheet.
\ No newline at end of file
+- [ ] Write documentiation about the design specifications sheet.
+
+## galaxy_RPViz
+
+A tool to visualize pathways by querying an RPViz server.
+
+`RPViz` returns an interactive HTML file that requires javascript. The `RPViz` tool has to be included in the [Galaxy whitelist](https://docs.galaxyproject.org/en/latest/admin/config.html).
+
+
+
--- a/rpVisualizer.xml	Fri Aug 02 05:27:32 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-<tool id="rpviz2" 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>
--- a/rpviz.xml	Fri Aug 02 05:27:32 2019 -0400
+++ b/rpviz.xml	Wed Aug 07 05:13:27 2019 -0400
@@ -4,7 +4,7 @@
         <requirement type="package">requests</requirement>
     </requirements>
     <command detect_errors="exit_code"><![CDATA[
-     python $__tool_directory__/toolRPViz.py $input1 $output1 -server $server
+     python $__tool_directory__/toolRPViz.py $input1 $output1 -server $server --input_format $input2 --selenzyme_table $input3 --outfolder $output1.extra_files_path
    ]]></command>
     <inputs>
         <param type="data" name="input1" format="tar" label="Input pathways"/>
@@ -19,6 +19,6 @@
         <data name="output1" format="html" from_work_dir="out.html" />
     </outputs>
     <help><![CDATA[
-        python3 toolRPViz.py [server SERVER] inputfile outputfile --input_format $input2 --selenzyme_table  --outfolder $outputfile.extra_files_path
+        RPViz tool.
     ]]></help>
 </tool>
--- a/toolRPViz.py	Fri Aug 02 05:27:32 2019 -0400
+++ b/toolRPViz.py	Wed Aug 07 05:13:27 2019 -0400
@@ -13,6 +13,7 @@
 import os
 import json
 import tarfile
+import shutil
 
 def arguments():
     parser = argparse.ArgumentParser(description='toolRPViz: Pathway visualizer. Pablo Carbonell, SYNBIOCHEM, 2019')
@@ -39,13 +40,13 @@
     print( res )
     
 def pathwayUpload( arg ):
-    files = { 'file': open(arg.infile, 'rb' ) }
+    # Post request
     data = {'selenzyme_table': arg.selenzyme_table, 'input_format': arg.input_format}
+    files = { 'file': open(arg.infile, 'rb' ), 'data': ('data.json', json.dumps(data)) }
     print('Sending query to '+arg.server)
-    r=requests.post( arg.server+'/Query',files=files,data=data )
-    if arg.outfolder is None:
-        arg.outfolder = os.path.dirname( arg.outfile )
-    if not os.path.exists(outfolder):
+    r=requests.post(arg.server+'/Query',files=files)
+    # Read response
+    if not os.path.exists(arg.outfolder):
         os.mkdir(arg.outfolder)
     outtar = os.path.join( arg.outfolder, 'out.tar' )
     open(outtar,'wb').write( r.content )
@@ -53,7 +54,7 @@
     tar = tarfile.open(outtar)
     tar.extractall(path=arg.outfolder)
     html = os.path.join( arg.outfolder, 'index.html' )
-    shutil.cp( html, arg.outfile )  
+    shutil.copy( html, arg.outfile )  
     print( 'Files extracted' )
 
 
--- a/toolVisualizer.py	Fri Aug 02 05:27:32 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""
-Created on Mar 19
-
-@author: Pablo Carbonell
-@description: Pathway visualizer.
-
-"""
-import argparse
-import os
-from rpviz.main import run
-
-def arguments():
-    parser = argparse.ArgumentParser(description='toolVisualizer: Pathway visualizer. Pablo Carbonell, SYNBIOCHEM, 2019')
-    parser.add_argument('infile', 
-                        help='Input SBML pathway file.')
-    parser.add_argument('outfile', 
-                        help='Output HTML file.')
-    return parser
-    
-def runVisualizer( infile, outfile ):
-    run(infile,outfile)
-
-
-
-if __name__ == "__main__":
-    parser = arguments()
-    arg = parser.parse_args()
-    assert os.path.exists(arg.infile)
-    runVisualizer( arg.infile, arg.outfile )