Previous changeset 26:fbf2e5072b32 (2019-07-05) Next changeset 28:501f39987c9b (2019-08-02) |
Commit message:
planemo upload commit 708fd9f837af7425a8986c336aab18cec7ff5b05 |
modified:
rpviz.xml toolRPViz.py |
b |
diff -r fbf2e5072b32 -r b30e3e5ee8f8 rpviz.xml --- a/rpviz.xml Fri Jul 05 17:29:50 2019 -0400 +++ b/rpviz.xml Fri Aug 02 05:17:33 2019 -0400 |
[ |
@@ -7,13 +7,18 @@ python $__tool_directory__/toolRPViz.py $input1 $output1 -server $server ]]></command> <inputs> - <param type="data" name="input1" format="xml" /> + <param type="data" name="input1" format="tar" label="Input pathways"/> + <param name="input2" type="text" value="sbml" label="Input format"> + <option value="sbml">sbml</option> + <option value="csv">CSV</option> + </param> + <param name="input3" type="boolean" truevalue="Y" falsevalue="N" checked="false" label="Retrieve Selenzyme information" /> <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 toolRPViz.py [server SERVER] inputfile outputfile + python3 toolRPViz.py [server SERVER] inputfile outputfile --input_format $input2 --selenzyme_table --outfolder $outputfile.extra_files_path ]]></help> </tool> |
b |
diff -r fbf2e5072b32 -r b30e3e5ee8f8 toolRPViz.py --- a/toolRPViz.py Fri Jul 05 17:29:50 2019 -0400 +++ b/toolRPViz.py Fri Aug 02 05:17:33 2019 -0400 |
[ |
@@ -12,6 +12,7 @@ import csv import os import json +import tarfile def arguments(): parser = argparse.ArgumentParser(description='toolRPViz: Pathway visualizer. Pablo Carbonell, SYNBIOCHEM, 2019') @@ -19,6 +20,15 @@ help='Pathways in SBML format.') parser.add_argument('outfile', help='HTML visualizer file.') + parser.add_argument('--input_format', default='sbml', + help='Input format: sbml|json') + parser.add_argument('--choice', default="5", + help='What kind of output do you want ? \n 1/Single HTML file \n 2/Separated HTML files \n 3/View directly in Cytoscape \n 4/Generate a file readable in Cytoscape \n 5/Tar file') + parser.add_argument('--selenzyme_table', + default="N", + help='Do you want to display the selenzyme information ? Y/N') + parser.add_argument('--outfolder', + help='Location of additional files') parser.add_argument('-server', default='http://rpviz.synbiochem.co.uk/REST', help='RPViz server.') return parser @@ -28,18 +38,27 @@ 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 pathwayUpload( arg ): + files = { 'file': open(arg.infile, 'rb' ) } + data = {'selenzyme_table': arg.selenzyme_table, 'input_format': arg.input_format} + 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): + os.mkdir(arg.outfolder) + outtar = os.path.join( arg.outfolder, 'out.tar' ) + open(outtar,'wb').write( r.content ) + print( 'Response successfully received' ) + tar = tarfile.open(outtar) + tar.extractall(path=arg.outfolder) + html = os.path.join( arg.outfolder, 'index.html' ) + shutil.cp( html, arg.outfile ) + print( 'Files extracted' ) if __name__ == "__main__": parser = arguments() arg = parser.parse_args() - assert os.path.exists(arg.infile) - pathwayUpload( arg.infile, arg.outfile, arg.server ) + assert os.path.exists( arg.infile ) + pathwayUpload( arg ) |