Commit 22eda98a authored by cmaffeo2's avatar cmaffeo2
Browse files

Made intrahelical connections remove any existing connections; important for...

Made intrahelical connections remove any existing connections; important for intrahelical "crossovers"
parent bcd1753a
......@@ -104,6 +104,12 @@ class Connection():
else:
raise Exception("OutOfBoundsError")
def delete(self):
self.A.container.connections.remove(self)
self.B.container.connections.remove(self)
self.A.connection = None
self.B.connection = None
def __repr__(self):
return "<Connection {}--{}--{}]>".format( self.A, self.type_, self.B )
......@@ -858,6 +864,15 @@ class DoubleStrandedSegment(Segment):
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:
print("WARNING: reconnecting {}".format(end1))
end1.connection.delete()
if end2.connection is not None:
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 )
......@@ -923,19 +938,33 @@ class SingleStrandedSegment(Segment):
def _connect_end(self, other, _5_to_3, force_connection):
assert( isinstance(other, Location) )
if _5_to_3 == True:
my_end = self.end3
seg1 = self
seg2 = other.container
end1 = self.end3
end2 = other
# assert( other.type_ == "end5" )
if (other.type_ is not "end5"):
print("Warning: code does not prevent connecting 3prime to 3prime, etc")
conn = Connection( my_end, other, type_="intrahelical" )
self._connect( other.container, conn, in_3prime_direction=True )
else:
my_end = self.end5
seg1 = other.container
seg2 = self
end1 = other
end2 = self.end5
# assert( other.type_ == "end3" )
if (other.type_ is not "end3"):
print("Warning: code does not prevent connecting 3prime to 3prime, etc")
conn = Connection( other, my_end, type_="intrahelical" )
other.container._connect( self, conn, in_3prime_direction=True )
## Remove other connections involving these points
if end1.connection is not None:
print("WARNING: reconnecting {}".format(end1))
end1.connection.delete()
if end2.connection is not None:
print("WARNING: reconnecting {}".format(end2))
end2.connection.delete()
conn = Connection( end1, end2, type_="intrahelical" )
seg1._connect( seg2, conn, in_3prime_direction=True )
def add_crossover(self, nt, other, other_nt, strands_fwd=(True,False), nt_on_5prime=True):
""" Add a crossover between two helices """
......
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