mkt.databases.pssm.consurf_grades

mkt.databases.pssm.consurf_grades(scores: list[float | None], n_bins: int = 9, bool_ascending: bool = True) list[int | None][source]

Assign ConSurf-style discrete conservation grades to continuous scores.

Bins the finite scores into n_bins equal-frequency (quantile) grades – the scheme ConSurf uses to turn a continuous conservation score into a small ordinal scale. With bool_ascending (higher score = more conserved, e.g. information content or percent identity) the most-conserved bin is grade n_bins and the most-variable is grade 1; pass bool_ascending=False for rate-type scores where lower = more conserved (e.g. Rate4Site). Grade n_bins is always the most conserved end regardless.

Parameters:
  • scores (list[float | None]) – Per-position conservation scores; None/NaN entries get grade None.

  • n_bins (int) – Number of grades (default 9, the ConSurf convention).

  • bool_ascending (bool) – Whether a higher score means more conserved (default True).

Returns:

One grade in 1..n_bins per input score (None where the score was missing).

Return type:

list[int | None]