libgunshotmatch.utils

Utility functions.

Functions:

create_alignment(peakpos, expr_code[, …])

Create a new pyms.DPA.Alignment.Alignment object.

get_rt_range(project)

Returns the minimum and maximum retention times (in minutes) across the repeats.

get_truncated_normal(mean, sd[, low, upp, …])

Returns count values from a truncated normal distrubition.

ms_comparison(top_ms, bottom_ms)

Performs a Mass Spectrum similarity calculation two mass spectra.

round_rt(rt)

Truncate precision of retention time to 10 decimal places.

create_alignment(peakpos, expr_code, similarity=0)[source]

Create a new pyms.DPA.Alignment.Alignment object.

Parameters
  • peakpos (Sequence[Sequence[Optional[Peak]]]) – Nested list of aligned peaks. Top level list contains lists of peaks for each experiment in expr_code.

  • expr_code (List[str]) – Experiment names. Order must match peakpos.

  • similarity (float) – Default 0.

Return type

Alignment

New in version 0.8.0.

get_rt_range(project)[source]

Returns the minimum and maximum retention times (in minutes) across the repeats.

Parameters

project (Project)

Return type

Tuple[float, float]

New in version 0.7.0.

get_truncated_normal(mean, sd, low=0, upp=10, count=10, random_state=None)[source]

Returns count values from a truncated normal distrubition.

Parameters
  • mean (float) – The midpoint of the normal distribution.

  • sd (float) – The spread of the normal distribution (the standard deviation).

  • low (float) – The lower bound. Default 0.

  • upp (float) – The upper bound. Default 10.

  • count (int) – Default 10.

  • random_state (Optional[int]) – Optional seed for the random number generator. Default None.

Return type

Sequence[float]

ms_comparison(top_ms, bottom_ms)[source]

Performs a Mass Spectrum similarity calculation two mass spectra.

Parameters

If either of top_ms or bottom_ms is None then None is returned, otherwise a comparison score is returned.

Return type

Optional[float]

round_rt(rt)[source]

Truncate precision of retention time to 10 decimal places.

Parameters

rt (Union[str, float, Decimal])

Return type

Decimal