diff --git a/mrdna/segmentmodel.py b/mrdna/segmentmodel.py index 23c7da0fe47a851238235356563afadbfab7e352..245e206bd9f679f62d7edd519aa7fd973ce06000 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