Question: Naming output file according to input file
gravatar for Rob
2.8 years ago by
Rob50 wrote:


I currently develop a galaxy tool and I want to remove the extension from my input file. For example, if my input file is "myfile.bam", I want to return a file named "myfile.something".

I would like to do something like that :

<data name="output1" label="${input}.something"/>

But I don't know how to remove the .bam extension, just how to add other things after it.. How can I do that ?

tool dev galaxy • 1.5k views
ADD COMMENTlink modified 6 months ago by Thon deBoer20 • written 2.8 years ago by Rob50
If ${input} is a data parameter it will never have the .bam ending. It will have a .dat ending. Just set the format="sam" and Galaxy and all users will know it's a SAM file.
ADD REPLYlink written 2.8 years ago by Bjoern Gruening5.1k

Hi, thanks for your answer.

That the point. (you're right my example was wrong, sorry, I will correct that, but it show what I want to do) but by input file I mean the user file, witch is a .bam. And I want to rename my output file by myself, cause in fact the soft doesn't product an extension recognize by Galaxy, and so I can't use the format attribute.

So what I want is to take the input file name (smth.bam) remove the .bam extension and add something other (.aaa or what you want) for the output.

(I have updated my post a little bit cause it wasn't really explicit)

ADD REPLYlink modified 2.8 years ago • written 2.8 years ago by Rob50

The true command seem to be :

<data name="output1" label="${}.something">

It return myInputFile.bam.something, but it's not what I want, do you have an idea for remove the .bam ?

ADD REPLYlink written 2.8 years ago by Rob50

The data tag takes a format attribute. Then it doesn't matter what file extension the results happen to have.

ADD REPLYlink written 2.8 years ago by Devon Ryan1.9k

Okay, but the format attribute doesn't modify the output file name.

So I guess it's impossible to work on the name itself. Since my input file format is not recognized by Galaxy, I am then condemned to keep this extension in my output file name..

Thanks for your answers.

ADD REPLYlink written 2.8 years ago by Rob50
gravatar for Thon deBoer
6 months ago by
Thon deBoer20
Thon deBoer20 wrote:

It is possible to use python code in the labels, so this should work:

<data name="output1" label="${os.path.splitext(os.path.basename($[0]}.something">

You can't use the { } for the $, but you DO need it for the python code, but this will do what you want.

it will name your output file "myInputFile.something".

Adopted from

ADD COMMENTlink written 6 months ago by Thon deBoer20 often don't need the os.path.basename part. That is only needed if you ever pass it a full path (but it doesn't hurt and I just always use it)

ADD REPLYlink written 6 months ago by Thon deBoer20
Please log in to add an answer.


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