ample.util.pdb_edit module

Useful manipulations on PDB files

add_missing_single_chain_ids(hierarchies, chain_id='A')[source]

Add any missing chain ids

Use the first chain.id as the template or the supplied chain_id if none is present

backbone(inpath=None, outpath=None)[source]

Only output backbone atoms.

calpha_only(inpdb, outpdb)[source]

Strip PDB to c-alphas only

chain_id_is_blank(chain)[source]
extract_chain(inpdb, outpdb, chainID=None, newChainID=None, cAlphaOnly=False, renumber=True)[source]

Extract chainID from inpdb and renumner. If cAlphaOnly is set, strip down to c-alpha atoms

extract_header_pdb_code(pdb_input)[source]
extract_header_title(pdb_input)[source]
extract_model(inpdb, outpdb, modelID)[source]

Extract modelID from inpdb into outpdb

get_info(inpath)[source]

Read a PDB and extract as much information as possible into a PdbInfo object

keep_matching(refpdb=None, targetpdb=None, outpdb=None, resSeqMap=None)[source]

Only keep those atoms in targetpdb that are in refpdb and write the result to outpdb. We also take care of renaming any chains.

match_resseq(targetPdb=None, outPdb=None, resMap=None, sourcePdb=None)[source]
merge(pdb1=None, pdb2=None, pdbout=None)[source]

Merge two pdb files into one

merge_chains(pdbin, pdbout, chains=None)[source]

Merge pdb chains.

If no chains argument is given merge all chains into the first chain, otherwise merge all but the first chain in chains into the first chain in chains.

Parameters
pdbin : file
Source pdb to merge chains from
pdbout : file
pdb output file for single chain pdb
chains : list
list of chain ids - if provided all chains in the list will be merged into the first.
Returns:pdbout – pdb output file for single chain pdb
Return type:file
molecular_weight(pdbin)[source]
num_atoms_and_residues(pdbin, first=False)[source]

“Return number of atoms and residues in a pdb file. If all is True, return all atoms and residues, else just for the first chain in the first model’

reliable_sidechains(inpath=None, outpath=None)[source]

Only output non-backbone atoms for residues in the res_names list.

reliable_sidechains_cctbx(pdbin=None, pdbout=None)[source]

Only output non-backbone atoms for residues in the res_names list.

rename_chains(inpdb=None, outpdb=None, fromChain=None, toChain=None)[source]

Rename Chains

renumber_residues(pdbin, pdbout, start=1)[source]

Renumber the residues in the chain

renumber_residues_gaps(pdbin, pdbout, gaps, start=1)[source]

Renumber the residues in the chain based on specified gaps

Parameters:
  • pdbin (str) –
  • pdbout (str) –
  • gaps (list) – List containing True/False for gaps
resseq(pdbin)[source]
select_residues(pdbin, pdbout, delete=None, tokeep=None, delete_idx=None, tokeep_idx=None)[source]
split_into_chains(pdbin, chain=None, directory=None)[source]

Split a pdb file into its separate chains

split_pdb(pdbin, directory=None, strip_hetatm=False, same_size=False)[source]

Split a pdb file into its separate models

Parameters:
  • pdbin (str) – path to input pdbf file
  • directory (str) – path to directory where pdb files will be created
  • strip_hetatm (bool) – remove HETATMS if true
  • same_size (bool) – Only output models of equal length (the most numerous length is selected)
standardise(pdbin, pdbout, chain=None, del_hetatm=False)[source]

Rename any non-standard AA, remove solvent and only keep most probably conformation.

std_residues_cctbx(pdbin, pdbout, del_hetatm=False)[source]

Map all residues in MODRES section to their standard counterparts optionally delete all other HETATMS

strip(pdbin, pdbout, hetatm=False, hydrogen=False, atom_types=[])[source]
translate(inpdb=None, outpdb=None, ftranslate=None)[source]

translate pdb args: ftranslate – vector of fractional coordinates to shift by

xyz_cb_coordinates(pdbin)[source]

Extract xyz for CA/CB atoms

xyz_coordinates(pdbin)[source]

Extract xyz for all atoms