Skip to content

Commit bdaea6f

Browse files
committed
Merge branch 'main' of https://github.com/bigbio/nf-modules into dev
2 parents e7437f0 + 0318e0a commit bdaea6f

10 files changed

Lines changed: 198 additions & 136 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,13 @@ dag.svg
198198
testing/
199199
testing*/
200200
*.pyc
201+
.nf-test
202+
*nf.test.snap
201203

202204
# Codacy
203205
.codacy
204206

205207
# IDEA
206208
.idea/
209+
210+
.nf-test*

modules/bigbio/onsite/environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
name: onsite
21
channels:
32
- conda-forge
43
- bioconda

modules/bigbio/onsite/main.nf

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
process ONSITE {
2-
tag "$meta.mzml_id"
2+
tag "${meta.id}"
33
label 'process_medium'
44
label 'onsite'
55

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' }"
6+
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
7+
? 'https://depot.galaxyproject.org/singularity/pyonsite:0.0.2--pyhdfd78af_0'
8+
: 'biocontainers/pyonsite:0.0.2--pyhdfd78af_0'}"
99

1010
input:
1111
tuple val(meta), path(mzml_file), path(id_file)
1212

1313
output:
14-
tuple val(meta), path("${id_file.baseName}_*.idXML"), emit: ptm_in_id_onsite
14+
tuple val(meta), path("${prefix}_*.idXML"), emit: ptm_in_id_onsite
1515
path "versions.yml", emit: versions
1616
path "*.log", emit: log
1717

18+
when:
19+
task.ext.when == null || task.ext.when
20+
1821
script:
1922
def args = task.ext.args ?: ''
20-
def prefix = task.ext.prefix ?: "${meta.mzml_id}"
23+
prefix = task.ext.prefix ?: "${meta.id}"
2124

22-
// Algorithm selection: ascore (default), phosphors, or lucxor
23-
def algorithm = params.onsite_algorithm ?: 'ascore'
25+
// Algorithm selection: lucxor (default), ascore, or phosphors
26+
def algorithm = params.onsite_algorithm ?: 'lucxor'
2427

2528
// Common parameters for all algorithms
2629
def fragment_tolerance = params.onsite_fragment_tolerance ?: '0.05'
30+
def compute_all_scores = params.onsite_compute_all_scores ? '--compute-all-scores' : ''
2731

