diff --git a/mrdna/segmentmodel.py b/mrdna/segmentmodel.py index 88949e744d2e90c85fa932d6b38ee685af58551e..3234f1006be2047133d523413033af2871d583c9 100644 --- a/mrdna/segmentmodel.py +++ b/mrdna/segmentmodel.py @@ -158,7 +158,7 @@ class ConnectableElement(): assert( np.all( [counter[l] == 1 for l in locs] ) ) return locs - def get_location_at(self, address, on_fwd_strand=True, new_type="crossover"): + def get_location_at(self, address, on_fwd_strand=True, new_type=None): loc = None if (self.num_nt == 1): # import pdb @@ -174,7 +174,7 @@ class ConnectableElement(): if l.address == address and l.on_fwd_strand == on_fwd_strand: assert(loc is None) loc = l - if loc is None: + if loc is None and new_type is not None: loc = Location( self, address=address, type_=new_type, on_fwd_strand=on_fwd_strand ) return loc @@ -1233,7 +1233,7 @@ class DoubleStrandedSegment(Segment): elif nt == self.num_nt-1 and strands_fwd[0]: loc = self.end3 else: - loc = self.get_location_at(c, strands_fwd[0]) + loc = self.get_location_at(c, strands_fwd[0], new_type='crossover') c = other.nt_pos_to_contour(other_nt) # TODOTODO: may need to subtract or add a little depending on 3prime/5prime @@ -1244,7 +1244,7 @@ class DoubleStrandedSegment(Segment): elif other_nt == other.num_nt-1 and not strands_fwd[1]: other_loc = other.end5 else: - other_loc = other.get_location_at(c, strands_fwd[1]) + other_loc = other.get_location_at(c, strands_fwd[1], new_type='crossover') self._connect(other, Connection( loc, other_loc, type_=type_ )) if nt_on_5prime: @@ -1370,7 +1370,7 @@ class SingleStrandedSegment(Segment): c1 = 1 else: raise Exception("Crossovers can only be at the ends of an ssDNA segment") - loc = self.get_location_at(c1, True) + loc = self.get_location_at(c1, True, new_type='crossover') if other_nt == 0: c2 = 0 @@ -1382,7 +1382,7 @@ class SingleStrandedSegment(Segment): if isinstance(other,SingleStrandedSegment): ## Ensure connections occur at opposing ends assert(np.isclose(other_nt,0) or np.isclose(other_nt,self.num_nt-1)) - other_loc = other.get_location_at( c2, True ) + other_loc = other.get_location_at( c2, True, new_type='crossover') # if ("22-2" in (self.name, other.name)): # pdb.set_trace() if nt_on_5prime: @@ -1392,7 +1392,7 @@ class SingleStrandedSegment(Segment): else: assert(c2 >= 0 and c2 <= 1) - other_loc = other.get_location_at( c2, strands_fwd[1] ) + other_loc = other.get_location_at( c2, strands_fwd[1], new_type='crossover') if nt_on_5prime: self._connect(other, Connection( loc, other_loc, type_="sscrossover" ), in_3prime_direction=True ) else: