Question: Python outputs empty on history
0
gravatar for luciaaheitor
3 months ago by
luciaaheitor20
luciaaheitor20 wrote:

Hello!

So I have a python script that I'm integrated in my local galaxy and it outputs 2 files: one pdf created with pdflatex and one csv file. This code works perfectly on the command line, on galaxy the code finishes successfully but the outputs are empty.

Command on the xml:

<command detect_errors="exit_code"><![CDATA[
    python '$__tool_directory__/LungCARD_report.py' "$patientID" "$sampleID" "$birthday" "$gender" "$labKit" "$sequencer" "$vcf_file" "$idxstats" "$flagstat" "$fastq1" "$fastq2"
]]></command>

Writting of the pdf file:

with open(filename, 'w') as f:
    f.write(content)

#outputs the report as latex
commandLine = subprocess.Popen(['pdflatex', filename])
commandLine.communicate()

os.unlink(filename)
os.unlink(filename[:-4] + '.log')
os.unlink(filename[:-4] + '.aux')

Writting of the csv file:

vcf.getVCF().to_csv(filename)

Planemo wrote the outputs tag as:

<outputs>
<data name="output1" format="pdf" from_work_dir="report.pdf" />
<data name="output2" format="csv" from_work_dir="unknown_variants.csv" />
</outputs>

Please help me get the outputs to the history in galaxy! Thanks!

ADD COMMENTlink written 3 months ago by luciaaheitor20

I never used "from_work_dir" so not sure about that. Maybe it needs to be the full path.

I would use $output1 as parameter for the python script. So:

python '$__tool_directory__/LungCARD_report.py' "$patientID" "$sampleID" "$birthday" "$gender" "$labKit" "$sequencer" "$vcf_file" "$idxstats" "$flagstat" "$fastq1" "$fastq2" $output1 $output2

In the python script I write the result to the $output1 parameter

ADD REPLYlink written 3 months ago by gb60

I changed the xml as you suggested and the result is the same.

In the python script I write the result to the $output1 parameter

How do you do that? I think the problem might be from my script but even after researching about it I was still unaware of what to do..

ADD REPLYlink modified 3 months ago • written 3 months ago by luciaaheitor20
0
gravatar for gb
3 months ago by
gb60
gb60 wrote:

So you pass the variable $output1 from the xml file into your python script. The variable $output1 is basically just a path, a output location.

So for example this:

with open(filename, 'w') as f:
f.write(content)

The filename should be the $output1 value.

ADD COMMENTlink written 3 months ago by gb60

Thank you! Thanks to your explanation I figured out what I was doing wrong.

The problem was that galaxy was looking for the "report.pdf" and "unknown_variants.csv" and the script was giving them other file names. After changing this everything worked out fine!

Thank you once again for the patience :)

ADD REPLYlink written 3 months ago by luciaaheitor20
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: 168 users visited in the last hour