Skip to content

Commit

Permalink
Make PDB parser ignore self bodning
Browse files Browse the repository at this point in the history
  • Loading branch information
samirelanduk committed Nov 2, 2017
1 parent bbab26a commit b9a439b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions atomium/files/pdbdict2pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def make_connections_bonds(model, connections):
:param list connections: The connections list from a data dictionary"""

for connection in connections:
try:
connection["bond_to"].remove(connection["atom"])
except: pass
atom = model.atom(atom_id=connection["atom"])
if atom:
for other in connection["bond_to"]:
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/files_tests/test_pdb_dict_to_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,21 @@ def test_can_bond_from_connections(self):
atoms[2].bond.assert_called_with(atoms[1])
atoms[3].bond.assert_called_with(atoms[1])
self.assertFalse(atoms[0].called)


def test_can_ignore_self_bonding(self):
model = Mock()
atoms = [Mock(), Mock(), Mock(), Mock()]
model.atom.side_effect = [
atoms[0], atoms[1], atoms[2], atoms[3]
]
for index, atom in enumerate(atoms):
atom.atom_id.return_value = index + 1
atom.bond = MagicMock()
connections = [{
"atom": 1, "bond_to": [1, 2, 3, 4]
}]
make_connections_bonds(model, connections)
atoms[0].bond.assert_any_call(atoms[1])
atoms[0].bond.assert_any_call(atoms[2])
atoms[0].bond.assert_called_with(atoms[3])

0 comments on commit b9a439b

Please sign in to comment.