Commit bcd1753a authored by cmaffeo2's avatar cmaffeo2
Browse files

Added function for setting splines; converted an assertion into a warning when...

Added function for setting splines; converted an assertion into a warning when beads are very close; fiex crash when helices lack crossovers
parent 616ca8e2
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment