Create a plugin for trimmomatic using GenericKnimeNodes

Hallo,
I want to create a plugin using GenericKnimeNodes for trimmomatic. Trimmomatic is a java based tool. As far as I know I need a bash script to make it executable. I’m new in this field and I don’t know how I can make an executable bash script. What should I write there. Please help me. Some suggestions or example

Hi,
to run trimmomatic from a shell script, you simply put the trimmomatic command in it and pass the parameters. On Linux, for example, you could create a script called trimmomatic.sh and put the following content inside: java -jar trimmomatic-0.35.jar "$@"
The “$@” means that all the arguments given to the shell script are passed to trimmomatic. Then you need to create a CTD file for your shell script and generate the nodes using GKN. For Windows you need to create a corresponding bat file, I think.

1 Like

@AlexanderFillbrunn
Thank you very much. Could you tell also how I can adjust it to parameters. I mean, I get parameters from cmd.file separated by a space but there should be a colon (":") between parameter and parametervalue in trimmomatic execution command. How can I formulate it by bash script

Hi,
what is the cmd file? Where does that come from? To replace spaces with colons in the parameters, you could use SED. But I am not sure how you can ensure that only the relevant spaces are replaced and not all of them.

@AlexanderFillbrunn
sorry, I mean with cmd CTD-file actually
Thank you.There are only colons between parameter and parameter value. I’ll try with SED

Hi @Natala

unfortunately you are right that the currently implemented default CommandGenerator, that creates
the command line from the CTD file, always separates option ("-xyz") and parameter value by
a whitespace. For such special command line tools like trimmomatic, you indeed have to either
write a little bash/bat script wrapper (as already mentioned), or you have to implement an own
CommandGenerator (which requires some more work I would assume).

@jpfeuffer thanks

If the tool is written in java, might it be easier to write a node to use the java api directly rather than going through an intermediate shell command of some sort?

Steve

@s.roughley what do you mean with java api?

Please, can you give me an example how is shell script to write in order to make jar file with passed parameters. Or can you tell me how I can create Knime Node from jarfile (special: trimmomatic)? Because I have no idea how to write a shell script and how to include it and jar file to payload using GenericKnimeNodes

@s.roughley I agree that it would be the much cleaner solution. However, I might not necessarily be “easier”, depending on your knowledge with KNIME intrinsics. You still have to design the parameter dialog and the logic to communicate with the model. Plus the skeletons of plugin and feature etc.

@Natala If you still want to pursue the command line execution, just write an own little command line script yourself you can just adapt one of the suggestions here and translate simple options to the weird options from that tool. However, of course you will have to represent every possible combination of “Step” and “Filter” as an own option.
E.g. “-ILLUMINACLIP:fastaWithAdaptersEtc” , “-ILLUMINACLIP:seedMismatches”, “-ILLUMINACLIP:palindromeClipThreshold” … and so on

@jpfeuffer Thanks a lot. Your tips are very helpful

@Natala - what I mean was the the tool is written in Java, as is KNIME. You can see the source code at https://github.com/timflutre/trimmomatic/ So, it would take some work, as @jpfeuffer has said, including some knowledge of both Java in general and writing KNIME nodes in particular, but then timmomatic is being run within KNIME, in the same java virtual machine, rather that transferring data and commands to a new process via a system command such as you would run at a command prompt.

Steve

2 Likes