pwem.convert.atom_struct module

class pwem.convert.atom_struct.AtomicStructHandler(fileName=None, permissive=1)[source]

Bases: object

Class that contain utilities to handle pdb/cif files

CIF = 1
PDB = 0
addStruct(secondPDBfileName, outPDBfileName=None, useModel=False)[source]

Join the second structure to the first one. If cheon numes are the same rename them. if outPDBfileName id provided then new struct is saved to a file


Returns gravity [default] or geometric center of mass of an Entity (anything with a get_atoms function in biopython. Geometric assumes all masses are equal (geometric=True)

checkLabelInFile(fileName, label)[source]
extractChain(chainID, start=0, end=-1, modelID='0', filename='output.mmcif')[source]

Code for chopping a structure. This module is used internally by the Bio.PDB.extract() function.


Get bounding box (angstroms) for atom struct. Only alpha carbons are taken into account. parameter: expand.- make box larger addind this factor

getFullID(model_id='0', chain_id=None)[source]

assign a label to a sequence obtained from a PDB file :parameter model_id chain_id :return: string with label

given an atomic structure returns two dictionaries:
  1. for all models and respective chains (chainID and length of residues)
  2. for each chain list of residues
getSequenceFromChain(modelID, chainID)[source]

return structure information, model, chain, residues, atoms…

getTransformMatrix(atomStructFn, startId=-1, endId=-1)[source]

find matrix that Superimposes two atom structures. this matrix moves atomStructFn to self


Read and parse file.

readFromPDBDatabase(pdbID, dir=None, type='mmCif')[source]

Retrieve structure from PDB :param pdbID: :param dir: save structure in this directory :param type: mmCif or pdb :return: filename with pdb file


Return a dictionary with all mmcif fields. you should parse them Example: get the list of the y coordinates of all atoms

dict = readLowLevel(“kk.pdb”) y_list = dict[‘_atom_site.Cartn_y’]
renameChain(chainID, newChainName, modelID='0', filename='output.mmcif')[source]

Renames chains to be one-letter chains

Existing one-letter chains will be kept. Multi-letter chains will be truncated or renamed to the next available letter of the alphabet.

If more than 62 chains are present in the structure, raises an OutOfChainsError

Returns a map between new and old chain IDs, as well as modifying the input structure

renumberChain(chainID, offset=0, modelID='0', filename='output.mmcif')[source]
transform(transformation_matrix, sampling=1.0)[source]

Geometrical transformation of a PDB structure

Parameters:entity – PDB biopython structure

:param transformation_matrix -> 4x4 scipion matrix :param sampling: scipion transform matrix is applied to voxels so

length must be multiplied by samplingRate
internal variables:
rotation matrix -> numpy.array(
[[ 0.5, -0.809017, 0.309017],
[ 0.809017, 0.30917, -0.5 ], [ 0.309017, 0.5, 0.809017]])

translation: translation vector -> numpy.array([1., 0., 0.], ‘d’)

Returns:no return, new data overwrites entity

Save structure as CIF. Be aware that this is not a lossless conversion


Save structure as PDB. Be aware that this is not a lossless conversion Returns False is conversion is not possible. True otherwise

exception pwem.convert.atom_struct.OutOfChainsError[source]

Bases: Exception

pwem.convert.atom_struct.cifToPdb(fnCif, fnPdb)[source]
pwem.convert.atom_struct.fromCIFToPDB(inFileName, outFileName, log)[source]
pwem.convert.atom_struct.fromCIFTommCIF(inFileName, outFileName, log)[source]
pwem.convert.atom_struct.fromPDBToCIF(inFileName, outFileName, log)[source]
pwem.convert.atom_struct.partiallyCleaningFolder(program, cwd)[source]
pwem.convert.atom_struct.pdbToCif(fnPdb, fnCif)[source]
pwem.convert.atom_struct.retry(runEnvirom, program, args, cwd, listAtomStruct=[], log=None, clean_dir=None)[source]
class pwem.convert.atom_struct.scipionMMCIFIO[source]

Bases: Bio.PDB.mmcifio.MMCIFIO

pwem.convert.atom_struct.toCIF(inFileName, outCIFFile)[source]
pwem.convert.atom_struct.toPdb(inFileName, outPDBFile)[source]