common#
- class atomworks.io.common.KeyToIntMapper[source]#
Bases:
object
Maps keys to unique integers based on the order of the first appearance of the key.
This is useful for mapping id’s such as chain_id, chain_entity, molecule_iid, etc. to integers.
chain_id_to_int = KeyToIntMapper() chain_id_to_int(“A”) # 0 chain_id_to_int(“C”) # 1 chain_id_to_int(“A”) # 0 chain_id_to_int(“B”) # 2
- atomworks.io.common.deduplicate_iterator(iterator: Iterable) Iterator [source]#
Deduplicate an iterator while preserving order.
- atomworks.io.common.immutable_lru_cache(maxsize: int = 128, typed: bool = False, deepcopy: bool = True) Callable [source]#
An immutable version of lru_cache for caching functions that return mutable objects.
- atomworks.io.common.listmap(func: Callable, *iterables) list [source]#
Like map, but returns a list instead of an iterator.
- atomworks.io.common.md5_hash_string(s: str, length: int = 32) str [source]#
Generate an MD5 hash of a string and return the first length characters.
- atomworks.io.common.not_isin(element: ndarray, array: ndarray, **isin_kwargs) ndarray [source]#
Like ~np.isin, but more efficient.