diff --git a/tools.yml b/tools.yml index a91527e..5d5c5ae 100644 --- a/tools.yml +++ b/tools.yml @@ -214,13 +214,55 @@ tools: cores: 6 mem: 24 toolshed.g2.bx.psu.edu/repos/bgruening/hifiasm/hifiasm/.*: - cores: 20 - mem: 120 + cores: 10 rules: - - id: tpvdb_hifiasm_small_input_rule - if: input_size <= 0.2 - cores: 6 - mem: 40 + - id: tpvdb_hifiasm_expert_memory_rule + # The memory requirement of Hifiasm depends on the "Estimated haploid genome size" (hg_size). + # If hg_size is set, and it can be calculated automatically, then we can fit memory more efficiently. + # This is done for example in the VGP workflows. + if: | + parameters = {p.name: p.value for p in job.parameters} + parameters = tool.params_from_strings(parameters, app) + + advanced_options = parameters.get("advanced_options", dict()) + hg_size = advanced_options.get("hg_size", "") + + bool(hg_size) + mem: | + from math import ceil + + parameters = {p.name: p.value for p in job.parameters} + parameters = tool.params_from_strings(parameters, app) + + advanced_options = parameters.get("advanced_options", dict()) + + kcov_default = 36 + kcov = advanced_options.get("kcov", kcov_default) + + hg_size = advanced_options.get("hg_size", "") + + value = 0 + if hg_size: + conversion_factors = { + "k": 1000000, + "M": 1000, + "G": 1, + } + conversion_factors = { + key.lower(): value for key, value in conversion_factors.items() + } + suffix = hg_size[-1:].lower() + value = hg_size[:len(hg_size) - 1] + value = value.replace(",", ".") + value = float(value) + # compute hg size in Gb + value = value / conversion_factors[suffix.lower()] + value = ceil(value * (kcov * 2) * 1.75) + + # return the amount of memory needed + value + + toolshed.g2.bx.psu.edu/repos/bgruening/infernal/infernal_cmbuild/.*: cores: 10 mem: 20