pychemstation.utils.sequence_types

 1from __future__ import annotations
 2
 3import os.path
 4from enum import Enum
 5from typing import Optional, List
 6from dataclasses import dataclass, field
 7from pychemstation.utils.tray_types import Tray
 8
 9
10@dataclass
11class SequenceDataFiles:
12    """Class to represent files generated during a sequence.
13
14    :param sequence_name: the name of the sequence that is running
15    :param dir: the complete path of the directory generated for the sequence
16    :param child_dirs: the complete path of the files for sequence runs, contains the Chemstation data, `dir` and the sample run file.
17    """
18
19    sequence_name: str
20    dir: str
21    child_dirs: List[str] = field(default_factory=list)
22
23
24class SampleType(Enum):
25    SAMPLE = 1
26    BLANK = 2
27    CALIBRATION = 3
28    CONTROL = 4
29
30    @classmethod
31    def _missing_(cls, value):
32        return cls.SAMPLE
33
34
35class InjectionSource(Enum):
36    AS_METHOD = "As Method"
37    MANUAL = "Manual"
38    MSD = "MSD"
39    HIP_ALS = "HipAls"
40
41    @classmethod
42    def _missing_(cls, value):
43        return cls.HIP_ALS
44
45
46@dataclass
47class SequenceEntry:
48    """Class to represent each row of a sequence file, maps one to one to Chemstation."""
49
50    data_file: str
51    vial_location: Tray
52    sample_name: Optional[str] = None
53    method: Optional[str] = None
54    num_inj: Optional[int] = 1
55    inj_vol: Optional[float] = 2
56    inj_source: Optional[InjectionSource] = InjectionSource.HIP_ALS
57    sample_type: Optional[SampleType] = SampleType.SAMPLE
58
59
60@dataclass
61class SequenceTable:
62    """Class to represent a sequence file.
63
64    :param name: name of the sequence
65    :param rows: the entries
66    """
67
68    name: str
69    rows: list[SequenceEntry]
70
71    def __eq__(self, other) -> bool:
72        if not isinstance(other, SequenceTable):
73            return False
74
75        equal = True
76        for self_row, other_row in zip(self.rows, other.rows):
77            equal &= self_row.vial_location == other_row.vial_location
78            equal &= self_row.data_file == other_row.data_file
79            if self_row.method and other_row.method:
80                equal &= (
81                    os.path.split(os.path.normpath(self_row.method))[-1]
82                    == os.path.split(os.path.normpath(other_row.method))[-1]
83                )
84            equal &= self_row.num_inj == other_row.num_inj
85            equal &= self_row.inj_vol == other_row.inj_vol
86            equal &= self_row.inj_source == other_row.inj_source
87            equal &= self_row.sample_name == other_row.sample_name
88            equal &= self_row.sample_type == other_row.sample_type
89        return equal
@dataclass
class SequenceDataFiles:
11@dataclass
12class SequenceDataFiles:
13    """Class to represent files generated during a sequence.
14
15    :param sequence_name: the name of the sequence that is running
16    :param dir: the complete path of the directory generated for the sequence
17    :param child_dirs: the complete path of the files for sequence runs, contains the Chemstation data, `dir` and the sample run file.
18    """
19
20    sequence_name: str
21    dir: str
22    child_dirs: List[str] = field(default_factory=list)

Class to represent files generated during a sequence.

Parameters
  • sequence_name: the name of the sequence that is running
  • dir: the complete path of the directory generated for the sequence
  • child_dirs: the complete path of the files for sequence runs, contains the Chemstation data, dir and the sample run file.
SequenceDataFiles(sequence_name: str, dir: str, child_dirs: List[str] = <factory>)
sequence_name: str
dir: str
child_dirs: List[str]
class SampleType(enum.Enum):
25class SampleType(Enum):
26    SAMPLE = 1
27    BLANK = 2
28    CALIBRATION = 3
29    CONTROL = 4
30
31    @classmethod
32    def _missing_(cls, value):
33        return cls.SAMPLE
SAMPLE = <SampleType.SAMPLE: 1>
BLANK = <SampleType.BLANK: 2>
CALIBRATION = <SampleType.CALIBRATION: 3>
CONTROL = <SampleType.CONTROL: 4>
class InjectionSource(enum.Enum):
36class InjectionSource(Enum):
37    AS_METHOD = "As Method"
38    MANUAL = "Manual"
39    MSD = "MSD"
40    HIP_ALS = "HipAls"
41
42    @classmethod
43    def _missing_(cls, value):
44        return cls.HIP_ALS
AS_METHOD = <InjectionSource.AS_METHOD: 'As Method'>
MANUAL = <InjectionSource.MANUAL: 'Manual'>
MSD = <InjectionSource.MSD: 'MSD'>
HIP_ALS = <InjectionSource.HIP_ALS: 'HipAls'>
@dataclass
class SequenceEntry:
47@dataclass
48class SequenceEntry:
49    """Class to represent each row of a sequence file, maps one to one to Chemstation."""
50
51    data_file: str
52    vial_location: Tray
53    sample_name: Optional[str] = None
54    method: Optional[str] = None
55    num_inj: Optional[int] = 1
56    inj_vol: Optional[float] = 2
57    inj_source: Optional[InjectionSource] = InjectionSource.HIP_ALS
58    sample_type: Optional[SampleType] = SampleType.SAMPLE

Class to represent each row of a sequence file, maps one to one to Chemstation.

SequenceEntry( data_file: str, vial_location: Union[pychemstation.utils.tray_types.FiftyFourVialPlate, pychemstation.utils.tray_types.VialBar, pychemstation.utils.tray_types.LocationPlus], sample_name: Optional[str] = None, method: Optional[str] = None, num_inj: Optional[int] = 1, inj_vol: Optional[float] = 2, inj_source: Optional[InjectionSource] = <InjectionSource.HIP_ALS: 'HipAls'>, sample_type: Optional[SampleType] = <SampleType.SAMPLE: 1>)
data_file: str
sample_name: Optional[str] = None
method: Optional[str] = None
num_inj: Optional[int] = 1
inj_vol: Optional[float] = 2
inj_source: Optional[InjectionSource] = <InjectionSource.HIP_ALS: 'HipAls'>
sample_type: Optional[SampleType] = <SampleType.SAMPLE: 1>
@dataclass
class SequenceTable:
61@dataclass
62class SequenceTable:
63    """Class to represent a sequence file.
64
65    :param name: name of the sequence
66    :param rows: the entries
67    """
68
69    name: str
70    rows: list[SequenceEntry]
71
72    def __eq__(self, other) -> bool:
73        if not isinstance(other, SequenceTable):
74            return False
75
76        equal = True
77        for self_row, other_row in zip(self.rows, other.rows):
78            equal &= self_row.vial_location == other_row.vial_location
79            equal &= self_row.data_file == other_row.data_file
80            if self_row.method and other_row.method:
81                equal &= (
82                    os.path.split(os.path.normpath(self_row.method))[-1]
83                    == os.path.split(os.path.normpath(other_row.method))[-1]
84                )
85            equal &= self_row.num_inj == other_row.num_inj
86            equal &= self_row.inj_vol == other_row.inj_vol
87            equal &= self_row.inj_source == other_row.inj_source
88            equal &= self_row.sample_name == other_row.sample_name
89            equal &= self_row.sample_type == other_row.sample_type
90        return equal

Class to represent a sequence file.

Parameters
  • name: name of the sequence
  • rows: the entries
SequenceTable( name: str, rows: list[SequenceEntry])
name: str
rows: list[SequenceEntry]