Skip to content

Metadata

tdfpy.MetaData dataclass

MetaData(df: pd.DataFrame)

Bases: _KeyDf

Example GlobalMetaData table keys:

SchemaType                  TDF
SchemaVersionMajor          3
SchemaVersionMinor          1
AcquisitionSoftwareVendor   Bruker
InstrumentVendor            Bruker
TimsCompressionType         2
ClosedProperly              1
MaxNumPeaksPerScan          1412
AnalysisId                  00000000-0000-0000-0000-000000000000
MzAcqRangeLower             100.000000
MzAcqRangeUpper             1700.000000
OneOverK0AcqRangeLower      0.578703
OneOverK0AcqRangeUpper      1.524471
AcquisitionSoftware         Bruker otofControl
AcquisitionSoftwareVersion  5.1.81.714-13047-vc110
AcquisitionDateTime         2018-08-21T20:40:14.356+02:00
InstrumentName              timsTOF Pro
InstrumentSerialNumber      1844426.34
OperatorName                Demo User
SampleName                  200ngHeLaDIAPASEF_CE8V1st10VPASEF

schema_type property

schema_type: str

Schema type (typically 'TDF').

schema_version_major property

schema_version_major: int

Major version of the TDF schema.

schema_version_minor property

schema_version_minor: int

Minor version of the TDF schema.

acquisition_software_vendor property

acquisition_software_vendor: str

Vendor of acquisition software.

instrument_vendor property

instrument_vendor: str

Instrument vendor.

tims_compression_type property

tims_compression_type: int

TIMS data compression type.

closed_properly property

closed_properly: bool

Whether the acquisition was closed properly.

max_num_peaks_per_scan property

max_num_peaks_per_scan: int

Maximum number of peaks per scan.

analysis_id property

analysis_id: str

Analysis UUID.

digitizer_num_samples property

digitizer_num_samples: int

Number of digitizer samples.

peak_list_index_scale_factor property

peak_list_index_scale_factor: int

Peak list index scale factor.

mz_acq_range_lower property

mz_acq_range_lower: float

Lower m/z acquisition range.

mz_acq_range_upper property

mz_acq_range_upper: float

Upper m/z acquisition range.

mz_acq_range property

mz_acq_range: tuple[float, float]

M/z acquisition range as (lower, upper) tuple.

one_over_k0_acq_range_lower property

one_over_k0_acq_range_lower: float

Lower 1/K0 acquisition range.

one_over_k0_acq_range_upper property

one_over_k0_acq_range_upper: float

Upper 1/K0 acquisition range.

one_over_k0_acq_range property

one_over_k0_acq_range: tuple[float, float]

1/K0 acquisition range as (lower, upper) tuple.

acquisition_software property

acquisition_software: str

Acquisition software name.

acquisition_software_version property

acquisition_software_version: str

Acquisition software version.

acquisition_firmware_version property

acquisition_firmware_version: str

Acquisition firmware version.

acquisition_datetime property

acquisition_datetime: datetime.datetime

Acquisition date and time.

instrument_name property

instrument_name: str

Instrument name.

instrument_family property

instrument_family: int

Instrument family code.

instrument_revision property

instrument_revision: int

Instrument revision number.

instrument_source_type property

instrument_source_type: int

Instrument source type code.

instrument_serial_number property

instrument_serial_number: str

Instrument serial number.

operator_name property

operator_name: str

Operator name.

description property

description: str

Sample/acquisition description.

sample_name property

sample_name: str

Sample name.

method_name property

method_name: str

Acquisition method name.

tdfpy.Calibration dataclass

Calibration(df: pd.DataFrame)

Bases: _KeyDf

Example Calibration table keys:

CalibrationDateTime              2018-08-21T16:50:31+02:00
CalibrationUser                  Demo User
CalibrationSoftware              Bruker otofControl
CalibrationSoftwareVersion       5.1.81.714-13047
MzCalibrationMode                3
MzStandardDeviationPPM           0.130754
ReferenceMassList                Tuning Mix ES-TOF (ESI)
MobilityCalibrationDateTime      2018-08-21T16:49:17+02:00
MobilityCalibrationUser          Demo User
MobilityStandardDeviationPercent 0.000932
ReferenceMobilityList            Tuning Mix ES-TOF (ESI)

tdfpy.elems.Polarity

Bases: StrEnum

from_str staticmethod

from_str(s: str) -> Polarity

Convert a string to a Polarity enum value.

Parameters:

Name Type Description Default
s str

Polarity string. Accepted values (case-insensitive): "positive" or "+"Polarity.POSITIVE; "negative" or "-"Polarity.NEGATIVE; "unknown" or "?"Polarity.UNKNOWN; "mixed" or "mix"Polarity.MIXED.

required

Returns:

Type Description
Polarity

The matching Polarity enum member.

Raises:

Type Description
ValueError

If the string does not match any known polarity.

Source code in src/tdfpy/elems.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@staticmethod
def from_str(s: str) -> "Polarity":
    """Convert a string to a `Polarity` enum value.

    Args:
        s: Polarity string. Accepted values (case-insensitive):
            `"positive"` or `"+"` → `Polarity.POSITIVE`;
            `"negative"` or `"-"` → `Polarity.NEGATIVE`;
            `"unknown"` or `"?"` → `Polarity.UNKNOWN`;
            `"mixed"` or `"mix"` → `Polarity.MIXED`.

    Returns:
        The matching `Polarity` enum member.

    Raises:
        ValueError: If the string does not match any known polarity.
    """
    s = s.lower()
    if s in ("positive", "+"):
        return Polarity.POSITIVE
    elif s in ("negative", "-"):
        return Polarity.NEGATIVE
    elif s in ("unknown", "unkown", "?"):
        return Polarity.UNKNOWN
    elif s in ("mixed", "mix"):
        return Polarity.MIXED
    else:
        raise ValueError(f"Unknown polarity string: {s}")