Skip to content

Commit

Permalink
Merge pull request #2 from daichengxin/dev
Browse files Browse the repository at this point in the history
fixed version yaml
  • Loading branch information
ypriverol authored Oct 14, 2022
2 parents 28c6110 + 43911c5 commit 3630390
Show file tree
Hide file tree
Showing 24 changed files with 155 additions and 28 deletions.
59 changes: 59 additions & 0 deletions bin/mzml_statistics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python

from pyopenms import MzMLFile, MSExperiment
import os
import pandas as pd
import click

CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


@click.group(context_settings=CONTEXT_SETTINGS)
def cli():
pass


@click.command("mzml_dataframe")
@click.option("--mzml_folder", "-d")
@click.pass_context
def mzml_dataframe(ctx, mzml_folder):

file_columns = ["File_Name", "SpectrumID", "MSLevel", "Charge", "MS2_peaks", "Base_Peak_Intensity"]
mzml_paths = list(i for i in os.listdir(mzml_folder) if i.endswith(".mzML"))
mzml_count = 1

def parse_mzml(file_name, file_columns):
info = []
exp = MSExperiment()
MzMLFile().load(file_name, exp)
for i in exp:
name = os.path.split(file_name)[1]
id = i.getNativeID()
MSLevel = i.getMSLevel()
if MSLevel == 2:
charge_state = i.getPrecursors()[0].getCharge()
peaks_tuple = i.get_peaks()
peak_per_ms2 = len(peaks_tuple[0])
if i.getMetaValue("base peak intensity"):
base_peak_intensity = i.getMetaValue("base peak intensity")
else:
base_peak_intensity = max(peaks_tuple[1]) if len(peaks_tuple[1]) > 0 else "null"
info_list = [name, id, 2, charge_state, peak_per_ms2, base_peak_intensity]
else:
info_list = [name, id, MSLevel, "null", "null", "null"]

info.append(info_list)

return pd.DataFrame(info, columns=file_columns)

for i in mzml_paths:
mzml_df = parse_mzml(mzml_folder + i, file_columns)
tsv_header = True if mzml_count == 1 else False
mzml_df.to_csv("mzml_info.tsv", mode="a", sep="\t", index=False, header=tsv_header)
mzml_count += 1


cli.add_command(mzml_dataframe)

