ample.util.pdb_edit module

Useful manipulations on PDB files

class Test(methodName=’runTest’)[source]

Bases: unittest.case.TestCase

Methods

addCleanup(function, *args, **kwargs) Add a function, with arguments, to be called when the test is completed.
addTypeEqualityFunc(typeobj, function) Add a type specific assertEqual style function to compare a type.
assertAlmostEqual(first, second[, places, …]) Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the between the two objects is more than the given delta.
assertAlmostEquals(first, second[, places, …]) Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the between the two objects is more than the given delta.
assertDictContainsSubset(expected, actual[, msg]) Checks whether actual is a superset of expected.
assertEqual(first, second[, msg]) Fail if the two objects are unequal as determined by the ‘==’ operator.
assertEquals(first, second[, msg]) Fail if the two objects are unequal as determined by the ‘==’ operator.
assertFalse(expr[, msg]) Check that the expression is false.
assertGreater(a, b[, msg]) Just like self.assertTrue(a > b), but with a nicer default message.
assertGreaterEqual(a, b[, msg]) Just like self.assertTrue(a >= b), but with a nicer default message.
assertIn(member, container[, msg]) Just like self.assertTrue(a in b), but with a nicer default message.
assertIs(expr1, expr2[, msg]) Just like self.assertTrue(a is b), but with a nicer default message.
assertIsInstance(obj, cls[, msg]) Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.
assertIsNone(obj[, msg]) Same as self.assertTrue(obj is None), with a nicer default message.
assertIsNot(expr1, expr2[, msg]) Just like self.assertTrue(a is not b), but with a nicer default message.
assertIsNotNone(obj[, msg]) Included for symmetry with assertIsNone.
assertItemsEqual(expected_seq, actual_seq[, msg]) An unordered sequence specific comparison.
assertLess(a, b[, msg]) Just like self.assertTrue(a < b), but with a nicer default message.
assertLessEqual(a, b[, msg]) Just like self.assertTrue(a <= b), but with a nicer default message.
assertListEqual(list1, list2[, msg]) A list-specific equality assertion.
assertMultiLineEqual(first, second[, msg]) Assert that two multi-line strings are equal.
assertNotAlmostEqual(first, second[, …]) Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the between the two objects is less than the given delta.
assertNotAlmostEquals(first, second[, …]) Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the between the two objects is less than the given delta.
assertNotEqual(first, second[, msg]) Fail if the two objects are equal as determined by the ‘!=’ operator.
assertNotEquals(first, second[, msg]) Fail if the two objects are equal as determined by the ‘!=’ operator.
assertNotIn(member, container[, msg]) Just like self.assertTrue(a not in b), but with a nicer default message.
assertNotIsInstance(obj, cls[, msg]) Included for symmetry with assertIsInstance.
assertNotRegexpMatches(text, unexpected_regexp) Fail the test if the text matches the regular expression.
assertRaises(excClass[, callableObj]) Fail unless an exception of class excClass is raised by callableObj when invoked with arguments args and keyword arguments kwargs.
assertRaisesRegexp(expected_exception, …) Asserts that the message in a raised exception matches a regexp.
assertRegexpMatches(text, expected_regexp[, msg]) Fail the test unless the text matches the regular expression.
assertSequenceEqual(seq1, seq2[, msg, seq_type]) An equality assertion for ordered sequences (like lists and tuples).
assertSetEqual(set1, set2[, msg]) A set-specific equality assertion.
assertTrue(expr[, msg]) Check that the expression is true.
assertTupleEqual(tuple1, tuple2[, msg]) A tuple-specific equality assertion.
assert_(expr[, msg]) Check that the expression is true.
debug() Run the test without collecting errors in a TestResult
doCleanups() Execute all cleanup functions.
fail([msg]) Fail immediately, with the given message.
failureException alias of AssertionError
setUp() Hook method for setting up the test fixture before exercising it.
setUpClass() Set up paths.
shortDescription() Returns a one-line description of the test, or None if no description has been provided.
skipTest(reason) Skip this test.
tearDown() Hook method for deconstructing the test fixture after testing it.
tearDownClass() Hook method for deconstructing the class fixture after running all tests in the class.
XtestSplit  
__call__  
assertDictEqual  
countTestCases  
defaultTestResult  
failIf  
failIfAlmostEqual  
failIfEqual  
failUnless  
failUnlessAlmostEqual  
failUnlessEqual  
failUnlessRaises  
id  
run  
testCheckPdbs  
testGetInfo1  
testGetInfo2  
testReliableSidechains  
testSelectResidues  
testSelectResiduesKeepIdxs  
testSequence1  
testStdResidues  
testStdResiduesCctbx  
testStripAtomTypes  
testStripHetatm  
testStripHydrogen  
testXyzCbCoordinates  
testXyzCoordinates  
XtestSplit()[source]
classmethod setUpClass()[source]

Set up paths. Need to do this with setUpClass, as otherwise the __file__ variable is updated whenever the cwd is changed in a test and the next test gets the wrong paths.

testCheckPdbs()[source]
testGetInfo1()[source]
testGetInfo2()[source]
testReliableSidechains()[source]
testSelectResidues()[source]
testSelectResiduesKeepIdxs()[source]
testSequence1()[source]
testStdResidues()[source]
testStdResiduesCctbx()[source]
testStripAtomTypes()[source]
testStripHetatm()[source]
testStripHydrogen()[source]
testXyzCbCoordinates()[source]
testXyzCoordinates()[source]
Xselect_residues(inpath=None, outpath=None, residues=None)[source]

Create a new pdb by selecting only the numbered residues from the list. This only keeps ATOM lines - everything else gets discarded.

Args: infile: path to input pdb outfile: path to output pdb residues: list of integers of the residues to keep

Return: Number of residues written

Xsplit(pdbin)[source]

Split a pdb into separate models

Xstd_residues(pdbin, pdbout)[source]

Switch any non-standard AA’s to their standard names. We also remove any ANISOU lines.

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

Only output backbone atoms.

calpha_only(inpdb, outpdb)[source]

Strip PDB to c-alphas only

check_pdb_directory(directory, single=True, allsame=True, sequence=None)[source]
check_pdbs(models, single=True, allsame=True, sequence=None)[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

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’

prepare_nmr_model(nmr_model_in, models_dir)[source]

Split an nmr pdb into its constituent parts and standardise the lengths

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]
sequence(pdbin)[source]
sequence_data(pdbin)[source]
split_into_chains(pdbin, chain=None, directory=None)[source]

Split a pdb file into its separate chains

split_pdb(pdbin, directory=None)[source]

Split a pdb file into its separate models

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]
to_single_chain(inpath, outpath)[source]

Condense a single-model multi-chain pdb to a single-chain pdb

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