Quality Control#

With MzQCFile pyOpenMS provides a tool to export quality control data from an experiment to a mzQC file following the HUPO-PSI specifications. MzQC is a reporting and exchange format for mass spectrometry quality control data in JSON format.

store() requires, besides the input_file and output_file path, at least a MSExperiment. Optionally, a FeatureMap and/or lists of ProteinIdentification and PeptideIdentification can be provided to calculate additional proteomics and metabolomics quality metrics.

 1import pyopenms as oms
 2from urllib.request import urlretrieve
 3
 4gh = "https://raw.githubusercontent.com/OpenMS/pyopenms-docs/master"
 5
 6# minimal required informations are input_file, output_file and a MSExperiment
 7input_file = "QCCalculator_input.mzML"
 8output_file = "result.mzQC"
 9
10# load mzML file in MSExperiment
11urlretrieve(gh + "/src/data/QCCalculator_input.mzML", "input.mzML")
12exp = oms.MSExperiment()
13oms.MzMLFile().load("input.mzML", exp)
14
15# prepare metadata for the mzQC file (optional but recommended)
16contact_name = "name of the person creating the mzQC file"
17contact_address = "contact address (mail/e-mail or phone) of the person creating the mzQC file"
18description = "description and comments about the mzQC file contents"
19label = "unique and informative label for the run"
20
21feature_map = oms.FeatureMap()
22# OPTIONAL: load featureXML file in FeatureMap()
23urlretrieve(
24    gh + "/src/data/FeatureFinderMetaboIdent_1_output.featureXML",
25    "features.featureXML",
26)
27oms.FeatureXMLFile().load("features.featureXML", feature_map)
28
29prot_ids = []  # list of ProteinIdentification()
30pep_ids = []  # list of PeptideIdentification()
31# OPTIONAL: get protein and peptide identifications from idXML file
32urlretrieve(gh + "/src/data/OpenPepXL_output.idXML", "ids.idXML")
33oms.IdXMLFile().load("ids.idXML", prot_ids, pep_ids)
34
35# create MzQCFile object and use store() to calculate and write the mzQC file
36mzqc = oms.MzQCFile()
37mzqc.store(
38    input_file,
39    output_file,
40    exp,  # minimal required information
41    contact_name,
42    contact_address,
43    description,
44    label,  # optional, but recommended, can be empty
45    feature_map,
46    prot_ids,
47    pep_ids,
48)  # optional, can be empty