Structure.subset_by_chain#

Structure.subset_by_chain(chain=None)[source]#

Return a subset of the structure that contains only atoms belonging to a specific chain. If no chain is specified, all chains are returned.

Parameters:
chainstr, optional

The chain identifier. If multiple chains should be selected they need to be a comma separated string, e.g. ‘A,B,CE’. If chain None, all chains are returned. Default is None.

Returns:
Structure

A subset of the class instance containing only the specified chains.

Raises:
ValueError

If none of the specified chains exist.

Examples

>>> from importlib_resources import files
>>> from tme import Structure
>>> fname = str(files("tests.data").joinpath("Structures/5khe.cif"))
>>> structure = Structure.from_file(filename=fname)
>>> structure.subset_by_chain(chain="A")   # Keep A
>>> structure.subset_by_chain(chain="A,B") # Keep A and B
>>> structure.subset_by_chain(chain="B,C") # Keep B, C does not exist