ms2pip.result

Definition and handling of MS²PIP results.

class ms2pip.result.ProcessingResult(*, psm_index, psm=None, theoretical_mz=None, predicted_intensity=None, observed_intensity=None, correlation=None, feature_vectors=None)[source]

Bases: BaseModel

Result of processing a single PSM.

Parameters:
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

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

as_spectra()[source]

Convert result to predicted and observed spectra.

Return type:

Tuple[PredictedSpectrum | None, ObservedSpectrum | None]

plot_spectra()[source]

Plot predicted and observed spectra.

Return type:

matplotlib.axes.Axes

Notes

Requires optional dependency spectrum_utils to be installed.

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_fields: ClassVar[Dict[str, FieldInfo]] = {'correlation': FieldInfo(annotation=Union[float, NoneType], required=False, default=None), 'feature_vectors': FieldInfo(annotation=Union[ndarray, NoneType], required=False, default=None), 'observed_intensity': FieldInfo(annotation=Union[Dict[str, numpy.ndarray], NoneType], required=False, default=None), 'predicted_intensity': FieldInfo(annotation=Union[Dict[str, numpy.ndarray], NoneType], required=False, default=None), 'psm': FieldInfo(annotation=Union[PSM, NoneType], required=False, default=None), 'psm_index': FieldInfo(annotation=int, required=True), 'theoretical_mz': FieldInfo(annotation=Union[Dict[str, numpy.ndarray], NoneType], required=False, default=None)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

ms2pip.result.calculate_correlations(results)[source]

Calculate and add Pearson correlations to list of results.

Parameters:

results (List[ProcessingResult]) –

Return type:

None

ms2pip.result.write_correlations(results, output_file)[source]

Write correlations to CSV file.

Parameters:
Return type:

None