Algorithms#
Many signal processing algorithms follow a similar pattern in OpenMS.
algorithm = NameOfTheAlgorithmClass()
exp = MSExperiment()
# populate exp, for example load from file
# ...
# run the algorithm on data
algorithm.filterExperiment(exp)
In many cases, the processing algorithms have a set of parameters that can be
adjusted. These are accessible through Algorithm.getParameters() and yield a
Param object (see Parameter handling) which can
be manipulated. After changing parameters, one can use Algorithm.setParameters() to
propagate the new parameters to the algorithm:
algorithm = NameOfTheAlgorithmClass()
param = algorithm.getParameters()
param.setValue("algo_parameter", "new_value")
algorithm.setParameters(param)
exp = MSExperiment()
# populate exp, for example load from file
# ...
algorithm.filterExperiment(exp)
Since they work on a single MSExperiment object, little input is needed to
execute a filter directly on the data. Examples of filters that follow this
pattern are GaussFilter, SavitzkyGolayFilter as well as the spectral filters
NLargest, Normalizer, SpectraMerger, ThresholdMower, WindowMower.
Using the same example file as before, we can execute a GaussFilter on our test data as follows:
1import pyopenms as oms
2from urllib.request import urlretrieve
3
4gh = "https://raw.githubusercontent.com/OpenMS/OpenMS/develop/doc/pyopenms"
5urlretrieve(gh + "/src/data/tiny.mzML", "test.mzML")
6
7gf = oms.GaussFilter()
8exp = oms.MSExperiment()
9oms.MzMLFile().load("test.mzML", exp)
10gf.filterExperiment(exp)
11# oms.MzMLFile().store("test.filtered.mzML", exp)