From 5baef2875a99106511bc8e42ced24cd87ff9e7c5 Mon Sep 17 00:00:00 2001 From: Chris Maffeo <cmaffeo2@illinois.edu> Date: Thu, 3 Jan 2019 10:19:24 -0600 Subject: [PATCH] Made changes that should improve handling of connections within a segment --- mrdna/segmentmodel.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mrdna/segmentmodel.py b/mrdna/segmentmodel.py index 23c7da0..245e206 100644 --- a/mrdna/segmentmodel.py +++ b/mrdna/segmentmodel.py @@ -111,7 +111,8 @@ class Connection(): def delete(self): self.A.container.connections.remove(self) - self.B.container.connections.remove(self) + if self.B.container is not self.A.container: + self.B.container.connections.remove(self) self.A.connection = None self.B.connection = None @@ -188,7 +189,8 @@ class ConnectableElement(): A.connection = B.connection = connection self.connections.append(connection) - other.connections.append(connection) + if other is not self: + other.connections.append(connection) l = A.container.locations if A not in l: l.append(A) l = B.container.locations @@ -532,9 +534,11 @@ class Segment(ConnectableElement, Group): def clear_all(self): Group.clear_all(self) # TODO: use super? self.beads = [] - for c,loc,other in self.get_connections_and_locations(): - loc.particle = None - other.particle = None + # for c,loc,other in self.get_connections_and_locations(): + # loc.particle = None + # other.particle = None + for l in self.locations: + l.particle = None def contour_to_nt_pos(self, contour_pos, round_nt=False): nt = contour_pos*(self.num_nt) - 0.5 -- GitLab