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 (numpy.ndarray) – Array of m/z values.

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

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

  • identifier (str | None) – Spectrum identifier.

  • peptidoform (psm_utils.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.

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 (numpy.ndarray) – Array of m/z values.

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

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

  • identifier (str | None) – Spectrum identifier.

  • peptidoform (psm_utils.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.

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 (numpy.ndarray) – Array of m/z values.

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

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

  • identifier (str | None) – Spectrum identifier.

  • peptidoform (psm_utils.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.