Structure.from_file#
- classmethod Structure.from_file(filename, keep_non_atom_records=False, filter_by_elements=None, filter_by_residues=None)[source]#
Reads an atomic structure file and into a
Structure
instance.- Parameters:
- filenamestr
Input file. Supported extensions are:
.pdb
Reads a PDB file
.cif
Reads an mmCIF file
- keep_non_atom_recordsbool, optional
Wheter to keep residues that are not labelled ATOM.
- filter_by_elements: set, optional
Which elements to keep. Default corresponds to all elements.
- filter_by_residues: set, optional
Which residues to keep. Default corresponds to all residues.
- Returns:
Structure
Structure instance representing the read in file.
- Raises:
- ValueError
If the extension is not supported.
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 Unique Chains: A-B, Atom Range: 1-1564 [N = 1564], Residue Range: 142-239 [N = 1564]
We can include non ATOM entries and restrict the considered elements and residues
>>> structure = Structure.from_file( >>> filename=fname, >>> keep_non_atom_records=True, >>> filter_by_elements = {"C"}, >>> filter_by_residues = {"GLY"}, >>> ) >>> structure Unique Chains: A,B, Atom Range: 96-1461 [N = 44], Residue Range: 154-228 [N = 44]