if __name__ == "__main__":
cli()
6 changes: 3 additions & 3 deletions modules/local/diannconvert/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ process DIANNCONVERT {
tag "$exp_design.Name"
label 'process_low'

conda (params.enable_conda ? "conda-forge::pandas_schema conda-forge::lzstring bioconda::pmultiqc=0.0.13" : null)
conda (params.enable_conda ? "conda-forge::pandas_schema conda-forge::lzstring bioconda::pmultiqc=0.0.16" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/pmultiqc:0.0.13--pyhdfd78af_0"
container "https://depot.galaxyproject.org/singularity/pmultiqc:0.0.16--pyhdfd78af_0"
} else {
container "quay.io/biocontainers/pmultiqc:0.0.13--pyhdfd78af_0"
container "quay.io/biocontainers/pmultiqc:0.0.16--pyhdfd78af_0"
}

input:
Expand Down
34 changes: 34 additions & 0 deletions modules/local/mzmlstatistics/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
process MZMLSTATISTICS {
label 'process_medium'
// TODO could be easily parallelized
label 'process_single_thread'

conda (params.enable_conda ? "conda-forge::pandas_schema conda-forge::lzstring bioconda::pmultiqc=0.0.16" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/pmultiqc:0.0.16--pyhdfd78af_0"
} else {
container "quay.io/biocontainers/pmultiqc:0.0.16--pyhdfd78af_0"
}

input:
path("out/*")

output:
path "mzml_info.tsv", emit: mzml_statistics
path "versions.yml", emit: version
path "*.log", emit: log

script:
def args = task.ext.args ?: ''

"""
mzml_statistics.py mzml_dataframe \\
--mzml_folder "./out/" \\
|& tee mzml_statistics.log
cat <<-END_VERSIONS > versions.yml
"${task.process}":
pyopenms: \$(echo "2.8.0")
END_VERSIONS
"""
}
26 changes: 26 additions & 0 deletions modules/local/mzmlstatistics/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: MZMLSTATISTICS
description: A module for mzMLs statistics
keywords:
- mzML
- statistics
tools:
- custom:
description: |
A custom module for mzMLs statistics.
homepage: https://github.com/bigbio/quantms
documentation: https://github.com/bigbio/quantms/tree/readthedocs
input:
- mzmls:
type: dir
description: mzML files directory
output:
- mzml_statistics:
type: file
description: mzMLs statistics file
pattern: "mzml_info.tsv"
- version:
type: file
description: File containing software version
pattern: "versions.yml"
authors:
- "@wanghong"
2 changes: 1 addition & 1 deletion modules/local/openms/consensusid/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ process CONSENSUSID {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
ConsensusID: \$(ConsensusID 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
ConsensusID: \$(ConsensusID 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/decoydatabase/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ process DECOYDATABASE {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
DecoyDatabase: \$(DecoyDatabase 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
DecoyDatabase: \$(DecoyDatabase 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/epifany/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ process EPIFANY {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Epifany: \$(Epifany 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
Epifany: \$(Epifany 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/extractpsmfeatures/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ process EXTRACTPSMFEATURES {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
PSMFeatureExtractor: \$(PSMFeatureExtractor 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
PSMFeatureExtractor: \$(PSMFeatureExtractor 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/falsediscoveryrate/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ process FALSEDISCOVERYRATE {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
FalseDiscoveryRate: \$(FalseDiscoveryRate 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
FalseDiscoveryRate: \$(FalseDiscoveryRate 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/filemerge/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ process FILEMERGE {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
FileMerger: \$(FileMerger 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
FileMerger: \$(FileMerger 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/idconflictresolver/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ process IDCONFLICTRESOLVER {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
IDConflictResolver: \$(IDConflictResolver 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
IDConflictResolver: \$(IDConflictResolver 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/idfilter/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ process IDFILTER {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
IDFilter: \$(IDFilter 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
IDFilter: \$(IDFilter 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/idmapper/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ process IDMAPPER {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
IDMapper: \$(IDMapper 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
IDMapper: \$(IDMapper 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/idpep/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ process IDPEP {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
IDPosteriorErrorProbability: \$(IDPosteriorErrorProbability 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
IDPosteriorErrorProbability: \$(IDPosteriorErrorProbability 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/idscoreswitcher/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ process IDSCORESWITCHER {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
IDScoreSwitcher: \$(IDScoreSwitcher 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
IDScoreSwitcher: \$(IDScoreSwitcher 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/indexpeptides/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ process INDEXPEPTIDES {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
PeptideIndexer: \$(PeptideIndexer 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
PeptideIndexer: \$(PeptideIndexer 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/isobaricanalyzer/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ process ISOBARICANALYZER {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
IsobaricAnalyzer: \$(IsobaricAnalyzer --version 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
IsobaricAnalyzer: \$(IsobaricAnalyzer --version 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/msstatsconverter/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ process MSSTATSCONVERTER {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
MSstatsConverter: \$(MSstatsConverter 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
MSstatsConverter: \$(MSstatsConverter 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/mzmlindexing/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ process MZMLINDEXING {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
FileConverter: \$(FileConverter 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
FileConverter: \$(FileConverter 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/openmspeakpicker/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ process OPENMSPEAKPICKER {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
PeakPickerHiRes: \$(PeakPickerHiRes 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g')
PeakPickerHiRes: \$(PeakPickerHiRes 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/local/openms/proteininference/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ process PROTEININFERENCE {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
ProteinInference: \$(ProteinInference 2>&1 | grep -E '^Version(.*) ' | sed 's/Version: //g')
ProteinInference: \$(ProteinInference 2>&1 | grep -E '^Version(.*) ' | sed 's/Version: //g' | cut -d ' ' -f 1)
END_VERSIONS
"""
}
6 changes: 3 additions & 3 deletions modules/local/pmultiqc/main.nf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
process PMULTIQC {
label 'process_high'

conda (params.enable_conda ? "conda-forge::pandas_schema conda-forge::lzstring bioconda::pmultiqc=0.0.15" : null)
conda (params.enable_conda ? "conda-forge::pandas_schema conda-forge::lzstring bioconda::pmultiqc=0.0.16" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/pmultiqc:0.0.15--pyhdfd78af_0"
container "https://depot.galaxyproject.org/singularity/pmultiqc:0.0.16--pyhdfd78af_0"
} else {
container "quay.io/biocontainers/pmultiqc:0.0.15--pyhdfd78af_0"
container "quay.io/biocontainers/pmultiqc:0.0.16--pyhdfd78af_0"
}

input:
Expand Down
12 changes: 12 additions & 0 deletions subworkflows/local/file_preparation.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

include { THERMORAWFILEPARSER } from '../../modules/local/thermorawfileparser/main'
include { MZMLINDEXING } from '../../modules/local/openms/mzmlindexing/main'
include { MZMLSTATISTICS } from '../../modules/local/mzmlstatistics/main'
include { OPENMSPEAKPICKER } from '../../modules/local/openms/openmspeakpicker/main'

workflow FILE_PREPARATION {
Expand All @@ -13,6 +14,7 @@ workflow FILE_PREPARATION {
main:
ch_versions = Channel.empty()
ch_results = Channel.empty()
ch_statistics = Channel.empty()

//
// Divide mzml files
Expand Down Expand Up @@ -51,6 +53,15 @@ workflow FILE_PREPARATION {
ch_versions = ch_versions.mix(MZMLINDEXING.out.version)
ch_results = ch_results.mix(MZMLINDEXING.out.mzmls_indexed)

ch_results.multiMap{
meta: it[0]
mzml: it[1]
}.set{ ch_mzml }

MZMLSTATISTICS( ch_mzml.mzml.collect() )
ch_statistics = ch_statistics.mix(MZMLSTATISTICS.out.mzml_statistics)
ch_versions = ch_versions.mix(MZMLSTATISTICS.out.version)

if (params.openms_peakpicking){
OPENMSPEAKPICKER (
ch_results
Expand All @@ -63,5 +74,6 @@ workflow FILE_PREPARATION {

emit:
results = ch_results // channel: [val(mzml_id), indexedmzml]
statistics = ch_statistics // channel: [ mzml_statistics.tsv ]
version = ch_versions // channel: [ *.version.txt ]
}
6 changes: 1 addition & 5 deletions workflows/quantms.nf
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ workflow QUANTMS {

ch_versions = ch_versions.mix(FILE_PREPARATION.out.version.ifEmpty(null))

FILE_PREPARATION.out.results
.map { it -> it[1] }
.set { ch_pmultiqc_mzmls }

FILE_PREPARATION.out.results
.branch {
dia: it[0].acquisition_method.contains("dia")
Expand Down Expand Up @@ -180,14 +176,14 @@ workflow QUANTMS {
ch_multiqc_files = Channel.empty()
ch_multiqc_files = ch_multiqc_files.mix(Channel.from(ch_multiqc_config))
ch_multiqc_files = ch_multiqc_files.mix(ch_workflow_summary.collectFile(name: 'workflow_summary_mqc.yaml'))
ch_multiqc_files = ch_multiqc_files.mix(FILE_PREPARATION.out.statistics)
ch_multiqc_files = ch_multiqc_files.mix(ch_methods_description.collectFile(name: 'methods_description_mqc.yaml'))
ch_multiqc_files = ch_multiqc_files.mix(CUSTOM_DUMPSOFTWAREVERSIONS.out.mqc_yml.collect())
ch_multiqc_quantms_logo = file("$projectDir/assets/nf-core-quantms_logo_light.png")

SUMMARYPIPELINE (
CREATE_INPUT_CHANNEL.out.ch_expdesign
.combine(ch_pipeline_results.ifEmpty([]).combine(ch_multiqc_files.collect())
.combine(ch_pmultiqc_mzmls.collect())
.combine(ch_ids_pmultiqc.collect().ifEmpty([])))
.combine(ch_msstats_in.ifEmpty([])),
ch_multiqc_quantms_logo
Expand Down

0 comments on commit 3630390

Please sign in to comment.