DisorderedAtom returns children sorted by altloc (#3232)

* Added method to return sorted list of children of DisorderedAtom

* Tweaked test file to test for order of disordered children.
This commit is contained in:
João Rodrigues
2020-08-24 11:34:40 -07:00
committed by GitHub
parent 70fceb8f1c
commit ff87d7defe
2 changed files with 8 additions and 1 deletions

View File

@ -482,6 +482,13 @@ class DisorderedAtom(DisorderedEntityWrapper):
"""Return disordered atom identifier."""
return "<Disordered Atom %s>" % self.get_id()
def disordered_get_list(self):
"""Return list of atom instances.
Sorts children by altloc (empty, then alphabetical).
"""
return sorted(self.child_dict.values(), key=lambda a: ord(a.altloc))
def disordered_add(self, atom):
"""Add a disordered atom."""
# Add atom to dict, use altloc as key

View File

@ -21,7 +21,7 @@ ATOM 218 CB ARG A 27 56.899 20.533 28.660 1.00 16.52 C
ATOM 219 CG ARG A 27 57.901 20.081 27.621 1.00 19.45 C
ATOM 220 CD ARG A 27 58.541 21.359 27.019 1.00 22.58 C
ATOM 221 NE ARG A 27 59.504 20.850 26.023 1.00 26.89 N
ATOM 222 CZ AARG A 27 59.081 20.674 24.762 0.50 26.69 C
ATOM 222 CZ ARG A 27 59.081 20.674 24.762 0.50 26.69 C
ATOM 223 CZ BARG A 27 60.798 20.732 26.326 0.50 26.95 C
ATOM 224 NH1AARG A 27 57.848 21.002 24.386 0.50 27.16 N
ATOM 225 NH1BARG A 27 61.262 21.064 27.522 0.50 27.39 N