Commit 7bc1eb13 authored by cmaffeo2's avatar cmaffeo2
Browse files

Fixed issues with skips at crossovers, but needs testing

parent 1c6a70c2
......@@ -247,7 +247,7 @@ class cadnano_part(SegmentModel):
rev_idxs, rev_colors = rev_ss.dump(xover_list)
strand_list.append((fwd_idxs, rev_idxs))
## Get lists of 5/3prime ends
strands5 = [o.strand5p() for o in part.oligos()]
strands3 = [o.strand3p() for o in part.oligos()]
......@@ -401,7 +401,7 @@ class cadnano_part(SegmentModel):
nt += self.insertions[hid][i].length()
return nt
def _get_segment_nucleotide(self, hid, zid):
def _get_segment_nucleotide(self, hid, zid, get_forward_location=False):
""" returns segments and zero-based nucleotide index """
seg = self._get_segment(hid,zid)
sid = self.helices[hid].index(seg)
......@@ -409,23 +409,36 @@ class cadnano_part(SegmentModel):
zMid = int(0.5*(zmin+zmax))
occ = self.strand_occupancies[hid]
ins = self.insertions[hid]
## TODO combine if/else when nested TODO is resolved
# if zid in self.insertions[hid]:
# import pdb
# pdb.set_trace()
if (zMid not in occ[0]) and (zMid in occ[1]):
## reversed ssDNA strand
nt = zmax-zid
# TODO: for i in range(zmin,zid+1): ?
for i in range(zid,zmax):
for i in range(zid,zmax+1):
if i in self.insertions[hid]:
nt += self.insertions[hid][i].length()
else:
## normal condition
if get_forward_location:
while zid in ins and ins[zid].length() < 0 and zid <= zmax:
zid+=1
# else:
# while zid in ins and ins[zid].length() > 0 and zid >= zmax:
# zid-=1
nt = zid-zmin
# TODO: for i in range(zmin,zid+1): ?
for i in range(zmin,zid):
if i in self.insertions[hid]:
nt += self.insertions[hid][i].length()
if i in ins:
nt += ins[i].length()
if not get_forward_location and zid in ins:
nt += ins[zid].length()
## Find insertions
return seg, nt
......@@ -464,12 +477,14 @@ class cadnano_part(SegmentModel):
def _add_crossovers(self):
for h1,f1,z1,h2,f2,z2 in self.xover_list:
# if (h1 == 52 or h2 == 52) and z1 == 221:
# import pdb
# pdb.set_trace()
seg1, nt1 = self._get_segment_nucleotide(h1,z1)
seg2, nt2 = self._get_segment_nucleotide(h2,z2)
if (h1 == 15 and z1 == 230) or h2 == 15 and z2 == 231:
import pdb
pdb.set_trace()
seg1, nt1 = self._get_segment_nucleotide(h1,z1,not f1)
seg2, nt2 = self._get_segment_nucleotide(h2,z2,f2)
## TODO: use different types of crossovers
## fwd?
## 5'-to-3' direction
seg1.add_crossover(nt1,seg2,nt2,[f1,f2])
def _add_prime_ends(self):
......
......@@ -1047,10 +1047,9 @@ class Strand(Group):
## TODO disambiguate names of functions
def add_dna(self, segment, start, end, is_fwd):
# TODOTODO use nt pos ?
""" start/end should be provided expressed as contour_length, is_fwd tuples """
if not (segment.contour_to_nt_pos(np.abs(start-end)) > 0.9):
print( "WARNING: segment constructed with a very small number of nts ({})".format(segment.contour_to_nt_pos(np.abs(start-end))) )
""" start/end are given as nt """
if np.abs(start-end) <= 0.9:
print( "WARNING: segment constructed with a very small number of nts ({})".format(np.abs(start-end)) )
# import pdb
# pdb.set_trace()
for s in self.strand_segments:
......
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