Structure#
- class Structure(record_type, atom_serial_number, atom_name, atom_coordinate, alternate_location_indicator, residue_name, chain_identifier, residue_sequence_number, code_for_residue_insertion, occupancy, temperature_factor, segment_identifier, element_symbol, charge, metadata)[source]#
Bases:
object
Represents atomic structures per the Protein Data Bank (PDB) specification.
References
Examples
The following achieves the definition of a
Structure
instance>>> from tme import Structure >>> structure = Structure( >>> record_type=["ATOM", "ATOM", "ATOM"], >>> atom_serial_number=[0, 1, 2] , >>> atom_name=["C", "N", "H"], >>> atom_coordinate=[[30,15,10], [35, 20, 15], [35,25,20]], >>> alternate_location_indicator=[".", ".", "."], >>> residue_name=["GLY", "GLY", "HIS"], >>> chain_identifier=["A", "A", "B"], >>> residue_sequence_number=[0, 0, 1], >>> code_for_residue_insertion=["?", "?", "?"], >>> occupancy=[0, 0, 0], >>> temperature_factor=[0, 0, 0], >>> segment_identifier=["1", "1", "1"], >>> element_symbol=["C", "N", "C"], >>> charge=["?", "?", "?"], >>> metadata={}, >>> ) >>> structure Unique Chains: A-B, Atom Range: 0-2 [N = 3], Residue Range: 0-1 [N = 3]
Structure
instances support a range of subsetting operations based on atom indices>>> structure[1] Unique Chains: A, Atom Range: 1-1 [N = 1], Residue Range: 0-0 [N = 1] >>> structure[(False, False, True)] Unique Chains: B, Atom Range: 2-2 [N = 1], Residue Range: 1-1 [N = 1] >>> structure[(1,2)] Unique Chains: A-B, Atom Range: 1-2 [N = 2], Residue Range: 0-1 [N = 2]
They can be written to disk in a range of formats using
Structure.to_file()
>>> structure.to_file("test.pdb") # Writes a PDB file to disk >>> structure.to_file("test.cif") # Writes a mmCIF file to disk
New instances can be created from a range of formats using
Structure.from_file()
>>> Structure.from_file("test.pdb") # Reads PDB file from disk Unique Chains: A-B, Atom Range: 0-2 [N = 3], Residue Range: 0-1 [N = 3] >>> Structure.from_file("test.cif") # Reads mmCIF file from disk Unique Chains: A-B, Atom Range: 0-2 [N = 3], Residue Range: 0-1 [N = 3]
Class instances can be discretized on grids and converted to
tme.density.Density
instances usingStructure.to_volume()
ortme.density.Density.from_structure()
.>>> volume, origin, sampling_rate = structure.to_volume(shape=(50,40,30))
Attributes
Array of record types, e.g.ATOM.
Array of serial numbers.
Array of atom names.
Array of x,y,z atom coordinates.
Array of alternate location indices.
Array of residue names.
Array of chain identifiers.
Array of residue ids.
Array of insertion information.
Array of occupancy factors.
Array of B-factors.
Array of segment identifiers.
Array of element symbols.
Array of charges.
Metadata dictionary.
Methods
Structure.align_structures
(structure1, ...)Align
structure2
tostructure1
using the Kabsch Algorithm.Calculate the center of mass of the structure.
Shifts the structure analogous to
tme.density.Density.centered()
.Structure.compare_structures
(structure1, ...)Compute root mean square deviation (RMSD) between two structures with the same number of atoms.
Returns a copy of the Structure instance.
Structure.from_file
(filename[, ...])Reads an atomic structure file and into a
Structure
instance.Structure.rigid_transform
(rotation_matrix, ...)Performs a rigid transform of internal structure coordinates.
Structure.subset_by_chain
([chain])Return a subset of the structure that contains only atoms belonging to a specific chain.
Structure.subset_by_range
(start, stop[, chain])Return a subset of the structure within a specific range of residues.
Structure.to_file
(filename)Writes the
Structure
instance to disk.Structure.to_volume
([shape, sampling_rate, ...])Maps class instance to a volume.