Commit 08c22124 by Kyle Beauchamp

Give nicer error when index not found.

parent 33d2d841
...@@ -592,6 +592,9 @@ class PDBFixer(object): ...@@ -592,6 +592,9 @@ class PDBFixer(object):
old_name, index, new_name = mut_str.split("-") old_name, index, new_name = mut_str.split("-")
index = int(index) index = int(index)
if index not in index_to_old_name:
raise(KeyError("Cannot find index %d in system!" % index))
if index_to_old_name[index] != old_name: if index_to_old_name[index] != old_name:
raise(ValueError("You asked to mutate %s %d, but that residue is actually %s!" % (old_name, index, index_to_old_name[index]))) raise(ValueError("You asked to mutate %s %d, but that residue is actually %s!" % (old_name, index, index_to_old_name[index])))
......
...@@ -30,3 +30,11 @@ def test_mutate_4_fails(): ...@@ -30,3 +30,11 @@ def test_mutate_4_fails():
fixer.applyMutations(["ALA-16-WTF", "SER-15-ALA"]) fixer.applyMutations(["ALA-16-WTF", "SER-15-ALA"])
fixer.addMissingHydrogens(7.0) fixer.addMissingHydrogens(7.0)
app.PDBFile.writeFile(fixer.topology, fixer.positions, tempfile.TemporaryFile()) app.PDBFile.writeFile(fixer.topology, fixer.positions, tempfile.TemporaryFile())
@raises(KeyError)
def test_mutate_5_fails():
fixer = pdbfixer.PDBFixer(pdbid='1VII')
fixer.applyMutations(["ALA-1000-GLY", "SER-15-ALA"])
fixer.addMissingHydrogens(7.0)
app.PDBFile.writeFile(fixer.topology, fixer.positions, tempfile.TemporaryFile())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment