Commit 5455d407 authored by cmaffeo2's avatar cmaffeo2
Browse files

Moved _connect_ends routine from 'DoubleStrandedSegment' to parent 'Segment'

parent f506105a
......@@ -754,6 +754,30 @@ class Segment(ConnectableElement, Group):
on_fwd_strand = True
self.add_location(nt,"3prime",on_fwd_strand)
## Real work
def _connect_ends(self, end1, end2, type_, force_connection=False):
debug = False
## TODO remove self?
## validate the input
for end in (end1, end2):
assert( isinstance(end, Location) )
assert( end.type_ in ("end3","end5") )
assert( end1.type_ != end2.type_ )
## Remove other connections involving these points
if end1.connection is not None:
if debug: print("WARNING: reconnecting {}".format(end1))
end1.connection.delete()
if end2.connection is not None:
if debug: print("WARNING: reconnecting {}".format(end2))
end2.connection.delete()
## Create and add connection
if end2.type_ == "end5":
end1.container._connect( end2.container, Connection( end1, end2, type_=type_ ), in_3prime_direction=True )
else:
end2.container._connect( end1.container, Connection( end2, end1, type_=type_ ), in_3prime_direction=True )
def get_3prime_locations(self):
return sorted(self.get_locations("3prime"),key=lambda x: x.address)
......@@ -1126,29 +1150,6 @@ class DoubleStrandedSegment(Segment):
loc.is_3prime_side_of_connection = True
other_loc.is_3prime_side_of_connection = False
## Real work
def _connect_ends(self, end1, end2, type_, force_connection):
debug = False
## TODO remove self?
## validate the input
for end in (end1, end2):
assert( isinstance(end, Location) )
assert( end.type_ in ("end3","end5") )
assert( end1.type_ != end2.type_ )
## Remove other connections involving these points
if end1.connection is not None:
if debug: print("WARNING: reconnecting {}".format(end1))
end1.connection.delete()
if end2.connection is not None:
if debug: print("WARNING: reconnecting {}".format(end2))
end2.connection.delete()
## Create and add connection
if end2.type_ == "end5":
end1.container._connect( end2.container, Connection( end1, end2, type_=type_ ), in_3prime_direction=True )
else:
end2.container._connect( end1.container, Connection( end2, end1, type_=type_ ), in_3prime_direction=True )
def _get_num_beads(self, contour, max_basepairs_per_bead, max_nucleotides_per_bead):
# return int(contour*self.num_nt // max_basepairs_per_bead)
return int(contour*(self.num_nt**2/(self.num_nt+1)) // max_basepairs_per_bead)
......@@ -2887,7 +2888,8 @@ class SegmentModel(ArbdModel):
history = []
if not strands_cover_segment(seg, is_fwd):
pos = nt = find_nt_not_in_strand(seg, is_fwd)
s = Strand(is_circular = True)
s = Strand(segname="S{:03d}".format(len(strands)),
is_circular = True)
history = _recursively_build_strand(s, seg, pos, is_fwd)
strands.append(s)
return history
......
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