|
| 1 | +import sys |
| 2 | + |
1 | 3 | def get_java_opts(snakemake):
|
2 | 4 | """Obtain java_opts from params, and handle resource definitions in resources."""
|
3 | 5 |
|
4 | 6 | java_opts = snakemake.params.get("java_opts", "")
|
5 | 7 | # Getting memory in megabytes, if java opts is not filled with -Xmx parameter
|
6 | 8 | # By doing so, backward compatibility is preserved
|
7 |
| - if "mem_mb" in snakemake.resources.keys() and not "-Xmx" in java_opts: |
| 9 | + if "mem_mb" in snakemake.resources.keys(): |
| 10 | + if "-Xmx" in java_opts: |
| 11 | + sys.exit("You have specified resources.mem_mb and provided `-Xmx` in params.java_opts. For Java memory specifications, please only use resources.mem_mb.") |
| 12 | + if "-Xmx" in extra: |
| 13 | + sys.exit("You have specified resources.mem_mb and provided `-Xmx` in params.extra. For Java memory specifications, please only use resources.mem_mb.") |
8 | 14 | java_opts += " -Xmx{}M".format(snakemake.resources["mem_mb"])
|
9 | 15 |
|
10 | 16 | # Getting memory in gigabytes, for user convenience. Please prefer the use
|
11 | 17 | # of mem_mb over mem_gb as advised in documentation.
|
12 |
| - elif "mem_gb" in snakemake.resources.keys() and not "-Xmx" in java_opts: |
| 18 | + elif "mem_gb" in snakemake.resources.keys(): |
| 19 | + if "-Xmx" in java_opts: |
| 20 | + sys.exit("You have specified resources.mem_gb and provided `-Xmx` in params.java_opts. For Java memory specifications, please only use resources.mem_mb.") |
| 21 | + if "-Xmx" in extra: |
| 22 | + sys.exit("You have specified resources.mem_gb and provided `-Xmx` in params.extra. For Java memory specifications, please only use resources.mem_mb.") |
13 | 23 | java_opts += " -Xmx{}G".format(snakemake.resources["mem_gb"])
|
14 | 24 |
|
15 | 25 | # Getting java temp directory from output files list, if -Djava.io.tmpdir
|
16 | 26 | # is not provided in java parameters. By doing so, backward compatibility is
|
17 | 27 | # not broken.
|
18 |
| - if "java_temp" in snakemake.output.keys() and not "-Djava.io.tmpdir" in java_opts: |
| 28 | + if "java_temp" in snakemake.output.keys(): |
| 29 | + if "-Djava.io.tmpdir" in java_opts: |
| 30 | + sys.exit("You have specified output.java_temp and provided `-Djava.io.tmpdir` in params.java_opts. Please choose the one you intended and remove the other specification.") |
19 | 31 | java_opts += " -Djava.io.tmpdir={}".format(snakemake.output["java_temp"])
|
20 | 32 |
|
21 | 33 | return java_opts
|
0 commit comments