Commit 7eb2c616 authored by cmaffeo2's avatar cmaffeo2
Browse files

Beads positions/orientations now generated from contour_position in _generate_one_bead()

parent 71aa2903
......@@ -127,8 +127,8 @@ class Segment(ConnectableElement, Group):
def contour_to_tangent(self,s):
t = interpolate.splev( s, self.position_spline_params, der=1 )
if len(t) > 1: t = np.array(t).T
return t
t = (t / np.linalg.norm(t,axis=0))
return t.T
def contour_to_orientation(self,s):
......@@ -136,8 +136,7 @@ class Segment(ConnectableElement, Group):
# axis = self.start_orientation.dot( np.array((0,0,1)) )
if self.quaternion_spline_params is None:
axis = self.contour_to_tangent(s)
# orientation = rotationAboutAxis( axis, s*self.twist_per_nt*self.num_nts, normalizeAxis=False )
orientation = rotationAboutAxis( axis, s*self.twist_per_nt*self.num_nts, normalizeAxis=False )
orientation = rotationAboutAxis( axis, s*self.twist_per_nt*self.num_nts, normalizeAxis=True )
## TODO: ensure this is correct
# orientation = self.start_orientation.dot(orientation) # .dot( self.start_orientation )
orientation = orientation.dot( self.start_orientation )
......@@ -152,7 +151,7 @@ class Segment(ConnectableElement, Group):
def _get_num_beads(self, max_basepairs_per_bead, max_nucleotides_per_bead ):
raise NotImplementedError
def _generate_one_bead(self, pos, nts, orientation=None):
def _generate_one_bead(self, contour_position, nts):
raise NotImplementedError
def _assign_particles_to_locations(self):
......@@ -212,44 +211,27 @@ class Segment(ConnectableElement, Group):
if num_beads <= 2:
## not yet implemented for dsDNA
assert( isinstance(self, SingleStrandedSegment) )
b = self._generate_one_bead(0.5,
self.start_position,
self.num_nts,
self.start_orientation)
b = self._generate_one_bead(0.5, self.num_nts)
self.children.append(b)
self.beads.append(b) # don't add orientation bead
self._assign_particles_to_locations()
return
for i in range(num_beads+1):
nts = nts_per_bead
if i == 0 or i == num_beads:
nts *= 0.5
s = i*float(nts_per_bead)/(self.num_nts) # contour
pos = self.contour_to_position(s)
if self.start_orientation is not None:
axis = self.start_orientation.dot( np.array((0,0,1)) )
orientation = rotationAboutAxis( axis, s*self.twist_per_nt*self.num_nts, normalizeAxis=False )
## TODO: ensure this is correct
# orientation = self.start_orientation.dot(orientation) # .dot( self.start_orientation )
orientation = orientation.dot( self.start_orientation )
else:
orientation = None
b = self._generate_one_bead(s,pos,nts,orientation)
b = self._generate_one_bead(s,nts)
self.children.append(b)
self.beads.append(b) # don't add orientation bead
if "orientation_bead" in b.__dict__:
if "orientation_bead" in b.__dict__: # TODO: think of a cleaner approach
o = b.orientation_bead
self.children.append(o)
self.add_bond(b,o, Segment.orientation_bond, exclude=True)
# if last is not None:
# self.add_bond( i=last, j=b, bond="ssdna" )
# last = b
self._assign_particles_to_locations()
def _regenerate_beads(self, max_nts_per_bead=4, ):
......@@ -337,10 +319,10 @@ class DoubleStrandedSegment(Segment):
def _get_num_beads(self, max_basepairs_per_bead, max_nucleotides_per_bead):
return (self.num_nts // max_basepairs_per_bead) + 1
def _generate_one_bead(self, contour_position, pos, nts, orientation=None):
def _generate_one_bead(self, contour_position, nts):
pos = self.contour_to_position(contour_position)
if self.local_twist:
assert(orientation is not None)
# opos = pos + np.array((2,0,0)).dot(orientation)
orientation = self.contour_to_orientation(contour_position)
opos = pos + orientation.dot( np.array((Segment.orientation_bond.r0,0,0)) )
o = PointParticle( Segment.orientation_particle, opos, nts,
num_nts=nts, parent=self )
......@@ -424,7 +406,8 @@ class SingleStrandedSegment(Segment):
# pdb.set_trace()
return (self.num_nts // max_nucleotides_per_bead) + 1
def _generate_one_bead(self, contour_position, pos, nts, orientation=None):
def _generate_one_bead(self, contour_position, nts):
pos = self.contour_to_position(contour_position)
return PointParticle( Segment.ssDNA_particle, pos, nts,
num_nts=nts, parent=self,
contour_position=contour_position )
......
Supports Markdown
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