Question: Having trouble passing outputs through a wrapper
0
gravatar for kramdi.a
4.5 years ago by
kramdi.a40
France
kramdi.a40 wrote:


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

 

outputs galaxy python wrapper • 1.5k views
ADD COMMENTlink modified 3.6 years ago by rlee0350 • written 4.5 years ago by kramdi.a40

Can you please give us a link to your Galaxy XML wrapper.

ADD REPLYlink written 4.5 years ago by Bjoern Gruening5.1k
0
gravatar for kramdi.a
4.5 years ago by
kramdi.a40
France
kramdi.a40 wrote:

I actually found what was wrong this morning, a silly inadvertence error when I copy the outputs. As you can see there are 5 shutil.move() calls when I only need to move 4 files (no more copy/paste..). Now the job completes successfully and I have access to all outputs in the history panel. 

However, the discordance is still there, it's not hurting the job, but I'm wondering what happened. Maybe because I deleted some of the older empty datasets ?

in /../file/000 I see : dataset_401/402/403/404/405 , in the history panel 400/401/402/403/404 and they all map. 

ADD COMMENTlink written 4.5 years ago by kramdi.a40
0
gravatar for rlee03
3.6 years ago by
rlee0350
United States
rlee0350 wrote:

How would you know which sys.argv[1] is mapped to   input_chip_file  etc...

ADD COMMENTlink written 3.6 years ago by rlee0350
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 165 users visited in the last hour