Custom galaxy tool specifying working directory


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!



I was able to figure out the problem thanks to the following post:
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.




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:

bash '$__tool_directory__/ $input $output $param1 $param2

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" -input [inputfolder files] -param $3 -param2 $4 -outputfolder $outlocation"/outputfolder"
    zip -r -j $outlocation"/" $outlocation"/outputfolder"
    mv  $outlocation"/" $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.

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