Usage Examples¶
I am a fan of quick hands-on overviews to get to know software, that I might or might not use in the future. Several hands-on examples can be found here Simply open them from colab A video version for ASMS’22 is `on youtube
The copy&paste essentials:
Load¶
from mzqc import MZQCFile as qc
with open("nameOfYourFile.mzQC", "r") as file:
my_run_qualities = qc.JsonSerialisable.FromJson(file)
Access elements¶
see schema for a general overview of available elements.
# An in-memory mzQC file will still have the same hierarchical structure as the schema
print(my_run_qualities.description)
# JSON arrays can be used like python lists
for m in my_run_qualities.qualityMetrics:
print(m.name)
# You can traverse the hierarchy with standard python member access notation ('.')
# and get to the bottom of things (like a metric value).
ms2_number = my_run_qualities.qualityMetrics[2].value
Store¶
inmem_file = qc.JsonSerialisable.ToJson(mzqc, readability=1)
with open("nameOfYourFile.mzQC", "w") as file:
file.write(inmem_file)
⚠️Note⚠️ The readability argument determines the level of indentations, 0 by default with no additional whitespaces, =1 minor indentation on MZQC objects (2 spaces), >1 heavy indentation for max. human readability (4 spaces, additional linebreaks). In case you need an existing file made more readable, try
mzqc-fixdescriptionsfrom the Accessories, it will also adjust indentation and linebreaks.