ms2pip.spectrum

MS2 spectrum handling.

class ms2pip.spectrum.Spectrum(*, mz, intensity, annotations=None, identifier=None, peptidoform=None, precursor_mz=None, precursor_charge=None, retention_time=None, mass_tolerance=None, mass_tolerance_unit=None)[source]

Bases: BaseModel

MS2 spectrum.

Parameters:
  • mz (np.ndarray) – Array of m/z values.

  • intensity (np.ndarray) – Array of intensity values.

  • annotations (Optional[np.ndarray]) – Array of peak annotations.

  • identifier (Optional[str]) – Spectrum identifier.

  • peptidoform (Optional[Union[Peptidoform, str]]) – Peptidoform.

  • precursor_mz (Optional[float]) – Precursor m/z.

  • precursor_charge (Optional[int]) – Precursor charge.

  • retention_time (Optional[float]) – Retention time.

  • mass_tolerance (Optional[float]) – Mass tolerance for spectrum annotation.

  • mass_tolerance_unit (Optional[str]) – Unit of mass tolerance for spectrum annotation.

model_config = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property tic

Total ion current.

remove_reporter_ions(label_type=None)[source]

Set the intensity of reporter ions to 0.

Return type:

None

remove_precursor(tolerance=0.02)[source]

Set the intensity of the precursor peak to 0.

Return type:

None

tic_norm()[source]

Normalize spectrum to total ion current.

Return type:

None

log2_transform()[source]

Log2-tranform spectrum.

Return type:

None

clip_intensity(min_intensity=0.0)[source]

Clip intensity values.

Return type:

None

to_spectrum_utils()[source]

Convert to spectrum_utils.spectrum.MsmsSpectrum.

Notes

  • Requires spectrum_utils to be installed.

  • If the precursor_mz or precursor_charge attributes are not set, the theoretical m/z and precursor charge of the peptidoform attribute are used, if present. Otherwise, ValueError is raised.

class ms2pip.spectrum.ObservedSpectrum(*, mz, intensity, annotations=None, identifier=None, peptidoform=None, precursor_mz=None, precursor_charge=None, retention_time=None, mass_tolerance=None, mass_tolerance_unit=None)[source]

Bases: Spectrum

MS2 spectrum.

Parameters:
  • mz (ndarray) – Array of m/z values.

  • intensity (ndarray) – Array of intensity values.

  • annotations (ndarray | None) – Array of peak annotations.

  • identifier (str | None) – Spectrum identifier.

  • peptidoform (Peptidoform | str | None) – Peptidoform.

  • precursor_mz (float | None) – Precursor m/z.

  • precursor_charge (int | None) – Precursor charge.

  • retention_time (float | None) – Retention time.

  • mass_tolerance (float | None) – Mass tolerance for spectrum annotation.

  • mass_tolerance_unit (str | None) – Unit of mass tolerance for spectrum annotation.

model_config = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ms2pip.spectrum.PredictedSpectrum(*, mz, intensity, annotations=None, identifier=None, peptidoform=None, precursor_mz=None, precursor_charge=None, retention_time=None, mass_tolerance=0.001, mass_tolerance_unit='Da')[source]

Bases: Spectrum

MS2 spectrum.

Parameters:
  • mz (ndarray) – Array of m/z values.

  • intensity (ndarray) – Array of intensity values.

  • annotations (ndarray | None) – Array of peak annotations.

  • identifier (str | None) – Spectrum identifier.

  • peptidoform (Peptidoform | str | None) – Peptidoform.

  • precursor_mz (float | None) – Precursor m/z.

  • precursor_charge (int | None) – Precursor charge.

  • retention_time (float | None) – Retention time.

  • mass_tolerance (Optional[float]) – Mass tolerance for spectrum annotation.

  • mass_tolerance_unit (Optional[str]) – Unit of mass tolerance for spectrum annotation.

model_config = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].