Skip to content

Commit

Permalink
Remove Citation info from data model
Browse files Browse the repository at this point in the history
  • Loading branch information
torogi94 committed Apr 19, 2024
1 parent c257023 commit 478f846
Show file tree
Hide file tree
Showing 29 changed files with 270 additions and 956 deletions.
52 changes: 50 additions & 2 deletions nmrpy/data_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from sdRDM import DataModel
from sdRDM.base.importedmodules import ImportedModules
from nmrpy.datamodel.core import *
from nmrpy.utils import create_enzymeml


class Base:
Expand Down Expand Up @@ -514,10 +515,24 @@ def deconvoluted_integrals(self):
"""
if self._deconvoluted_peaks is not None:
integrals = []
i = 0
for peak in self._deconvoluted_peaks:
int_gauss = peak[-1] * Fid._f_gauss_int(peak[3], peak[1])
int_lorentz = (1 - peak[-1]) * Fid._f_lorentz_int(peak[3], peak[2])
integrals.append(int_gauss + int_lorentz)

for peak_identity in self.fid_object.peak_identities:
if peak_identity.name == self.identities[i]:
try:
peak_identity.associated_integrals.append(
float(integrals[i])
)
except:
peak_identity.associated_integrals = []
peak_identity.associated_integrals.append(
float(integrals[i])
)
i += 1
return integrals

def _get_plots(self):
Expand Down Expand Up @@ -1509,6 +1524,24 @@ def enzymeml_library(self):
del self.__enzymeml_library
print("The current EnzymeML library has been deleted.")

@property
def concentrations(self):
"""
An array of the concentration for each FID.
"""
return self.__c

@concentrations.setter
def concentrations(self, c):
if not isinstance(c, dict):
raise TypeError("c must be a dictionary.")
self.__c = c

@concentrations.deleter
def concentrations(self):
del self.__c
print("The current concentrations have been deleted.")

def __str__(self):
return "FidArray of {} FID(s)".format(len(self.data))

Expand Down Expand Up @@ -1568,6 +1601,7 @@ def _get_widgets(self):
or isinstance(self.__dict__[id], FidArrayRangeSelector)
or isinstance(self.__dict__[id], DataTraceRangeSelector)
or isinstance(self.__dict__[id], DataTraceSelector)
or isinstance(self.__dict__[id], IdentityRangeAssigner)
]
return widgets

Expand Down Expand Up @@ -2325,14 +2359,22 @@ def save_to_file(self, filename=None, overwrite=False):
self._del_widgets()
for fid in self.get_fids():
fid._del_widgets()
# delete EnzymeML library & document (can't be pickled)
try:
del self.enzymeml_library
del self.enzymeml_document
except:
pass
with open(filename, "wb") as f:
pickle.dump(self, f)

# TODO: Will probably create a measurement object for each FID(?)
# and add them to the EnzymeML document provided
# Issue: How to get species for IdentityAssigner? __init__()?
def add_to_enzymeml(self, enzymeml_document=None) -> None:
...
def to_enzymeml(self, enzymeml_document: DataModel = None) -> DataModel:
if not enzymeml_document:
enzymeml_document = self.enzymeml_document
return create_enzymeml(self, enzymeml_document)

# TODO: Refactor save_data method
# possibly make saving to EnzymeML a get_measurements method
Expand Down Expand Up @@ -2409,6 +2451,12 @@ def clear_identities(self):
for fid in self.get_fids():
fid.identities = None

def calculate_concentrations(self):
integrals = self.deconvoluted_integrals.transpose()
self._concentration_widget = ConcentrationCalculator(
fid_array=self, integrals=integrals
)


class Importer(Base):
def __init__(self, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions nmrpy/datamodel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

__URL__ = "https://github.com/NMRPy/nmrpy"
__COMMIT__ = "dec2cda6676f8d04070715fe079ed786515ea918"
__URL__ = ""
__COMMIT__ = ""
13 changes: 1 addition & 12 deletions nmrpy/datamodel/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
from .processingsteps import ProcessingSteps
from .identity import Identity
from .fidarray import FIDArray
from .citation import Citation
from .person import Person
from .publication import Publication
from .cv import CV
from .term import Term
from .fileformats import FileFormats
from .subjects import Subjects
from .publicationtypes import PublicationTypes
from .identifiertypes import IdentifierTypes

__doc__ = ""

__all__ = [
"NMRpy",
"Experiment",
Expand All @@ -24,13 +19,7 @@
"ProcessingSteps",
"Identity",
"FIDArray",
"Citation",
"Person",
"Publication",
"CV",
"Term",
"FileFormats",
"Subjects",
"PublicationTypes",
"IdentifierTypes",
]
71 changes: 0 additions & 71 deletions nmrpy/datamodel/core/abstractspecies.py

This file was deleted.

Loading

0 comments on commit 478f846

Please sign in to comment.