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, returnAlphabet=False)[source]

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


Using an atomic structure as input, this method returns two list: * List 1: B-factor field values for each atom of the structure. * List 2 is a list of lists. For each residue of the structure a list with the model, chain, order number of residue, name of residue and average of B-factor field values (atoms) is returned. An example of each list item is: [0, ‘A’, 103, ‘PHE’, 96.01]

getTransformMatrix(atomStructFn, startId=-1, endId=-1, outFn=None)[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


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’)


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.addScipionAttribute(cifDic, attributeScoresDic, attrName, recipient='residues')[source]

Add a scipion attribute in a section of the CIF dictionary “cifDic”: must be a cif dictionary parsed by Biopython “attributeScoresDic” a dictionary of the form {spec: value}”

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, messages=[], sdterrLog=None)[source]
class pwem.convert.atom_struct.scipionMMCIFIO[source]



pwem.convert.atom_struct.testLog(log, messages=None, sdterrLog=None)[source]
pwem.convert.atom_struct.toCIF(inFileName, outCIFFile)[source]
pwem.convert.atom_struct.toPdb(inFileName, outPDBFile)[source]