Impossible to set --max-memory for Trimmomatic

Kneaddata v.0.12.4
I am trying to use Kneaddata’s --max-memory flag for Trimmomatic, to avoid Java heap space errors for large fastq files (with threads set to 16, I got this error for a 9GB fastq.gz file).

I found that in order for the --max-memory flag to work, one must set the --trimmomatic PATH flag to the .jar file. However, when I set the path to something like “~/miniforge3/envs/Shotgun_shortread_env_NXXX_TEST_NAME/share/trimmomatic/trimmomatic.jar” I got an “Unable to list files in trimmomatic directory:” error. It turns out this comes from the find_dependency() function, in which it tries to list the files in path_provided - which obviously fails, because “trimmomatic.jar” is not a directory. But if I instead give the directory, the function finds both “trimmomatic” and “trimmomatic.jar”, because “trimmomatic_jar=“trimmomatic*”” in config.py, which unreliably selects the former instead of the latter.

EDIT: I originally said this was run due to bypass-trf. That was me misreading, so I have edited the post

EDIT2: For those having the same issue, a workaround is to set the Java option as an environment variable before running Kneaddata, e.g.:
export _JAVA_OPTIONS=“-Xmx{round(memory*0.75)}g”
(note, Trimmomatic specifically expects “_JAVA_OPTIONS”)

1 Like