diff --git a/dnarbd/segmentmodel.py b/dnarbd/segmentmodel.py index cf834d67a93cff22d93eaf4daa14a082f4e13bfe..30d01bc4f7b8eb503fa1970e26274535aaaa1baf 100644 --- a/dnarbd/segmentmodel.py +++ b/dnarbd/segmentmodel.py @@ -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,22 +1601,22 @@ 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 - + if b is None: ## need to generate a bead if isinstance(s2,DoubleStrandedSegment):