Hello,
I am trying to integrated a developed tool into Galaxy. I have to write a wrapper (I chose python) because the line command of my tool does not specify the outputs.
-A few remarks:
*I run a single user Galaxy instance (default install)
* my tool generates 4 outputs + 1 log file. You can see below the command line tag and the wrapper.py I use.
The job is not going right, here's what's happening after executing the tool:
- I can see 5 dataset_XXX getting generated in the default database/file/000, however, I noticed there was a discordance in the the number (_XXX) attached compared to what I see in Galaxy History, I don't know why.
- The task completes with an error generated from the wrapper.py as if the process called (my tool) failed, but when I go look into the in database/file/000, all the generated files are empty except for the logging file which looks as if the tool completed the task...Where did the tool's outputs go ?
The problem seems to be in the capture of outputs by Galaxy. I am actually having a hard time understanding the communication between the tool and Galaxy when it comes to outputs passed through a wrapper.
Here's my wrapper.py,
Any remarques would be appreciated.
Thank you
-----------
<command interpreter="python">tool_wrapper.py '$input_chip_file' '$input_control_file' '$config_file' '$project_name' '$output_peaks_file' '$output_regions_file' '$output_density_file' '$output_proba_file' '$log_report'</command>
-------------- wrapper.py-----------
#!/usr/bin/env python
import sys, subprocess, tempfile, os, shutil
if __name__ == "__main__":
input_chip_file = sys.argv[1]
input_control_file = sys.argv[2]
config_file = sys.argv[3]
project_name = sys.argv[4]
output_peaks_file = sys.argv[5]
output_regions_file = sys.argv[6]
output_density_file = sys.argv[7]
output_proba_file = sys.argv[8]
log_report = sys.argv[9]
TOOL_BINARY="/home/.../../tool_binary"
#create tmp dir:
tmp_dir=tempfile.mkdtemp()
try:
#call
proc=subprocess.Popen(args= "%s %s > %s" % (TOOL_BINARY, " ".join([input_chip_file, input_control_file, config_file , project_name]), log_report ), shell=True, cwd=tmp_dir)
#check process
returncode = proc.wait()
if returncode :
raise Exception
#deal with outputs
shutil.move( os.path.join(tmp_dir, "%s_peaks.bed" % project_name) ,output_peaks_file )
shutil.move( os.path.join( tmp_dir, "%s_regions.bed" % project_name ) ,output_regions_file )
shutil.move( os.path.join( tmp_dir, "%s_density.bed" % project_name ) ,output_density_file )
shutil.move( os.path.join( tmp_dir, "%s_proba.bed" % project_name ) ,output_proba_file )
shutil.move( os.path.join( tmp_dir, "%s.bed" % project_name ) ,output_density_file )
#handle Exception
except Exception:
sys.stderr.write ("Error while runing TOOL\n")
shutil.rmtree(tmp_dir)
raise Exception
shutil.rmtree(tmp_dir) #clean up working dir
Can you please give us a link to your Galaxy XML wrapper.