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