Chain Utilities#

atomworks.io.utils.chain.create_chain_id_generator(unavailable_chain_ids: Sequence[str] = []) Iterator[str][source]#

Generate the next available chain ID that is not in the unavailable_chain_ids list. The chain IDs are generated in lexicographical order,

i.e. A, B, C, …, Z, AA, AB, …, ZZ, AAA, etc.

The first available chain ID will be returned, i.e. gaps in the unavailable_chain_ids list will be filled.

Parameters:

unavailable_chain_ids (-) – List of already occupied chain IDs.

Yields:

- str – The next available chain ID.

Example

>>> unavailable = ["A", "B", "C", "AA", "AB"]
>>> next_id = create_chain_id_generator(unavailable)
>>> print(next(next_id), next(next_id), next(next_id))
D E F