2832
// Set default value for add_decoys (can be overridden by setting params.onsite_add_decoys = false)
2933
def onsite_add_decoys = params.containsKey('onsite_add_decoys') ? params.onsite_add_decoys : true
@@ -39,32 +43,31 @@ process ONSITE {
3943
if (algorithm == 'ascore') {
4044
// AScore: uses -in, -id, -out, --fragment-mass-unit
4145
fragment_unit = params.onsite_fragment_unit ?: 'Da'
46+
def optional_flags = [add_decoys, compute_all_scores, debug].findAll { a -> a }.join(' \\\n ')
4247
algorithm_cmd = """
4348
onsite ascore \\
4449
-in ${mzml_file} \\
4550
-id ${id_file} \\
46-
-out ${id_file.baseName}_ascore.idXML \\
51+
-out ${prefix}_ascore.idXML \\
4752
--fragment-mass-tolerance ${fragment_tolerance} \\
48-
--fragment-mass-unit ${fragment_unit} \\
49-
${add_decoys} \\
50-
${debug} \\
51-
${args}
53+
--fragment-mass-unit ${fragment_unit}${optional_flags ? ' \\\n ' + optional_flags : ''}
5254
"""
53-
} else if (algorithm == 'phosphors') {
55+
}
56+
else if (algorithm == 'phosphors') {
5457
// PhosphoRS: uses -in, -id, -out, --fragment-mass-unit
5558
fragment_unit = params.onsite_fragment_unit ?: 'Da'
59+
def optional_flags = [add_decoys, compute_all_scores, debug].findAll { a -> a }.join(' \\\n ')
5660
algorithm_cmd = """
5761
onsite phosphors \\
5862
-in ${mzml_file} \\
5963
-id ${id_file} \\
60-
-out ${id_file.baseName}_phosphors.idXML \\
64+
-out ${prefix}_phosphors.idXML \\
6165
--fragment-mass-tolerance ${fragment_tolerance} \\
62-
--fragment-mass-unit ${fragment_unit} \\
63-
${add_decoys} \\
64-
${debug} \\
66+
--fragment-mass-unit ${fragment_unit}${optional_flags ? ' \\\n ' + optional_flags : ''}
6567
${args}
6668
"""
67-
} else if (algorithm == 'lucxor') {
69+
}
70+
else if (algorithm == 'lucxor') {
6871
// LucXor: uses -in, -id, -out, --fragment-error-units (note: error-units not mass-unit)
6972
fragment_unit = params.onsite_fragment_error_units ?: 'Da'
7073
def fragment_method = params.onsite_fragment_method ?: 'CID'
@@ -74,20 +77,22 @@ process ONSITE {
7477
def max_num_perm = params.onsite_max_num_perm ?: '16384'
7578
def modeling_threshold = params.onsite_modeling_score_threshold ?: '0.95'
7679
def scoring_threshold = params.onsite_scoring_threshold ?: '0.0'
77-
def min_num_psms = params.onsite_min_num_psms_model ?: '50'
80+
def min_num_psms = params.onsite_min_num_psms_model ?: '5'
7881
def rt_tolerance = params.onsite_rt_tolerance ?: '0.01'
82+
def disable_split_by_charge = params.onsite_disable_split_by_charge ? '--disable-split-by-charge' : ''
7983

8084
// Optional target modifications - default for LucXor includes decoy
8185
def target_mods = params.onsite_target_modifications ? "--target-modifications ${params.onsite_target_modifications}" : "--target-modifications 'Phospho(S),Phospho(T),Phospho(Y),PhosphoDecoy(A)'"
8286
def neutral_losses = params.onsite_neutral_losses ? "--neutral-losses ${params.onsite_neutral_losses}" : "--neutral-losses 'sty -H3PO4 -97.97690'"
8387
def decoy_mass = params.onsite_decoy_mass ? "--decoy-mass ${params.onsite_decoy_mass}" : "--decoy-mass 79.966331"
8488
def decoy_losses = params.onsite_decoy_neutral_losses ? "--decoy-neutral-losses ${params.onsite_decoy_neutral_losses}" : "--decoy-neutral-losses 'X -H3PO4 -97.97690'"
8589

90+
def optional_flags = [disable_split_by_charge, compute_all_scores, debug].findAll { a -> a }.join(' \\\n ')
8691
algorithm_cmd = """
8792
onsite lucxor \\
8893
-in ${mzml_file} \\
8994
-id ${id_file} \\
90-
-out ${id_file.baseName}_lucxor.idXML \\
95+
-out ${prefix}_lucxor.idXML \\
9196
--fragment-method ${fragment_method} \\
9297
--fragment-mass-tolerance ${fragment_tolerance} \\
9398
--fragment-error-units ${fragment_unit} \\
@@ -102,21 +107,19 @@ process ONSITE {
102107
--modeling-score-threshold ${modeling_threshold} \\
103108
--scoring-threshold ${scoring_threshold} \\
104109
--min-num-psms-model ${min_num_psms} \\
105-
--rt-tolerance ${rt_tolerance} \\
106-
${debug} \\
107-
${args}
110+
--rt-tolerance ${rt_tolerance}${optional_flags ? ' \\\n ' + optional_flags : ''}
108111
"""
109-
} else {
110-
error "Unknown onsite algorithm: ${algorithm}. Supported algorithms: ascore, phosphors, lucxor"
112+
}
113+
else {
114+
error("Unknown onsite algorithm: ${algorithm}. Supported algorithms: ascore, phosphors, lucxor")
111115
}
112116

113117
"""
114-
${algorithm_cmd} \\
115-
2>&1 | tee ${id_file.baseName}_${algorithm}.log
118+
${algorithm_cmd.trim()} 2>&1 | tee ${prefix}_${algorithm}.log
116119
117120
cat <<-END_VERSIONS > versions.yml
118121
"${task.process}":
119-
onsite: \$(onsite --version 2>&1 | grep -oP 'version \\K[0-9.]+' || echo "unknown")
122+
onsite: \$(onsite --version 2>&1 | grep -oE 'version \\K[0-9.]+' || echo "unknown")
120123
algorithm: ${algorithm}
121124
END_VERSIONS
122125
"""

modules/bigbio/onsite/meta.yml

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: onsite
2-
description: Post-translational modification (PTM) localization using onsite algorithms (AScore, PhosphoRS, LucXor)
2+
description: Post-translational modification (PTM) localization using onsite
3+
algorithms (AScore, PhosphoRS, LucXor)
34
keywords:
45
- onsite
56
- PTM
@@ -18,39 +19,51 @@ tools:
1819
homepage: https://github.com/bigbio/onsite
1920
documentation: https://github.com/bigbio/onsite/blob/main/README.md
2021
tool_dev_url: https://github.com/bigbio/onsite
21-
doi: ""
22-
licence: ["MIT"]
22+
licence:
23+
- "MIT"
24+
identifier: ""
2325
input:
24-
- meta:
25-
type: map
26-
description: |
27-
Groovy Map containing sample information
28-
e.g. [ id:'test', mzml_id:'sample1' ]
29-
- mzml_file:
30-
type: file
31-
description: Input spectrum file in mzML format
32-
pattern: "*.mzML"
33-
- id_file:
34-
type: file
35-
description: Protein/peptide identifications file in idXML format
36-
pattern: "*.idXML"
37-
- meta:
38-
type: map
39-
description: |
40-
Groovy Map containing sample information
41-
e.g. [ id:'test', mzml_id:'sample1' ]
42-
- ptm_in_id_onsite:
43-
type: file
44-
description: Protein/peptide identifications file with PTM localization scores
45-
pattern: "*_{ascore,phosphors,lucxor}.idXML"
46-
- log:
47-
type: file
48-
description: Log file from onsite execution
49-
pattern: "*.log"
50-
- versions:
51-
type: file
52-
description: File containing software versions
53-
pattern: "versions.yml"
26+
- - meta:
27+
type: map
28+
description: |
29+
Groovy Map containing sample information
30+
e.g. `[ id:'test', mzml_id:'sample1' ]`
31+
- mzml_file:
32+
type: file
33+
description: Input spectrum file in mzML format
34+
pattern: "*.mzML"
35+
ontologies: []
36+
- id_file:
37+
type: file
38+
description: Protein/peptide identifications file in idXML format
39+
pattern: "*.idXML"
40+
ontologies: []
41+
output:
42+
ptm_in_id_onsite:
43+
- - meta:
44+
type: map
45+
description: |
46+
Groovy Map containing sample information
47+
- ${prefix}_*.idXML:
48+
type: file
49+
description: Output idXML file containing PTM localization results from
50+
onsite
51+
pattern: "${prefix}_*.idXML"
52+
ontologies: []
53+
log:
54+
- "*.log":
55+
type: file
56+
description: Log file from onsite execution
57+
pattern: "*.log"
58+
ontologies: []
59+
versions:
60+
- versions.yml:
61+
type: file
62+
description: File containing software versions
63+
pattern: "versions.yml"
64+
ontologies:
65+
- edam: http://edamontology.org/format_3750
5466
authors:
5567
- "@ypriverol"
5668
- "@weizhongchun"
69+
- "@enryh"

modules/bigbio/onsite/tests/main.nf.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ nextflow_process {
55
process "ONSITE"
66
tag "modules"
77
tag "modules_onsite"
8+
tag "modules_bigbio"
89
tag "onsite"
910

1011
test("Should run AScore algorithm") {

modules/bigbio/thermorawfileparser/environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
name: thermorawfileparser
21
channels:
32
- conda-forge
43
- bioconda
Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
process THERMORAWFILEPARSER {
2-
tag "$meta.mzml_id"
2+
tag "${meta.id}"
33
label 'process_low'
44
label 'process_single'
55
label 'error_retry'
@@ -9,59 +9,64 @@ process THERMORAWFILEPARSER {
99
'https://depot.galaxyproject.org/singularity/thermorawfileparser:2.0.0.dev--h9ee0642_0' :
1010
'biocontainers/thermorawfileparser:2.0.0.dev--h9ee0642_0' }"
1111

12-
stageInMode {
13-
if (task.attempt == 1) {
14-
if (task.executor == "awsbatch") {
15-
'symlink'
16-
} else {
17-
'link'
18-
}
19-
} else if (task.attempt == 2) {
20-
if (task.executor == "awsbatch") {
21-
'copy'
22-
} else {
23-
'symlink'
24-
}
25-
} else {
26-
'copy'
27-
}
28-
}
2912
input:
30-
tuple val(meta), path(rawfile)
13+
tuple val(meta), path(raw)
3114

3215
output:
33-
tuple val(meta), path("*.{mzML,mgf,parquet}"), emit: convert_files
34-
path "versions.yml", emit: versions
35-
path "*.log", emit: log
16+
tuple val(meta), path("*.{mzML,mzML.gz,mgf,mgf.gz,parquet,parquet.gz}"), emit: spectra
17+
tuple val("${task.process}"), val('thermorawfileparser'), eval("thermorawfileparser --version"), emit: versions_thermorawfileparser, topic: versions
18+
path "*.log", emit: log
19+
20+
when:
21+
task.ext.when == null || task.ext.when
3622

3723
script:
3824
def args = task.ext.args ?: ''
25+
// Detect existing format options in any supported syntax: -f=2, -f 2, --format=2,
26+
// or --format 2.
27+
def hasFormatArg = (args =~ /(^|\s)(-f(=|\s)\d+|--format(=|\s)\d+)/).find()
3928
// Default to indexed mzML format (-f=2) if not specified in args
40-
def formatArg = args.contains('-f=') ? '' : '-f=2'
29+
def formatArg = hasFormatArg ? '' : '-f=2'
30+
def prefix = task.ext.prefix ?: "${meta.id}"
31+
def suffix = args.contains("--format 0") || args.contains("-f 0")
32+
? "mgf"
33+
: args.contains("--format 1") || args.contains("-f 1")
34+
? "mzML"
35+
: args.contains("--format 2") || args.contains("-f 2")
36+
? "mzML"
37+
: args.contains("--format 3") || args.contains("-f 3")
38+
? "parquet"
39+
: "mzML"
40+
suffix = args.contains("--gzip") ? "${suffix}.gz" : "${suffix}"
4141

4242
"""
43-
ThermoRawFileParser.sh -i='${rawfile}' ${formatArg} ${args} -o=./ 2>&1 | tee '${rawfile.baseName}_conversion.log'
44-
45-
cat <<-END_VERSIONS > versions.yml
46-
"${task.process}":
47-
ThermoRawFileParser: \$(ThermoRawFileParser.sh --version)
48-
END_VERSIONS
43+
thermorawfileparser \\
44+
-i='${raw}' \\
45+
${formatArg} ${args} \\
46+
-o=./ 2>&1 | tee '${prefix}_conversion.log'
4947
"""
5048

5149
stub:
52-
def prefix = task.ext.prefix ?: "${meta.mzml_id}"
5350
def args = task.ext.args ?: ''
54-
// Determine output format from args, default to mzML
55-
// Format 0 = MGF, formats 1-2 = mzML, format 3 = Parquet, format 4 = None
56-
def outputExt = (args =~ /-f=0\b/).find() ? 'mgf' : 'mzML'
51+
def prefix = task.ext.prefix ?: "${meta.id}"
52+
def suffix = args.contains("--format 0") || args.contains("-f 0")
53+
? "mgf"
54+
: args.contains("--format 1") || args.contains("-f 1")
55+
? "mzML"
56+
: args.contains("--format 2") || args.contains("-f 2")
57+
? "mzML"
58+
: args.contains("--format 3") || args.contains("-f 3")
59+
? "parquet"
60+
: "mzML"
61+
suffix = args.contains("--gzip") ? "${suffix}.gz" : "${suffix}"
5762

5863
"""
59-
touch '${prefix}.${outputExt}'
64+
touch '${prefix}.${suffix}'
6065
touch '${prefix}_conversion.log'
6166
6267
cat <<-END_VERSIONS > versions.yml
6368
"${task.process}":
64-
ThermoRawFileParser: \$(ThermoRawFileParser.sh --version)
69+
ThermoRawFileParser: \$(thermorawfileparser --version)
6570
END_VERSIONS
6671
"""
6772
}

0 commit comments

Comments
 (0)