matchms.filtering.add_retention module

matchms.filtering.add_retention.add_retention_index(spectrum_in: Spectrum) Spectrum[source]

Add retention index into ‘retention_index’ key if present.

Parameters

spectrum – Spectrum with RI information.

Return type

Spectrum with RI info stored under ‘retention_index’.

matchms.filtering.add_retention.add_retention_time(spectrum_in: Spectrum) Spectrum[source]

Add retention time information to the ‘retention_time’ key as float. Negative values and those not convertible to a float result in ‘retention_time’ being ‘None’.

Parameters

spectrum – Spectrum with retention time information.

Return type

Spectrum with harmonized retention time information.

matchms.filtering.add_retention.safe_convert_to_float(value: Any) Optional[float][source]

Safely convert value to float. Return ‘None’ on failure.

Parameters

value – Object to convert to float.

Return type

Converted float value or ‘None’ if conversion is not possible.

matchms.filtering.add_retention.safe_store_value(metadata: dict, value: Any, target_key: str) dict[source]

Helper function to safely store a value in the target key without throwing an exception, but storing ‘None’ instead.

Parameters
  • spectrum – Spectrum to which to add ‘value’ in ‘target_key’.

  • value – Value to parse into ‘target_key’.

  • target_key – Name of the key in which to store the value.

Return type

Spectrum with added key.