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

Improved placement of beads

Code now always places a ssDNA bead when an ssDNA segment is between two dsDNA segments.

Code now more robustly places a bead and intrahelical junctions
parent 43af36b0
......@@ -756,6 +756,12 @@ class Segment(ConnectableElement, Group):
# print(" %s working on %d to %d" % (self.name, eb1.position[2], eb2.position[2]))
e_ds = eb2.get_contour_position(self) - eb1.get_contour_position(self)
num_beads = self._get_num_beads( e_ds, max_basepairs_per_bead, max_nucleotides_per_bead )
## Ensure there is a ssDNA bead between dsDNA beads
if num_beads == 0 and isinstance(self,SingleStrandedSegment) and isinstance(eb1.parent,DoubleStrandedSegment) and isinstance(eb2.parent,DoubleStrandedSegment):
num_beads = 1
## TODO similarly ensure there is a dsDNA bead between ssDNA beads
ds = e_ds / (num_beads+1)
nts = ds*self.num_nt
eb1.num_nt += 0.5*nts
......@@ -1595,18 +1601,18 @@ class SegmentModel(ArbdModel):
## TODO improve this for combinations of ssDNA and dsDNA (maybe a1/a2 should be calculated differently)
b = None
if isinstance(s1,DoubleStrandedSegment):
b = s1.get_nearest_bead(a1)
if b is not None:
if np.abs(b.get_nt_position(s1) - s1.contour_to_nt_pos(a1)) > 0.5:
b = None
elif isinstance(s2,DoubleStrandedSegment):
if b is None and isinstance(s2,DoubleStrandedSegment):
b = s2.get_nearest_bead(a2)
if b is not None:
if np.abs(b.get_nt_position(s2) - s2.contour_to_nt_pos(a2)) > 0.5:
b = None
else:
b = None
if b is not None and b.parent not in (s1,s2):
b = None
......
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