vermouth.utils module

Provides several generic utility functions


Returns True if and only if all elements in iterable are equal; and False otherwise.

Parameters:iterable ( – The container whose elements will be checked.
Returns:True iff all elements in iterable compare equal, False otherwise.
Return type:bool
vermouth.utils.are_different(left, right)[source]

Return True if two values are different from one another.

Values are considered different if they do not share the same type. In case of numerical value, the comparison is done with numpy.isclose() to account for rounding. In the context of this test, nan compares equal to itself, which is not the default behavior.

The order of mappings (dicts) is assumed to be irrelevant, so two dictionaries are not different if the only difference is the order of the keys.


Returns the first ASCII letter.

Parameters:string (str) – The string in which to look for the first ASCII letter.
Return type:str
Raises:ValueError – No ASCII letter was found in ‘search_string’.
vermouth.utils.format_atom_string(node, atomid='', chain='', resname='', resid='', atomname='')[source]
vermouth.utils.maxes(iterable, key=<function <lambda>>)[source]

Analogous to max, but returns a list of all maxima.

>>> all(key(elem) == max(iterable, key=key) for elem in iterable)
  • iterable ( – The iterable for which to find all maxima.
  • key ( – This callable will be called on each element of iterable to evaluate it to a value. Return values must support > and ==.

A list of all maximal values.

Return type: