-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from ypriverol/dev
testing with dev version of OpenMS 2.8.0
- Loading branch information
Showing
24 changed files
with
189 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.