Commit 78cb44eb authored by cmaffeo2's avatar cmaffeo2
Browse files

Changed how particles are named so that it no longer reflects the number of...

Changed how particles are named so that it no longer reflects the number of nucleotides represented, but is more robust to clashes
parent 4c1a3d1c
......@@ -327,9 +327,12 @@ class cadnano_part(SegmentModel):
bp = int(round(b.get_nt_position(segment)))
if bp < 0: bp = 0
if bp >= segment.num_nt: bp = segment.num_nt-1
b.beta = bp_to_zidx[bp]
if 'orientation_bead' in b.__dict__:
b.orientation_bead.beta = bp_to_zidx[bp]
try:
b.beta = bp_to_zidx[bp]
if 'orientation_bead' in b.__dict__:
b.orientation_bead.beta = bp_to_zidx[bp]
except:
pass
seg._generate_bead_callbacks.append(callback)
def atomic_callback(nucleotide, bp_to_zidx=bp_to_zidx):
......@@ -338,8 +341,11 @@ class cadnano_part(SegmentModel):
bp = int(round(segment.contour_to_nt_pos( nt.contour_position )))
if bp < 0: bp = 0
if bp >= segment.num_nt: bp = segment.num_nt-1
nt.beta = bp_to_zidx[bp]
nt.parent.occupancy = segment.occupancy
try:
nt.beta = bp_to_zidx[bp]
nt.parent.occupancy = segment.occupancy
except:
pass
seg._generate_nucleotide_callbacks.append(atomic_callback)
......
......@@ -276,8 +276,8 @@ class SegmentParticle(PointParticle):
if seg == target_seg:
# pdb.set_trace()
## Found a segment in our target
sign = (contour_in_seg == 1) - (contour_in_seg == 0)
assert( sign in (1,-1) )
sign = 1 if contour_in_seg == 1 else -1
if sign == -1: assert( contour_in_seg == 0 )
if distance < cutoff: # TODO: check if this does anything
cutoff = distance
return [[distance, contour_in_seg+sign*seg.nt_pos_to_contour(distance)]], [(seg, contour_in_seg, distance)]
......@@ -1932,17 +1932,21 @@ class SegmentModel(ArbdModel):
""" Reassign bead types """
if self.DEBUG: print("Assigning bead types")
beadtype_s = dict()
beadtype_count = dict(D=0,O=0,S=0)
def _assign_bead_type(bead, num_nt, decimals):
num_nt0 = bead.num_nt
bead.num_nt = np.around( np.float32(num_nt), decimals=decimals )
key = (bead.type_.name[0].upper(), bead.num_nt)
char = bead.type_.name[0].upper()
key = (char, bead.num_nt)
if key in beadtype_s:
bead.type_ = beadtype_s[key]
else:
t = deepcopy(bead.type_)
t.__dict__["nts"] = bead.num_nt*2 if t.name[0].upper() in ("D","O") else bead.num_nt
t.name = t.name + "%03d" % (t.nts*10**decimals)
t.__dict__["nts"] = bead.num_nt*2 if char in ("D","O") else bead.num_nt
# t.name = t.name + "%03d" % (t.nts*10**decimals)
t.name = char + "%03d" % (beadtype_count[char])
beadtype_count[char] += 1
if self.DEBUG: print( "{} --> {} ({})".format(num_nt0, bead.num_nt, t.name) )
beadtype_s[key] = bead.type_ = t
......
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