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:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
mz (ndarray)
intensity (ndarray)
annotations (ndarray | None)
identifier (str | None)
peptidoform (Annotated[Peptidoform | None, BeforeValidator(func=~ms2pip.spectrum._coerce_peptidoform, json_schema_input_type=PydanticUndefined)])
precursor_mz (float | None)
precursor_charge (int | None)
retention_time (float | None)
mass_tolerance (float | None)
mass_tolerance_unit (str | None)
- 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
- inverse_log2_transform()[source]
Undo log2 transformation of intensities (inverse of
log2_transform()).- Return type:
None
- to_spectrum_utils()[source]
Convert to spectrum_utils.spectrum.MsmsSpectrum.
Notes
Requires spectrum_utils to be installed.
If the
precursor_mzorprecursor_chargeattributes are not set, the theoretical m/z and precursor charge of thepeptidoformattribute are used, if present. Otherwise,ValueErroris 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:
SpectrumCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
mz (ndarray)
intensity (ndarray)
annotations (ndarray | None)
identifier (str | None)
peptidoform (Annotated[Peptidoform | None, BeforeValidator(func=~ms2pip.spectrum._coerce_peptidoform, json_schema_input_type=PydanticUndefined)])
precursor_mz (float | None)
precursor_charge (int | None)
retention_time (float | None)
mass_tolerance (float | None)
mass_tolerance_unit (str | None)
- 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:
SpectrumCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
mz (ndarray)
intensity (ndarray)
annotations (ndarray | None)
identifier (str | None)
peptidoform (Annotated[Peptidoform | None, BeforeValidator(func=~ms2pip.spectrum._coerce_peptidoform, json_schema_input_type=PydanticUndefined)])
precursor_mz (float | None)
precursor_charge (int | None)
retention_time (float | None)
mass_tolerance (float | None)
mass_tolerance_unit (str | None)
- model_config = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].