matchms.networking.networking_functions module

Helper functions to build and handle spectral networks

matchms.networking.networking_functions.get_top_hits(scores: <module 'matchms.Scores' from '/home/docs/checkouts/readthedocs.org/user_builds/matchms/checkouts/latest/readthedocs/../matchms/Scores.py'>, identifier_key: str = 'spectrum_id', top_n: int = 25, search_by: str = 'queries', ignore_diagonal: bool = False) Tuple[dict, dict][source]

Get top_n highest scores (and indices) for every entry.

Parameters
  • scores – Matchms Scores object containing all similarities.

  • identifier_key – Metadata key for unique intentifier for each spectrum in scores. Will also be used for the naming the network nodes. Default is ‘spectrum_id’.

  • top_n – Return the indexes and scores for the top_n highest scores. Scores between a spectrum with itself (diagonal of scores.scores) will not be taken into account.

  • search_by – Chose between ‘queries’ or ‘references’ which decides if the top_n matches for every spectrum in scores.queries or in scores.references will be collected and returned

  • ignore_diagonal – Set to True if scores.scores is symmetric (i.e. if references and queries were the same) and if scores between spectra with themselves should be excluded.