Reading files
There are two types of files we typically work with, models and maps. TEMPy loads these files using parsing functions.
Reading models
To read a PDB file, use the PDBParser.
>>> from TEMPy.protein.structure_parser import PDBParser
>>> model = PDBParser.read_PDB_file("", "../tests/test_data/1CS4.pdb")
>>> model
Gemmi_Structure: 1CS4
, Filename: ../tests/test_data/1CS4.pdb
No Of Atoms: 5647
First Atom: (MET 377 A: 28.568, -27.770, 32.255)
Last Atom: (LEU 388 C: 16.116, -21.409, 27.123)
To read a mmCIF file, use the mmCIFParser.
>>> from TEMPy.protein.structure_parser import mmCIFParser
>>> model = mmCIFParser.read_mmCIF_file("../tests/test_data/1CS4.cif")
>>> model
Gemmi_Structure: 1CS4
, Filename: ../tests/test_data/1CS4.cif
No Of Atoms: 5647
First Atom: (MET 377 A: 28.568, -27.770, 32.255)
Last Atom: (LEU 388 C: 16.116, -21.409, 27.123)
Operations on models
To get a list of chains:
>>> from TEMPy.protein.structure_parser import mmCIFParser
>>> model = mmCIFParser.read_mmCIF_file("../tests/test_data/1CS4.cif")
>>> model.get_chain_list()
['A', 'B', 'C']
To get a particular chain, use the get_chain method. This will return a new structure.
>>> from TEMPy.protein.structure_parser import mmCIFParser
>>> model = mmCIFParser.read_mmCIF_file("../tests/test_data/1CS4.cif")
>>> model.get_chain('A')
Gemmi_Structure: 1CS4chainA
No Of Atoms: 1476
First Atom: (MET 377 A: 28.568, -27.770, 32.255)
Last Atom: (LEU 565 A: 45.328, -2.249, 79.025)
Often, we only want to work with backbone atoms. This can be a useful for example at low resolutions.
>>> from TEMPy.protein.structure_parser import mmCIFParser
>>> model = mmCIFParser.read_mmCIF_file("../tests/test_data/1CS4.cif")
>>> model.get_backbone()
No Of Atoms: 2124
First Atom: (MET 377 A: 28.568, -27.770, 32.255)
Last Atom: (LEU 388 C: 13.015, -22.394, 30.319)
For more information about the methods available, consult the API reference: Link
Reading maps
>>> from TEMPy.maps.map_parser import MapParser
>>> map = MapParser.readMRC("../tests/test_data/1CS4.mrc")
>>> map
Obtained from ../tests/test_data/1CS4.mrc
Origin: [-18.572 -51.218 -21.575]
Box size (x,y,z): [32, 31, 35]
Grid spacing: [3.500 3.500 3.500]
Min, max, mean, std: 0.000, 0.630, 0.026, 0.087
You can get information about the dimensions of the box in voxels:
>>> from TEMPy.maps.map_parser import MapParser
>>> map = MapParser.readMRC("../tests/test_data/1CS4.mrc")
>>> map.box_size()
(35, 31, 32)
Or the size of each voxel in units of Angstroms:
>>> from TEMPy.maps.map_parser import MapParser
>>> map = MapParser.readMRC("../tests/test_data/1CS4.mrc")
>>> map.apix
array([3.5, 3.5, 3.5], dtype=float32)
For more information about the methods available, consult the API reference: Link