From bf3f62d5331cb391e6e20b0ccf64107591a0acd1 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Thu, 14 Sep 2023 22:14:01 -0700 Subject: [PATCH] Also combine overlapping ranges into segments With atomic models, subsequent atoms in the same residue will overlap the range of the last representation segment, not just end up contiguous with it. Combine these into one segment. --- modules/mmcif/pyext/src/data.py | 2 +- modules/mmcif/test/test_data.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/mmcif/pyext/src/data.py b/modules/mmcif/pyext/src/data.py index 688496fc8c..a4014ddced 100644 --- a/modules/mmcif/pyext/src/data.py +++ b/modules/mmcif/pyext/src/data.py @@ -254,7 +254,7 @@ def start_new_segment(): elif (type(particle) == type(self.particles[0]) # noqa: E721 and is_res == self.is_res and is_atom == self.is_atom - and resrange[0] == self.residue_range[1] + 1 + and resrange[0] <= self.residue_range[1] + 1 and starting_model == self.starting_model and self._same_rigid_body(rigid_body)): # Continue an existing segment diff --git a/modules/mmcif/test/test_data.py b/modules/mmcif/test/test_data.py index 94764a85fe..4ce6a43040 100644 --- a/modules/mmcif/test/test_data.py +++ b/modules/mmcif/test/test_data.py @@ -354,11 +354,11 @@ def test_coordinate_handler_add_chain(self): # One residue with atomic representation residue = IMP.atom.Residue.setup_particle(IMP.Particle(m), IMP.atom.ALA, 4) - atom = IMP.atom.Atom.setup_particle(IMP.Particle(m), - IMP.atom.AT_CA) - IMP.core.XYZR.setup_particle( - atom, IMP.algebra.Sphere3D(IMP.algebra.Vector3D(1, 2, 3), 4)) - residue.add_child(atom) + for att in (IMP.atom.AT_CA, IMP.atom.AT_O): + atom = IMP.atom.Atom.setup_particle(IMP.Particle(m), att) + IMP.core.XYZR.setup_particle( + atom, IMP.algebra.Sphere3D(IMP.algebra.Vector3D(1, 2, 3), 4)) + residue.add_child(atom) top.add_child(residue) # Two beads each spanning two residues frag = IMP.atom.Fragment.setup_particle(IMP.Particle(m), [5, 6])