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 using Structure.to_volume() or tme.density.Density.from_structure().

>>> volume, origin, sampling_rate = structure.to_volume(shape=(50,40,30))

Attributes

Structure.record_type

Array of record types, e.g.ATOM.

Structure.atom_serial_number

Array of serial numbers.

Structure.atom_name

Array of atom names.

Structure.atom_coordinate

Array of x,y,z atom coordinates.

Structure.alternate_location_indicator

Array of alternate location indices.

Structure.residue_name

Array of residue names.

Structure.chain_identifier

Array of chain identifiers.

Structure.residue_sequence_number

Array of residue ids.

Structure.code_for_residue_insertion

Array of insertion information.

Structure.occupancy

Array of occupancy factors.

Structure.temperature_factor

Array of B-factors.

Structure.segment_identifier

Array of segment identifiers.

Structure.element_symbol

Array of element symbols.

Structure.charge

Array of charges.

Structure.metadata

Metadata dictionary.

Methods

Structure.align_structures(structure1, ...)

Align structure2 to structure1 using the Kabsch Algorithm.

Structure.center_of_mass()

Calculate the center of mass of the structure.

Structure.centered()

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.

Structure.copy()

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.