|
| 1 | +process ONSITE { |
| 2 | + tag "$meta.mzml_id" |
| 3 | + label 'process_medium' |
| 4 | + label 'openms' |
| 5 | + |
| 6 | + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? |
| 7 | + 'https://depot.galaxyproject.org/singularity/pyonsite:0.0.2--pyhdfd78af_0' : |
| 8 | + 'quay.io/biocontainers/pyonsite:0.0.2--pyhdfd78af_0' }" |
| 9 | + |
| 10 | + input: |
| 11 | + tuple val(meta), path(mzml_file), path(id_file) |
| 12 | + |
| 13 | + output: |
| 14 | + tuple val(meta), path("${id_file.baseName}_onsite_*.idXML"), emit: ptm_in_id_onsite |
| 15 | + path "versions.yml", emit: versions |
| 16 | + path "*.log", emit: log |
| 17 | + |
| 18 | + script: |
| 19 | + def args = task.ext.args ?: '' |
| 20 | + def prefix = task.ext.prefix ?: "${meta.mzml_id}" |
| 21 | + |
| 22 | + // Select algorithm (ascore, phosphors, or lucxor) |
| 23 | + def algorithm = params.onsite_algorithm ?: 'lucxor' |
| 24 | + |
| 25 | + // Basic parameters |
| 26 | + def fragment_tolerance = params.onsite_fragment_tolerance ?: 0.5 |
| 27 | + def fragment_units = params.onsite_fragment_error_units ?: 'Da' |
| 28 | + def threads = params.onsite_threads ?: task.cpus |
| 29 | + def add_decoys = params.onsite_add_decoys ?: false |
| 30 | + def min_psms = params.onsite_min_psms ?: 5 |
| 31 | + def disable_split_by_charge = params.onsite_disable_split_by_charge ?: false |
| 32 | + def compute_all_scores = params.onsite_compute_all_scores != null ? params.onsite_compute_all_scores : true |
| 33 | + |
| 34 | + // Algorithm-specific parameters |
| 35 | + def fragment_method = params.onsite_fragment_method ?: meta.dissociationmethod |
| 36 | + def neutral_losses = params.onsite_neutral_losses ? "--neutral-losses ${params.onsite_neutral_losses}" : "" |
| 37 | + def decoy_mass = params.onsite_decoy_mass ? "--decoy-mass ${params.onsite_decoy_mass}" : "" |
| 38 | + def decoy_losses = params.onsite_decoy_neutral_losses ? "--decoy-neutral-losses ${params.onsite_decoy_neutral_losses}" : "" |
| 39 | + def min_psms_param = "--min-num-psms-model ${min_psms}" |
| 40 | + |
| 41 | + // Debug options - onsite only accepts --debug flag without value |
| 42 | + def debug = params.onsite_debug ? "--debug" : "" |
| 43 | + |
| 44 | + // Build algorithm-specific parameter strings |
| 45 | + def tolerance_param = "" |
| 46 | + def method_param = "" |
| 47 | + def algorithm_specific_params = "" |
| 48 | + def decoy_param = "" |
| 49 | + |
| 50 | + if (algorithm == 'lucxor') { |
| 51 | + // LucXor uses --fragment-error-units and --fragment-method |
| 52 | + tolerance_param = "--fragment-error-units ${fragment_units}" |
| 53 | + method_param = fragment_method ? "--fragment-method ${fragment_method}" : "" |
| 54 | + algorithm_specific_params = "${neutral_losses} ${decoy_mass} ${decoy_losses} ${min_psms_param}" |
| 55 | + |
| 56 | + // Add LucXor-specific parameters |
| 57 | + // Note: disable_split_by_charge is only supported by LucXor |
| 58 | + if (disable_split_by_charge) { |
| 59 | + algorithm_specific_params += " --disable-split-by-charge" |
| 60 | + } |
| 61 | + if (compute_all_scores) { |
| 62 | + algorithm_specific_params += " --compute-all-scores" |
| 63 | + } |
| 64 | + |
| 65 | + // LucXor uses --target-modifications |
| 66 | + // Build target modifications list from params.mod_localization |
| 67 | + if (params.mod_localization) { |
| 68 | + def target_mods = params.mod_localization.tokenize(',').collect { it.trim() } |
| 69 | + |
| 70 | + // Add decoy modification if enabled |
| 71 | + if (add_decoys) { |
| 72 | + target_mods.add('PhosphoDecoy(A)') |
| 73 | + } |
| 74 | + |
| 75 | + // Format as command line arguments |
| 76 | + decoy_param = "--target-modifications '${target_mods.join(',')}'" |
| 77 | + } else if (add_decoys) { |
| 78 | + // If no mod_localization specified but decoys enabled, use default with decoy |
| 79 | + decoy_param = "--target-modifications 'Phospho(S),Phospho(T),Phospho(Y),PhosphoDecoy(A)'" |
| 80 | + } |
| 81 | + } else { |
| 82 | + // AScore and PhosphoRS use --fragment-mass-unit |
| 83 | + tolerance_param = "--fragment-mass-unit ${fragment_units}" |
| 84 | + method_param = "" |
| 85 | + algorithm_specific_params = "" |
| 86 | + |
| 87 | + // Add compute_all_scores parameter for AScore and PhosphoRS |
| 88 | + // Note: disable_split_by_charge is LucXor-specific and not used here |
| 89 | + if (compute_all_scores) { |
| 90 | + algorithm_specific_params += " --compute-all-scores" |
| 91 | + } |
| 92 | + |
| 93 | + // AScore and PhosphoRS use --add-decoys flag |
| 94 | + if (add_decoys) { |
| 95 | + decoy_param = "--add-decoys" |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + """ |
| 100 | + onsite ${algorithm} \\ |
| 101 | + -in ${mzml_file} \\ |
| 102 | + -id ${id_file} \\ |
| 103 | + -out ${id_file.baseName}_onsite_${algorithm}.idXML \\ |
| 104 | + --fragment-mass-tolerance ${fragment_tolerance} \\ |
| 105 | + ${tolerance_param} \\ |
| 106 | + --threads ${threads} \\ |
| 107 | + ${method_param} \\ |
| 108 | + ${decoy_param} \\ |
| 109 | + ${algorithm_specific_params} \\ |
| 110 | + ${debug} \\ |
| 111 | + 2>&1 | tee ${id_file.baseName}_onsite_${algorithm}.log |
| 112 | +
|
| 113 | + cat <<-END_VERSIONS > versions.yml |
| 114 | + "${task.process}": |
| 115 | + onsite: \$(onsite --version 2>&1 | grep -oP 'version \\K[0-9.]+' || echo "0.0.1") |
| 116 | + END_VERSIONS |
| 117 | + """ |
| 118 | +} |
0 commit comments