Skip to content

Commit

Permalink
Refactor import statements for PlateManager class
Browse files Browse the repository at this point in the history
  • Loading branch information
haeussma committed Sep 16, 2024
1 parent 24b5dbd commit f8a381f
Show file tree
Hide file tree
Showing 41 changed files with 21,997 additions and 1,587 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
with:
path: .cache
key: ${{ github.ref }}
- run: pip install mkdocs-material
- run: pip install mkdocs-material mkdocs-plotly-plugin mkdocstrings-python
- run: mkdocs gh-deploy --force
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ poetry.lock
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# DS_Store files
.DS_Store

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

Expand Down
2 changes: 1 addition & 1 deletion MTPHandler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import os

from MTPHandler import PlateManager
from MTPHandler.plate_manager import PlateManager
2 changes: 1 addition & 1 deletion MTPHandler/ioutils/calipytion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from calipytion.model import Sample, SignalType, Standard, UnitDefinition
from calipytion.tools.calibrator import Calibrator

from MTPHandler.dataclasses import Molecule, Plate, Protein, Species, Well
from MTPHandler.model import Molecule, Plate, Protein, Species, Well
from MTPHandler.tools import (
get_measurement,
get_species_condition,
Expand Down
34 changes: 17 additions & 17 deletions MTPHandler/ioutils/pyenzyme.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,36 @@
from datetime import datetime
from typing import Dict, List, Optional

import numpy as np

# from calipytion.core import Standard
import pyenzyme as pe
from pyenzyme.model import DataTypes

from MTPHandler.dataclasses import Molecule, Plate, Protein, Species, Well
from calipytion.model import Standard
from pyenzyme.model import DataTypes

import numpy as np

from MTPHandler.model import Molecule, Plate, Protein, Species, Well
from MTPHandler.tools import get_measurement


class Plate_to_EnzymeMLDocument:

def __init__(
self,
plate: Plate,
measured_molecule: Molecule,
standard: Optional[Standard] = None,
) -> None:

assert measured_molecule or standard, (
"Either a measured molecule or a standard must be provided."
)
assert (
measured_molecule or standard
), "Either a measured molecule or a standard must be provided."

self.plate = plate
self.measured_molecule = measured_molecule
self.standard = standard


@property
def temperature(self) -> float:
return np.mean(self.plate.temperatures).tolist()


@staticmethod
def map_protein(protein: Protein) -> pe.Protein:
return pe.Protein(**protein.model_dump())
Expand All @@ -50,17 +45,20 @@ def map_small_molecule(molecule: Molecule) -> pe.SmallMolecule:
canonical_smiles=molecule.smiles,
)

def map_measurement_data(self, well: Well, wavelength: float) -> list[pe.MeasurementData]:

def map_measurement_data(
self, well: Well, wavelength: float
) -> list[pe.MeasurementData]:
measurement = pe.Measurement(
id=well.id,
name=f"{self.measured_molecule.name}", #type: ignore
name=f"{self.measured_molecule.name}", # type: ignore
ph=well.ph,
temperature=self.temperature,
)

photo_meas = get_measurement(well, wavelength)
data_type = pe.DataTypes.ABSORPTION if not self.standard else pe.DataTypes.CONCENTRATION
data_type = (
pe.DataTypes.ABSORPTION if not self.standard else pe.DataTypes.CONCENTRATION
)

for meas in well.init_conditions:
if meas.species_id == self.measured_molecule.id:
Expand All @@ -71,7 +69,9 @@ def map_measurement_data(self, well: Well, wavelength: float) -> list[pe.Measure
measurement.add_to_species(
species_id=meas.species_id,
init_conc=meas.init_conc,
data_type=DataTypes.ABSORPTION if is_measured_species else DataTypes.CONCENTRATION,
data_type=DataTypes.ABSORPTION
if is_measured_species
else DataTypes.CONCENTRATION,
data_unit=photo_meas.data_unit,
data=photo_meas.absorption if is_measured_species else [],
time=photo_meas.time if is_measured_species else [],
Expand Down
Loading

0 comments on commit f8a381f

Please sign in to comment.