1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
import openmm.app as app
import pdbfixer
import tempfile
from pytest import raises
def test_mutate_1():
fixer = pdbfixer.PDBFixer(pdbid='1VII')
fixer.applyMutations(["ALA-57-GLY"], "A")
fixer.findMissingResidues()
fixer.findMissingAtoms()
fixer.addMissingAtoms()
fixer.addMissingHydrogens(7.0)
with tempfile.NamedTemporaryFile(mode='w+') as temp_pdb:
app.PDBFile.writeFile(fixer.topology, fixer.positions, temp_pdb)
temp_pdb.flush()
pdb = app.PDBFile(temp_pdb.name)
new_residue57 = list(fixer.topology.residues())[16]
assert new_residue57.name == "GLY", "Name of mutated residue did not change correctly!"
assert len(list(new_residue57.atoms())) == 7, "Should have 7 atoms in GLY 56"
atom_names = set([atom.name for atom in new_residue57.atoms()])
desired_atom_names = set(["N", "CA", "C", "O", "H", "HA3", "HA2"])
assert atom_names == desired_atom_names, "Atom Names did not match for GLY 56"
def test_mutate_2():
fixer = pdbfixer.PDBFixer(pdbid='1VII')
fixer.applyMutations(["ALA-57-LEU", "SER-56-ALA"], "A")
fixer.findMissingResidues()
fixer.findMissingAtoms()
fixer.addMissingAtoms()
fixer.addMissingHydrogens(7.0)
temp_pdb = tempfile.NamedTemporaryFile(mode='w+')
new_residue57 = list(fixer.topology.residues())[16]
new_residue56 = list(fixer.topology.residues())[15]
assert new_residue57.name == "LEU", "Name of mutated residue did not change correctly!"
assert new_residue56.name == "ALA", "Name of mutated residue did not change correctly!"
assert len(list(new_residue56.atoms())) == 10, "Should have 10 atoms in ALA 56"
assert len(list(new_residue57.atoms())) == 19, "Should have 19 atoms in LEU 57"
atom_names = set([atom.name for atom in new_residue56.atoms()])
desired_atom_names = set(["N", "CA", "CB", "C", "O", "H", "HA", "HB1", "HB2", "HB3"])
assert atom_names == desired_atom_names, "Atom Names did not match for ALA 56"
atom_names = set([atom.name for atom in new_residue57.atoms()])
desired_atom_names = set(["C", "N", "CA", "CB", "CG", "CD1", "CD2", "O", "H", "HA", "HB2", "HB3", "HD11", "HD12", "HD13", "HD21", "HD22", "HD23", "HG"])
assert atom_names == desired_atom_names, "Atom Names did not match for LEU 57"
def test_mutate_3_fails():
with raises(ValueError):
fixer = pdbfixer.PDBFixer(pdbid='1VII')
fixer.applyMutations(["ALA-57-GLY", "SER-57-ALA"], "A")
def test_mutate_4_fails():
with raises(KeyError):
fixer = pdbfixer.PDBFixer(pdbid='1VII')
fixer.applyMutations(["ALA-57-WTF", "SER-56-ALA"], "A")
def test_mutate_5_fails():
with raises(KeyError):
fixer = pdbfixer.PDBFixer(pdbid='1VII')
fixer.applyMutations(["ALA-1000-GLY", "SER-56-ALA"], "A")
def test_mutate_multiple_copies_of_chain_A():
fixer = pdbfixer.PDBFixer(pdbid='1OL5')
fixer.applyMutations(['TPO-287-THR','TPO-288-THR'], "A")
|