massdash.structs.TransitionGroup

class massdash.structs.TransitionGroup(precursorData: List[Chromatogram] | List[Mobilogram] | List[Spectrum], transitionData: List[Chromatogram] | List[Mobilogram] | List[Spectrum], sequence: str = None, precursor_charge: int = None)

Bases: object

A Transition Group which contains a list of precursor and transition data. Precursor and Transition data must be a Chromatogram, Mobilogram or Spectrum object.

adjust_length(length: int) None

Adjusts the length size of the chromatograms, mobilograms, and spectra.

If the length is smaller than the current length, the data will be sliced to the given length. If the length is larger than the current length, the data will be padded with zeros on both sides.

E.g. if the data array is [1, 2, 3] and the desired length is 7, the returned array will be [0, 0, 1, 2, 3, 0, 0].

E.g. if the data array is [1, 2, 3] and the desired length is 1, the returned data array will be [1].

Parameters:

length (int) – The length of the output array

Returns:

A new TransitionGroup object with padded data and intensity.

Return type:

TransitionGroup

empty() bool

Check if the TransitionGroup is empty.

Returns:

True if all of the chromatograms, mobilograms, and spectra are empty, False otherwise.

Return type:

bool

flatten(level: Literal['ms1', 'ms2', 'ms1ms2'] | None = 'ms2') Chromatogram | Mobilogram | Spectrum

Flatten the TransitionGroup into a single Data1D object.

Parameters:

level (str) – The level of the data to sum. Must be one of [‘ms1’, ‘ms2’, ‘ms1ms2’].

Returns:

A single Data1D object containing the flattened data.

Return type:

Union[Chromatogram, Mobilogram, Spectrum]

Raises:

ValueError – Level must be one of [‘ms1’, ‘ms2’, ‘ms1ms2’]

max(boundary: Tuple[float, float], level: str | None = 'ms1ms2') float

Calculate the highest intensity within a given boundary.

Parameters:

boundary (tuple) – A tuple containing the left and right boundaries.

Returns:

The highest intensity within the given boundary.

Return type:

float

median(boundary: Tuple[float, float] | None = None, level: str | None = 'ms2') float

Calculate the median intensity of a given boundary in the 1D data.

Parameters:
  • chrom_data (list) – A list of tuples containing the retention time and intensity values of a chromatogram.

  • boundary (tuple) – A tuple containing the left and right boundaries of the region of interest.

Returns:

The median intensity value of the data points within the given boundary.

Return type:

float

Raises:

ValueError – Level must be one of [‘ms1’, ‘ms2’, ‘ms1ms2’]

plot(transitionGroupFeatures: List[TransitionGroupFeature] | None = None, smoothing: Literal['none', 'sgolay', 'gauss'] | None = 'none', gaussian_sigma: float = 2.0, gaussian_window: int = 11, sgolay_polynomial_order: int = 3, sgolay_frame_length: int = 11) None

Convenience function for plotting 1D data, meant for jupyter notebook context.

Parameters:
  • transitionGroupFeatures (Optional[List[TransitionGroupFeature]], optional) – list of transition group features include in plot. Defaults to None.

  • smoothing (Optional[Literal['none', 'sgolay', 'gauss']], optional) – Smoothing to apply on the plot. Defaults to ‘none’.

  • gaussian_sigma (float, optional) – sigma for gaussian plotting, ignored if smoothing is not ‘gauss’. Defaults to 2.0.

  • gaussian_window (int, optional) – window for gaussian plotting, ignored if smoothing is not ‘gauss’. Defaults to 11.

  • sgolay_polynomial_order (int, optional) – Polynomial order for sgolay, ignored if smoothing is not ‘sgolay’. Defaults to 3.

  • sgolay_frame_length (int, optional) – Frame length for sgolay, ignored if smoothing is not ‘sgolay’. Defaults to 11.

Raises:

ValueError – Unknown type of 1D data

sum(boundary: Tuple[float, float], level: Literal['ms1', 'ms2', 'ms1ms2'] | None = 'ms2') float

Calculates the integrated intensity of a chromatogram within a given boundary.

Parameters:
  • boundary (Tuple[float, float]) – _description_

  • level (Optional[Literal['ms1', 'ms2', 'ms1ms2' ]], optional) – The MS level of the data to sum. Defaults to ‘ms2’.

Returns:

The integrated intensity of the chromatogram within the given boundary

Return type:

float

Raises:

ValueError – Level must be one of [‘ms1’, ‘ms2’, ‘ms1ms2’]

toPandasDf(separate=False) DataFrame

Convert the TransitionGroup to a Pandas DataFrame.

Parameters:

separate (bool, optional) – If True, return separate DataFrames for precursor and transition data. Defaults to False.

Returns:

DataFrame representation of the TransitionGroup.

Return type:

pd.DataFrame

to_pyopenms(includePrecursors=True) _MRMTransitionGroupCPDF

Convert the TransitionGroup to an OpenMS TransitionGroup.

Parameters:

includePrecursors (bool, optional) – If True, include precursor in transition group. Note Precursor and transition chromatograms are not distinguished in this OpenMS representation. Defaults to True.

Returns:

An OpenMS TransitionGroup object, can invoke pyopenms methods on this object.

Return type:

po.MRMTransitionGroupCP

Raises:

ValueError – Cannot convert Spectrum to pyopenms TransitionGroup