Algorithms
Many signal processing algorithms follow a similar pattern in OpenMS.
algorithm = NameOfTheAlgorithmClass()
exp = MSExperiment()
# populate exp, for example load from file
algorithm.filterExperiment(exp)
In many cases, the processing algorithms have a set of parameters that can be
adjusted. These are accessible through getParameters()
and yield a
Param
object (see Parameter handling) which can
be manipulated. After changing parameters, one can use 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
BernNorm
, MarkerMower
, NLargest
, Normalizer
,
ParentPeakMower
, Scaler
, SpectraMerger
, SqrtMower
,
ThresholdMower
, WindowMower
.
Using the same example file as before, we can execute a GaussFilter
on our test data as follows:
1from pyopenms import *
2from urllib.request import urlretrieve
3
4gh = "https://raw.githubusercontent.com/OpenMS/pyopenms-docs/master"
5urlretrieve(gh + "/src/data/tiny.mzML", "test.mzML")
6
7exp = MSExperiment()
8gf = GaussFilter()
9exp = MSExperiment()
10MzMLFile().load("test.mzML", exp)
11gf.filterExperiment(exp)
12# MzMLFile().store("test.filtered.mzML", exp)