Skip to content

Commit

Permalink
Merge branch '165_MSParams_fix' into 'master'
Browse files Browse the repository at this point in the history
Add ability to instantiate MSParameters

Closes #165

See merge request mass-spectrometry/corems!127
  • Loading branch information
corilo committed Sep 25, 2024
2 parents fd89859 + 269a5a1 commit 29431b1
Show file tree
Hide file tree
Showing 30 changed files with 19,055 additions and 17,854 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.0.10
current_version = 2.1.0
commit = False
tag = False

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ CoreMS aims to provide

## Current Version

`2.0.10`
`2.1.0`

***

Expand Down Expand Up @@ -323,7 +323,7 @@ UML (unified modeling language) diagrams for Direct Infusion FT-MS and GC-MS cla
If you use CoreMS in your work, please use the following citation:
Version [2.0.10 Release on GitHub](https://github.com/EMSL-Computing/CoreMS/releases/tag/v2.0.10), archived on Zenodo:
Version [2.1.0 Release on GitHub](https://github.com/EMSL-Computing/CoreMS/releases/tag/v2.1.0), archived on Zenodo:
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4641552.svg)](https://doi.org/10.5281/zenodo.4641552)
Expand Down
2 changes: 1 addition & 1 deletion corems/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__author__ = 'Yuri E. Corilo'
__version__ = '2.0.10'
__version__ = '2.1.0'
__doc__ = '''
<div align="left">
Expand Down
93 changes: 89 additions & 4 deletions corems/encapsulation/factory/parameters.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
import dataclasses

from corems.encapsulation.factory.processingSetting import LiquidChromatographSetting, MolecularFormulaSearchSettings, TransientSetting, MassSpecPeakSetting, MassSpectrumSetting
from corems.encapsulation.factory.processingSetting import CompoundSearchSettings, GasChromatographSetting
from corems.encapsulation.factory.processingSetting import DataInputSetting

def reset_ms_parameters():
"""Reset the MSParameter class to the default values"""
MSParameters.molecular_search = MolecularFormulaSearchSettings()
MSParameters.transient = TransientSetting()
MSParameters.mass_spectrum = MassSpectrumSetting()
MSParameters.ms_peak = MassSpecPeakSetting()
MSParameters.data_input = DataInputSetting()

def reset_gcms_parameters():
"""Reset the GCMSParameters class to the default values"""
GCMSParameters.molecular_search = CompoundSearchSettings()
GCMSParameters.gc_ms = GasChromatographSetting()

def reset_lcms_parameters():
"""Reset the LCMSParameters class to the default values"""
LCMSParameters.lc_ms = LiquidChromatographSetting()
LCMSParameters.mass_spectrum = MassSpectrumSetting()
LCMSParameters.ms_peak = MassSpecPeakSetting()
LCMSParameters.ms1_molecular_search = MolecularFormulaSearchSettings()
LCMSParameters.ms2_molecular_search = MolecularFormulaSearchSettings()

class MSParameters:
"""MSParameters class is used to store the parameters used for the processing of the mass spectrum
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.
Parameters
----------
use_defaults: bool, optional
if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
Attributes
-----------
molecular_search: MolecularFormulaSearchSettings
Expand All @@ -19,6 +47,11 @@ class MSParameters:
MassSpecPeakSetting object
data_input: DataInputSetting
DataInputSetting object
Notes
-----
One can use the use_defaults parameter to reset the parameters to the default values.
Alternatively, to use the current values - modify the class's contents before instantiating the class.
"""

molecular_search = MolecularFormulaSearchSettings()
Expand All @@ -27,27 +60,64 @@ class MSParameters:
ms_peak = MassSpecPeakSetting()
data_input = DataInputSetting()

def __init__(self, use_defaults = False) -> None:
if not use_defaults:
self.molecular_search = dataclasses.replace(MSParameters.molecular_search)
self.transient = dataclasses.replace(MSParameters.transient)
self.mass_spectrum = dataclasses.replace(MSParameters.mass_spectrum)
self.ms_peak = dataclasses.replace(MSParameters.ms_peak)
self.data_input = dataclasses.replace(MSParameters.data_input)
else:
self.molecular_search = MolecularFormulaSearchSettings()
self.transient = TransientSetting()
self.mass_spectrum = MassSpectrumSetting()
self.ms_peak = MassSpecPeakSetting()
self.data_input = DataInputSetting()

class GCMSParameters:
"""GCMSParameters class is used to store the parameters used for the processing of the gas chromatograph mass spectrum
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.
Parameters
----------
use_defaults: bool, optional
if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
Attributes
-----------
molecular_search: MolecularFormulaSearchSettings
MolecularFormulaSearchSettings object
gc_ms: GasChromatographSetting
GasChromatographSetting object
Notes
-----
One can use the use_defaults parameter to reset the parameters to the default values.
Alternatively, to use the current values - modify the class's contents before instantiating the class.
"""

molecular_search = CompoundSearchSettings()
gc_ms = GasChromatographSetting()

def __init__(self, use_defaults = False) -> None:
if not use_defaults:
self.molecular_search = dataclasses.replace(GCMSParameters.molecular_search)
self.gc_ms = dataclasses.replace(GCMSParameters.gc_ms)
else:
self.molecular_search = CompoundSearchSettings()
self.gc_ms = GasChromatographSetting()

class LCMSParameters:
"""LCMSParameters class is used to store the parameters used for the processing of the liquid chromatograph mass spectrum
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.
Parameters
----------
use_defaults: bool, optional
if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
Attributes
-----------
lc_ms: LiquidChromatographSetting
Expand All @@ -60,17 +130,32 @@ class LCMSParameters:
MolecularFormulaSearchSettings object
ms2_molecular_search: MolecularFormulaSearchSettings
MolecularFormulaSearchSettings object
Notes
-----
One can use the use_defaults parameter to reset the parameters to the default values.
Alternatively, to use the current values - modify the class's contents before instantiating the class.
"""
lc_ms = LiquidChromatographSetting()

mass_spectrum = MassSpectrumSetting()

ms_peak = MassSpecPeakSetting()

ms1_molecular_search = MolecularFormulaSearchSettings()

ms2_molecular_search = MolecularFormulaSearchSettings()

def __init__(self, use_defaults = False) -> None:
if not use_defaults:
self.lc_ms = dataclasses.replace(LCMSParameters.lc_ms)
self.mass_spectrum = dataclasses.replace(LCMSParameters.mass_spectrum)
self.ms_peak = dataclasses.replace(LCMSParameters.ms_peak)
self.ms1_molecular_search = dataclasses.replace(LCMSParameters.ms1_molecular_search)
self.ms2_molecular_search = dataclasses.replace(LCMSParameters.ms2_molecular_search)
else:
self.lc_ms = LiquidChromatographSetting()
self.mass_spectrum = MassSpectrumSetting()
self.ms_peak = MassSpecPeakSetting()
self.ms1_molecular_search = MolecularFormulaSearchSettings()
self.ms2_molecular_search = MolecularFormulaSearchSettings()

def default_parameters(file_location): # pragma: no cover
"""Generate parameters dictionary with the default parameters for data processing
To gather parameters from instrument data during the data parsing step, a parameters dictionary with the default parameters needs to be generated.
Expand Down
2 changes: 1 addition & 1 deletion docs/corems.html
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ <h2 id="citing-corems">Citing CoreMS</h2>
<label class="view-source-button" for="mod-corems-view-source"><span>View Source</span></label>

<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>
</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>
</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>
</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>
</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>
</span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a>
Expand Down
Loading

0 comments on commit 29431b1

Please sign in to comment.