This module contains the CosineAlignmentEngine class for aligning two spectra using cosine similarity.

class modifinder.engines.alignment.CosineAlignmentEngine.CosineAlignmentEngine(**kwargs)[source]

Bases: AlignmentEngine

align(network: DiGraph, mz_tolerance: float = 0.02, ppm_tolerance: float = 100.0, align_all: bool = False, **kwargs)[source]

Aligns the spectra in the network using cosine similarity.

Parameters:
  • network (nx.DiGraph) – The Compound Graph object to align the spectra in.

  • mz_tolerance (float, optional) – Fragment mz tolerance, by default 0.02

  • ppm_tolerance (float, optional) – Fragment ppm tolerance, by default 100.0

  • align_all (bool, default False) – if True, all edges will be aligned, if False, only the edges that have not been aligned will be aligned

  • kwargs (dict) – additional arguments

align_single(SpectrumTuple1: Spectrum, SpectrumTuple2: Spectrum, mz_tolerance: float = 0.02, ppm_tolerance: float = 100.0, **kwargs) EdgeDetail[source]

Aligns two spectra using cosine similarity and returns the cosine score and the matched peaks.

Parameters:
  • SpectrumTuple1 (SpectrumTuple) – First spectrum

  • SpectrumTuple2 (SpectrumTuple) – Second spectrum

  • mz_tolerance (float) – Fragment mz tolerance

  • ppm_tolerance (float) – Fragment ppm tolerance

  • kwargs – additional arguments

Returns:

the edge detail object

Return type:

EdgeDetail