Commit e440cc78 authored by cmaffeo2's avatar cmaffeo2
Browse files

Enabled automatic creation of terminal 5prime and 3prime ends

parent 6f48f441
......@@ -2061,41 +2061,33 @@ class SegmentModel(ArbdModel):
""" Ensure unconnected ends have 5prime Location objects """
for seg in self.segments:
## TODO move into Segment calls
import pdb
if False: # TODO: Make this happen conditionally
if seg.start5.connection is None:
add_end = True
for l in seg.get_locations("5prime"):
if l.address == 0 and l.on_fwd_strand:
add_end = False
break
if add_end:
seg.add_5prime(0)
if 'end5' in seg.__dict__ and seg.end5.connection is None:
add_end = True
for l in seg.get_locations("5prime"):
if l.address == 1 and (l.on_fwd_strand is False):
add_end = False
break
if add_end:
seg.add_5prime(seg.num_nt-1,on_fwd_strand=False)
if 'start3' in seg.__dict__ and seg.start3.connection is None:
add_end = True
for l in seg.get_locations("3prime"):
if l.address == 0 and (l.on_fwd_strand is False):
add_end = False
break
if add_end:
seg.add_3prime(0,on_fwd_strand=False)
if seg.end3.connection is None:
add_end = True
for l in seg.get_locations("3prime"):
if l.address == 1 and l.on_fwd_strand:
add_end = False
break
if add_end:
seg.add_3prime(seg.num_nt-1)
five_prime_locs = seg.get_locations("5prime")
three_prime_locs = seg.get_locations("3prime")
def is_start_5prime(l):
return l.get_nt_pos() < 1 and l.on_fwd_strand
def is_end_5prime(l):
return l.get_nt_pos() > seg.num_nt-1 and not l.on_fwd_strand
def is_start_3prime(l):
return l.get_nt_pos() < 1 and not l.on_fwd_strand
def is_end_3prime(l):
return l.get_nt_pos() > seg.num_nt-1 and l.on_fwd_strand
if seg.start5.connection is None:
if len(list(filter( is_start_5prime, five_prime_locs ))) == 0:
seg.add_5prime(0) # TODO ensure this is the same place
if 'end5' in seg.__dict__ and seg.end5.connection is None:
if len(list(filter( is_end_5prime, five_prime_locs ))) == 0:
seg.add_5prime(seg.num_nt-1,on_fwd_strand=False)
if 'start3' in seg.__dict__ and seg.start3.connection is None:
if len(list(filter( is_start_3prime, three_prime_locs ))) == 0:
seg.add_3prime(0,on_fwd_strand=False)
if seg.end3.connection is None:
if len(list(filter( is_end_3prime, three_prime_locs ))) == 0:
seg.add_3prime(seg.num_nt-1)
# print( [(l,l.get_connected_location()) for l in seg.locations] )
# addresses = np.array([l.address for l in seg.get_locations("5prime")])
......
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