Skip to content

Commit

Permalink
Fix bug where atoms with alt loc 1 aren't parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
samirelanduk committed Oct 28, 2017
1 parent 7a962d4 commit 80090b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions atomium/files/pdbdict2pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ def residue_dict_to_residue(residue_dict, molecule=False):
instead of a :py:class:`.Residue`.
:rtype: :py:class:`.Residue` or :py:class:`.Molecule`"""

atoms = [atom_dict_to_atom(atom) for atom in residue_dict["atoms"]
if atom["alt_loc"] is None or atom["alt_loc"] == "A"]
atoms = [
atom_dict_to_atom(atom) for atom in residue_dict["atoms"]
if atom["alt_loc"] is None or atom["alt_loc"] == "A"
or atom["alt_loc"] == "1"
]
MolClass = Molecule if molecule else Residue
residue = MolClass(*atoms, name=residue_dict["name"])
residue._id = residue_dict["id"]
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/files_tests/test_pdb_dict_to_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def test_can_convert_residue_dict_to_residue(self, mock_atom, mock_res):
@patch("atomium.files.pdbdict2pdb.Residue")
@patch("atomium.files.pdbdict2pdb.atom_dict_to_atom")
def test_can_convert_residue_dict_to_residue_alt_loc(self, mock_atom, mock_res):
self.atom_dicts[1]["alt_loc"] = "1"
self.atom_dicts[2]["alt_loc"] = "A"
self.atom_dicts[3]["alt_loc"] = "B"
self.atom_dicts[2]["occupancy"] = 0.8
Expand All @@ -130,7 +131,7 @@ def test_can_convert_residue_dict_to_residue_alt_loc(self, mock_atom, mock_res):
res_dict = {"id": "A12", "name": "VAL", "atoms": self.atom_dicts}
returned_residue = residue_dict_to_residue(res_dict)
mock_atom.assert_any_call({"alt_loc": None, "atom_id": 1, "occupancy": 1})
mock_atom.assert_any_call({"alt_loc": None, "atom_id": 2, "occupancy": 1})
mock_atom.assert_any_call({"alt_loc": "1", "atom_id": 2, "occupancy": 1})
mock_atom.assert_any_call({"alt_loc": "A", "atom_id": 3, "occupancy": 0.8})
self.assertEqual(mock_atom.call_count, 3)
self.assertIs(returned_residue, residue)
Expand Down

0 comments on commit 80090b1

Please sign in to comment.