Commit 07e916b3 authored by cmaffeo2's avatar cmaffeo2
Browse files

Made SegmentModel.get_location_at() search all location types, by default

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