Skip to content

Commit 29431b1

Browse files
committed
Merge branch '165_MSParams_fix' into 'master'
Add ability to instantiate MSParameters Closes #165 See merge request mass-spectrometry/corems!127
2 parents fd89859 + 269a5a1 commit 29431b1

30 files changed

Lines changed: 19055 additions & 17854 deletions

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.0.10
2+
current_version = 2.1.0
33
commit = False
44
tag = False
55

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CoreMS aims to provide
5050

5151
## Current Version
5252

53-
`2.0.10`
53+
`2.1.0`
5454

5555
***
5656

@@ -323,7 +323,7 @@ UML (unified modeling language) diagrams for Direct Infusion FT-MS and GC-MS cla
323323
324324
If you use CoreMS in your work, please use the following citation:
325325
326-
Version [2.0.10 Release on GitHub](https://github.com/EMSL-Computing/CoreMS/releases/tag/v2.0.10), archived on Zenodo:
326+
Version [2.1.0 Release on GitHub](https://github.com/EMSL-Computing/CoreMS/releases/tag/v2.1.0), archived on Zenodo:
327327
328328
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4641552.svg)](https://doi.org/10.5281/zenodo.4641552)
329329

corems/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'Yuri E. Corilo'
2-
__version__ = '2.0.10'
2+
__version__ = '2.1.0'
33
__doc__ = '''
44
<div align="left">
55

corems/encapsulation/factory/parameters.py

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,40 @@
1+
import dataclasses
2+
13
from corems.encapsulation.factory.processingSetting import LiquidChromatographSetting, MolecularFormulaSearchSettings, TransientSetting, MassSpecPeakSetting, MassSpectrumSetting
24
from corems.encapsulation.factory.processingSetting import CompoundSearchSettings, GasChromatographSetting
35
from corems.encapsulation.factory.processingSetting import DataInputSetting
46

7+
def reset_ms_parameters():
8+
"""Reset the MSParameter class to the default values"""
9+
MSParameters.molecular_search = MolecularFormulaSearchSettings()
10+
MSParameters.transient = TransientSetting()
11+
MSParameters.mass_spectrum = MassSpectrumSetting()
12+
MSParameters.ms_peak = MassSpecPeakSetting()
13+
MSParameters.data_input = DataInputSetting()
14+
15+
def reset_gcms_parameters():
16+
"""Reset the GCMSParameters class to the default values"""
17+
GCMSParameters.molecular_search = CompoundSearchSettings()
18+
GCMSParameters.gc_ms = GasChromatographSetting()
19+
20+
def reset_lcms_parameters():
21+
"""Reset the LCMSParameters class to the default values"""
22+
LCMSParameters.lc_ms = LiquidChromatographSetting()
23+
LCMSParameters.mass_spectrum = MassSpectrumSetting()
24+
LCMSParameters.ms_peak = MassSpecPeakSetting()
25+
LCMSParameters.ms1_molecular_search = MolecularFormulaSearchSettings()
26+
LCMSParameters.ms2_molecular_search = MolecularFormulaSearchSettings()
27+
528
class MSParameters:
629
"""MSParameters class is used to store the parameters used for the processing of the mass spectrum
730
831
Each attibute is a class that contains the parameters for the processing of the mass spectrum, see the corems.encapsulation.factory.processingSetting module for more details.
932
33+
Parameters
34+
----------
35+
use_defaults: bool, optional
36+
if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
37+
1038
Attributes
1139
-----------
1240
molecular_search: MolecularFormulaSearchSettings
@@ -19,6 +47,11 @@ class MSParameters:
1947
MassSpecPeakSetting object
2048
data_input: DataInputSetting
2149
DataInputSetting object
50+
51+
Notes
52+
-----
53+
One can use the use_defaults parameter to reset the parameters to the default values.
54+
Alternatively, to use the current values - modify the class's contents before instantiating the class.
2255
"""
2356

2457
molecular_search = MolecularFormulaSearchSettings()
@@ -27,27 +60,64 @@ class MSParameters:
2760
ms_peak = MassSpecPeakSetting()
2861
data_input = DataInputSetting()
2962

63+
def __init__(self, use_defaults = False) -> None:
64+
if not use_defaults:
65+
self.molecular_search = dataclasses.replace(MSParameters.molecular_search)
66+
self.transient = dataclasses.replace(MSParameters.transient)
67+
self.mass_spectrum = dataclasses.replace(MSParameters.mass_spectrum)
68+
self.ms_peak = dataclasses.replace(MSParameters.ms_peak)
69+
self.data_input = dataclasses.replace(MSParameters.data_input)
70+
else:
71+
self.molecular_search = MolecularFormulaSearchSettings()
72+
self.transient = TransientSetting()
73+
self.mass_spectrum = MassSpectrumSetting()
74+
self.ms_peak = MassSpecPeakSetting()
75+
self.data_input = DataInputSetting()
76+
3077
class GCMSParameters:
3178
"""GCMSParameters class is used to store the parameters used for the processing of the gas chromatograph mass spectrum
3279
3380
Each attibute is a class that contains the parameters for the processing of the data, see the corems.encapsulation.factory.processingSetting module for more details.
3481
82+
Parameters
83+
----------
84+
use_defaults: bool, optional
85+
if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
86+
3587
Attributes
3688
-----------
3789
molecular_search: MolecularFormulaSearchSettings
3890
MolecularFormulaSearchSettings object
3991
gc_ms: GasChromatographSetting
4092
GasChromatographSetting object
93+
94+
Notes
95+
-----
96+
One can use the use_defaults parameter to reset the parameters to the default values.
97+
Alternatively, to use the current values - modify the class's contents before instantiating the class.
4198
"""
4299

43100
molecular_search = CompoundSearchSettings()
44101
gc_ms = GasChromatographSetting()
45102

103+
def __init__(self, use_defaults = False) -> None:
104+
if not use_defaults:
105+
self.molecular_search = dataclasses.replace(GCMSParameters.molecular_search)
106+
self.gc_ms = dataclasses.replace(GCMSParameters.gc_ms)
107+
else:
108+
self.molecular_search = CompoundSearchSettings()
109+
self.gc_ms = GasChromatographSetting()
110+
46111
class LCMSParameters:
47112
"""LCMSParameters class is used to store the parameters used for the processing of the liquid chromatograph mass spectrum
48113
49114
Each attibute is a class that contains the parameters for the processing of the data, see the corems.encapsulation.factory.processingSetting module for more details.
50115
116+
Parameters
117+
----------
118+
use_defaults: bool, optional
119+
if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
120+
51121
Attributes
52122
-----------
53123
lc_ms: LiquidChromatographSetting
@@ -60,17 +130,32 @@ class LCMSParameters:
60130
MolecularFormulaSearchSettings object
61131
ms2_molecular_search: MolecularFormulaSearchSettings
62132
MolecularFormulaSearchSettings object
133+
134+
Notes
135+
-----
136+
One can use the use_defaults parameter to reset the parameters to the default values.
137+
Alternatively, to use the current values - modify the class's contents before instantiating the class.
63138
"""
64139
lc_ms = LiquidChromatographSetting()
65-
66140
mass_spectrum = MassSpectrumSetting()
67-
68141
ms_peak = MassSpecPeakSetting()
69-
70142
ms1_molecular_search = MolecularFormulaSearchSettings()
71-
72143
ms2_molecular_search = MolecularFormulaSearchSettings()
73144

145+
def __init__(self, use_defaults = False) -> None:
146+
if not use_defaults:
147+
self.lc_ms = dataclasses.replace(LCMSParameters.lc_ms)
148+
self.mass_spectrum = dataclasses.replace(LCMSParameters.mass_spectrum)
149+
self.ms_peak = dataclasses.replace(LCMSParameters.ms_peak)
150+
self.ms1_molecular_search = dataclasses.replace(LCMSParameters.ms1_molecular_search)
151+
self.ms2_molecular_search = dataclasses.replace(LCMSParameters.ms2_molecular_search)
152+
else:
153+
self.lc_ms = LiquidChromatographSetting()
154+
self.mass_spectrum = MassSpectrumSetting()
155+
self.ms_peak = MassSpecPeakSetting()
156+
self.ms1_molecular_search = MolecularFormulaSearchSettings()
157+
self.ms2_molecular_search = MolecularFormulaSearchSettings()
158+
74159
def default_parameters(file_location): # pragma: no cover
75160
"""Generate parameters dictionary with the default parameters for data processing
76161
To gather parameters from instrument data during the data parsing step, a parameters dictionary with the default parameters needs to be generated.

docs/corems.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ <h2 id="citing-corems">Citing CoreMS</h2>
502502
<label class="view-source-button" for="mod-corems-view-source"><span>View Source</span></label>
503503

504504
<div class="pdoc-code codehilite"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos"> 1</span></a><span class="n">__author__</span> <span class="o">=</span> <span class="s1">&#39;Yuri E. Corilo&#39;</span>
505-
</span><span id="L-2"><a href="#L-2"><span class="linenos"> 2</span></a><span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;2.0.5&#39;</span>
505+
</span><span id="L-2"><a href="#L-2"><span class="linenos"> 2</span></a><span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;2.1.0&#39;</span>
506506
</span><span id="L-3"><a href="#L-3"><span class="linenos"> 3</span></a><span class="vm">__doc__</span> <span class="o">=</span> <span class="s1">&#39;&#39;&#39;</span>
507507
</span><span id="L-4"><a href="#L-4"><span class="linenos"> 4</span></a><span class="s1">&lt;div align=&quot;left&quot;&gt;</span>
508508
</span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a>

0 commit comments

Comments
 (0)