Custom galaxy tool specifying working directory

Hello,

I am trying to write a galaxy custom tool who’s command calls a script that requires an output directory (I cannot change that unfortunately). Then the script outputs a bunch of files in that directory with predictable numbers and names. I can set the “outputs” “data_format=‘directory’” and everything executes but the results are empty.

Things I have tried:

  1. Specifying to the script to write the files in the current executing directory --> FileNotFound
  2. Specifying a set location --> FileNotFound
  3. discovered_datasets within the "data fomat=“directory” --> empty results

All help would be greatly appreciated!

Thanks

EDIT:

I was able to figure out the problem thanks to the following post: https://biostar.usegalaxy.org/p/1965/.
The trouble is that Galaxy sends .dat files and that my script uses the extension to check that the input filetype is correct. I solved it by creating a symbolic link to the input files with the correct extensions in the command before the main call:

ln -s inputFile.dat toPassFile.csv &&

However I have now come across another problem. I need to put that file in a docker, and symbolic link in a container is not supported in docker (as far as I know). To solve this I crate a dummy function that reads the .dat files and writes them to CSV inside the docker.

I hope that this solves someones else’s problem.

Cheers

2 Likes

Hello,

What you can do is make use of bash, zip (optional) and temporary folders and upload a zip file.
So you start your script like something like this:

<command>
<![CDATA[
bash '$__tool_directory__/yourbashwrapperscript.sh $input $output $param1 $param2
]]>
</command>

The bash wrapper (with zip) looks something like this:

    outlocation=$(mktemp -d your_path/galaxy/database/XXXXXX)
    mkdir $outlocation"/outputfolder"
    mkdir $outlocation"/inputfolder"
    unzip $1 -d $outlocation"/inputfolder" 
    mytool.py -input [inputfolder files] -param $3 -param2 $4 -outputfolder $outlocation"/outputfolder"
    zip -r -j $outlocation"/output.zip" $outlocation"/outputfolder"
    mv  $outlocation"/output.zip" $2
    rm -rf $outlocation

You can also just move all the output files to galaxy instead of zipping it. To do this you need more
mv commands and output locations in your xml. I have a tool where I can choose my output files with the help of a boolean parameter and a output filter. You can find it in the manual and if necessarily I can explain it but it is out of the scope of your question :blush:
You can not literally copy paste this code, it is just for inspiration.

EDIT:
Forgot the docker part. You can mount the tempfolder in your docker.

2 Likes