forked from bigbio/quantms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
119 lines (108 loc) · 4.87 KB
/
Copy pathmain.nf
File metadata and controls
119 lines (108 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
process COMET {
tag "$meta.mzml_id"
label 'process_medium'
label 'openms'
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'oras://ghcr.io/bigbio/openms-tools-thirdparty-sif:2026.07.02' :
'ghcr.io/bigbio/openms-tools-thirdparty:2026.07.02' }"
input:
tuple val(meta), path(mzml_file), path(database)
output:
tuple val(meta), path("${mzml_file.baseName}_comet.idparquet"), emit: id_files_comet
path "versions.yml", emit: versions
path "*.log", emit: log
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.mzml_id}"
if (meta.fragmentmasstoleranceunit == "ppm") {
// Note: This uses an arbitrary rule to decide if it was hi-res or low-res
// and uses Comet's defaults for bin size, in case unsupported unit "ppm" was given.
if (meta.fragmentmasstolerance.toDouble() < 50) {
bin_tol = 0.015
bin_offset = 0.0
inst = params.instrument ?: "high_res"
} else {
bin_tol = 0.50025
bin_offset = 0.4
inst = params.instrument ?: "low_res"
}
log.warn "The chosen search engine Comet does not support ppm fragment tolerances. We guessed a " + inst +
" instrument and set the fragment_bin_tolerance to " + bin_tol
} else {
// TODO expose the fragment_bin_offset parameter of comet
bin_tol = meta.fragmentmasstolerance.toDouble()
bin_offset = bin_tol <= 0.05 ? 0.0 : 0.4
if (!params.instrument)
{
inst = bin_tol <= 0.05 ? "high_res" : "low_res"
} else {
inst = params.instrument
}
}
def isoSlashComet = "0/1"
if (params.isotope_error_range) {
def isoRangeComet = params.isotope_error_range.split(",")
def range = (isoRangeComet[0].toInteger()..isoRangeComet[1].toInteger()-1).collect { v -> v.toString() }
range.add(isoRangeComet[1])
isoSlashComet = range.join("/")
}
// for consensusID the cutting rules need to be the same. So we adapt to the loosest rules from MSGF
// TODO find another solution. In ProteomicsLFQ we re-run PeptideIndexer (remove??) and if we
// e.g. add XTandem, after running ConsensusID it will lose the auto-detection ability for the
// XTandem specific rules.
enzyme = meta.enzyme
if (params.search_engines.contains("msgf")){
if (meta.enzyme == "Trypsin") enzyme = "Trypsin/P"
else if (meta.enzyme == "Arg-C") enzyme = "Arg-C/P"
else if (meta.enzyme == "Asp-N") enzyme = "Arg-N/B"
else if (meta.enzyme == "Chymotrypsin") enzyme = "Chymotrypsin/P"
else if (meta.enzyme == "Lys-C") enzyme = "Lys-C/P"
}
num_enzyme_termini = ""
if (meta.enzyme == "unspecific cleavage")
{
num_enzyme_termini = "none"
}
else if (params.num_enzyme_termini == "fully")
{
num_enzyme_termini = "full"
}
il_equiv = params.IL_equivalent ? "-PeptideIndexing:IL_equivalent" : ""
met_excision = params.met_excision ? "-clip_nterm_methionine true" : ""
"""
CometAdapter \\
-in ${mzml_file} \\
-out ${mzml_file.baseName}_comet.idparquet \\
-threads $task.cpus \\
-database "${database}" \\
-instrument ${inst} \\
-missed_cleavages $params.allowed_missed_cleavages \\
-min_peptide_length $params.min_peptide_length \\
-max_peptide_length $params.max_peptide_length \\
-num_hits $params.num_hits \\
-num_enzyme_termini $params.num_enzyme_termini \\
-enzyme "${enzyme}" \\
-isotope_error ${isoSlashComet} \\
-precursor_charge $params.min_precursor_charge:$params.max_precursor_charge \\
-fixed_modifications ${meta.fixedmodifications.tokenize(',').collect { mod -> "'$mod'" }.join(" ") } \\
-variable_modifications ${meta.variablemodifications.tokenize(',').collect { mod -> "'$mod'" }.join(" ") } \\
-max_variable_mods_in_peptide $params.max_mods \\
-precursor_mass_tolerance $meta.precursormasstolerance \\
-precursor_error_units $meta.precursormasstoleranceunit \\
-fragment_mass_tolerance ${bin_tol} \\
-fragment_bin_offset ${bin_offset} \\
-minimum_peaks $params.min_peaks \\
${met_excision} \\
${il_equiv} \\
-PeptideIndexing:unmatched_action ${params.unmatched_action} \\
-debug $params.db_debug \\
-force \\
$args \\
2>&1 | tee ${mzml_file.baseName}_comet.log
cat <<-END_VERSIONS > versions.yml
"${task.process}":
CometAdapter: \$(CometAdapter 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
Comet: \$(/opt/OpenMS/thirdparty/Comet/comet.exe 2>&1 | grep -m1 -E "^[[:space:]]*Comet version.*" | sed 's/^[[:space:]]*Comet version //g' | sed 's/"//g')
END_VERSIONS
"""
}