diff --git a/segmentmodel.py b/segmentmodel.py index ffd15d576ec796f57e04ae92a58f439841d6c0ef..76c73d99132778b6da36cbb3c45ba01331ff2602 100644 --- a/segmentmodel.py +++ b/segmentmodel.py @@ -358,12 +358,16 @@ class Segment(ConnectableElement, Group): self.end_position = end_position ## Set up interpolation for positions + self._set_splines_from_ends() + + self.sequence = None + + + def _set_splines_from_ends(self): a = np.array([self.start_position,self.end_position]).T tck, u = interpolate.splprep( a, u=[0,1], s=0, k=1) self.position_spline_params = tck self.quaternion_spline_params = None - - self.sequence = None def clear_all(self): @@ -1284,7 +1288,7 @@ class SegmentModel(ArbdModel): self._clear_beads() def update(self, segment , copy=False): - assert( isinstance(other, SegmentModel) ) + assert( isinstance(segment, Segment) ) if copy: segment = deepcopy(segment) self.segments.append(segment) @@ -1654,7 +1658,8 @@ class SegmentModel(ArbdModel): if self.DEBUG: print(" Adding %d bonds" % len(intra_beads)) for b1,b2 in intra_beads: # assert( not np.isclose( np.linalg.norm(b1.collapsedPosition() - b2.collapsedPosition()), 0 ) ) - assert( np.linalg.norm(b1.collapsedPosition() - b2.collapsedPosition()) > 1 ) + if np.linalg.norm(b1.collapsedPosition() - b2.collapsedPosition()) < 1: + print("WARNING: some beads are very close") parent = self._getParent(b1,b2) ## TODO: could be sligtly smarter about sep @@ -1993,7 +1998,9 @@ class SegmentModel(ArbdModel): for s,d in SegmentModel.walk_through_helices(s0,-d0): if s == s0 and len(tmp) > 0: ## end of circular helix, only add first crossover - tmp.append( s.get_contour_sorted_connections_and_locations("crossover")[::d][0] + [d] ) + cl_list = s.get_contour_sorted_connections_and_locations("crossover") + if len(cl_list) > 0: + tmp.append( cl_list[::d][0] + [d] ) else: tmp.extend( [cl + [d] for cl in s.get_contour_sorted_connections_and_locations("crossover")[::d]] ) processed_segments.add(s)