How should I store files using original file names and extensions when I upload them

tool-dev
object-store

#1

Hello,
I am developing a new galaxy tool using R as main programming language.

When I upload a number of txt files with the Upload tool in Get Data, I noticed that it stores the files in galaxy/database/files/000 directory and changes the file names from the originalname.txt into dataset_number .dat. How can I set up Upload tool in order to store the file with the originalname.txt format.

Thank you very much in advance for your help.


#2

This isn’t possible, Galaxy may store files in object stores that don’t resemble classical file systems.
The correct way is to reference files in your tool using $file.element_identifier.


#3

Thank you for your response.

My problem is that the R package I am using to develop the tool requires a set of filenames and a location of the files and it generates an ExpressionSet based on those files. If the filenames in the file directory are different from the original once I don’t know how to tell to the function what file to integrate.

Could you suggest me a solution?

Thank you


#4

You can symlink this in your command section to a known location. This is a very common pattern in Galaxy tools. So ln -s $file input1.tab or something like that, and then use input1.tab in your tool. If the name is important you can use ln -s '$file' '${re.sub('[^\w\-_]', '_', $file.element_identifier)'.tab


#5

Thank you mvdbeek,
I tried to add the command you suggested in the command tag of my tool.xml file and it works if I run it for one file. However, if I iterate the command to create a symlink for 4 files using a for statement the loop stucks. I did not find any example showing the application of loops in the command statement. That’s could be the cause?

This is my code:

<command>
for ( i=1; i<=4; i++ ); do
  ln -s '${ARRAY[$i]}' '${ARRAY[$i]}.element_identifier';
done
</command>

Thank you for your precious help


#6

The language in the <command/> tag is cheetah, there are many examples in the documentation, one is here.
The documentation is pretty dense, you might want to follow along the planemo tutorial first (https://planemo.readthedocs.io/en/latest/writing_standalone.html and specifically https://planemo.readthedocs.io/en/latest/writing_advanced.html#processing-lists-reductions)


#7

Thank you for your precious help!!!

I resolved the issue as follows:

<![CDATA[
#for $input in $LIST
ln -sf '$input' '$__tool_directory__/Symlink/${input.element_identifier}';
#end for

]]>

Have a nice day