def test_list_assemblies(): """ Test the :func:`list_assemblies()` function based on a known example. """ path = join(data_dir("structure"), "1f2n.cif") pdbx_file = pdbx.PDBxFile.read(path) assembly_list = pdbx.list_assemblies(pdbx_file) assert assembly_list == { "1": "complete icosahedral assembly", "2": "icosahedral asymmetric unit", "3": "icosahedral pentamer", "4": "icosahedral 23 hexamer", "5": "icosahedral asymmetric unit, std point frame", "6": "crystal asymmetric unit, crystal frame", }
At first we will check, which assemblies are available to us. """ # Code source: Patrick Kunzmann # License: BSD 3 clause import numpy as np import biotite.structure as struc import biotite.structure.io.pdbx as pdbx import biotite.structure.io as strucio import biotite.database.rcsb as rcsb pdbx_file = pdbx.PDBxFile.read(rcsb.fetch("1M4X", "mmcif")) assemblies = pdbx.list_assemblies(pdbx_file) print("ID name") print() for assembly_id, name in assemblies.items(): print(f"{assembly_id:2} {name}") ######################################################################## # ``'complete icosahedral assembly'`` sounds good. # In fact, often the first assembly is the complete one. # Hence, the :func:`get_assembly()` function builds the first assembly # by default. # Since we know the ID we want (``'1'``), we will provide it to this # function anyway. # It returns the chosen assembly as :class:`AtomArray`. # Note that the assembly ID is a string, not an integer.