Commit 243a46e5 authored by cmaffeo2's avatar cmaffeo2
Browse files

Made DoubleStrandedSegment.__init__ use num_bp instead of num_nts

parent 5d97a736
...@@ -306,8 +306,8 @@ class cadnano_part(SegmentModel): ...@@ -306,8 +306,8 @@ class cadnano_part(SegmentModel):
print("Adding helix with length",numBps,zid1,zid2) print("Adding helix with length",numBps,zid1,zid2)
kwargs = dict(name="%d-%d" % (hid,len(helices[hid])), kwargs = dict(name="%d-%d" % (hid,len(helices[hid])))
num_nts = numBps)
posargs1 = dict( start_position = self._get_cadnano_position(hid,zid1), posargs1 = dict( start_position = self._get_cadnano_position(hid,zid1),
end_position = self._get_cadnano_position(hid,zid2) ) end_position = self._get_cadnano_position(hid,zid2) )
...@@ -316,10 +316,13 @@ class cadnano_part(SegmentModel): ...@@ -316,10 +316,13 @@ class cadnano_part(SegmentModel):
## TODO get sequence from cadnano api ## TODO get sequence from cadnano api
if zMid in strandOccupancies[0] and zMid in strandOccupancies[1]: if zMid in strandOccupancies[0] and zMid in strandOccupancies[1]:
kwargs['num_bp'] = numBps
seg = DoubleStrandedSegment(**kwargs,**posargs1) seg = DoubleStrandedSegment(**kwargs,**posargs1)
elif zMid in strandOccupancies[0]: elif zMid in strandOccupancies[0]:
kwargs['num_nts'] = numBps
seg = SingleStrandedSegment(**kwargs,**posargs1) seg = SingleStrandedSegment(**kwargs,**posargs1)
elif zMid in strandOccupancies[1]: elif zMid in strandOccupancies[1]:
kwargs['num_nts'] = numBps
seg = SingleStrandedSegment(**kwargs,**posargs2) seg = SingleStrandedSegment(**kwargs,**posargs2)
else: else:
raise Exception("Segment could not be found") raise Exception("Segment could not be found")
......
...@@ -284,7 +284,7 @@ def convert_maya_to_segments(helices): ...@@ -284,7 +284,7 @@ def convert_maya_to_segments(helices):
botPos = 0.5 * (bot.get_position() + bot.basepair.get_position()) botPos = 0.5 * (bot.get_position() + bot.basepair.get_position())
topPos = 0.5 * (top.get_position() + top.basepair.get_position()) topPos = 0.5 * (top.get_position() + top.basepair.get_position())
segments[hn] = DoubleStrandedSegment(hn, num_nts = len(z)//2, segments[hn] = DoubleStrandedSegment(hn, num_bp = len(z)//2,
start_position = botPos, start_position = botPos,
end_position = topPos) end_position = topPos)
segmentsBot[hn] = bot segmentsBot[hn] = bot
......
...@@ -761,7 +761,7 @@ class DoubleStrandedSegment(Segment): ...@@ -761,7 +761,7 @@ class DoubleStrandedSegment(Segment):
""" Class that describes a segment of ssDNA. When built from """ Class that describes a segment of ssDNA. When built from
cadnano models, should not span helices """ cadnano models, should not span helices """
def __init__(self, name, num_nts, start_position = np.array((0,0,0)), def __init__(self, name, num_bp, start_position = np.array((0,0,0)),
end_position = None, end_position = None,
segment_model = None, segment_model = None,
local_twist = False, local_twist = False,
...@@ -771,15 +771,16 @@ class DoubleStrandedSegment(Segment): ...@@ -771,15 +771,16 @@ class DoubleStrandedSegment(Segment):
self.helical_rise = 10.44 self.helical_rise = 10.44
self.distance_per_nt = 3.4 self.distance_per_nt = 3.4
Segment.__init__(self, name, num_nts, Segment.__init__(self, name, num_bp,
start_position, start_position,
end_position, end_position,
segment_model) segment_model)
self.num_bp = self.num_nts
self.local_twist = local_twist self.local_twist = local_twist
if num_turns is None: if num_turns is None:
num_turns = float(num_nts) / self.helical_rise num_turns = float(num_bp) / self.helical_rise
self.twist_per_nt = float(360 * num_turns) / num_nts self.twist_per_nt = float(360 * num_turns) / num_bp
if start_orientation is None: if start_orientation is None:
start_orientation = np.eye(3) # np.array(((1,0,0),(0,1,0),(0,0,1))) start_orientation = np.eye(3) # np.array(((1,0,0),(0,1,0),(0,0,1)))
...@@ -998,7 +999,7 @@ class SingleStrandedSegment(Segment): ...@@ -998,7 +999,7 @@ class SingleStrandedSegment(Segment):
class StrandInSegment(Group): class StrandInSegment(Group):
""" Class that holds atomic model, maps to segment """ """ Represents a piece of an ssDNA strand within a segment """
def __init__(self, segment, start, end, is_fwd): def __init__(self, segment, start, end, is_fwd):
""" start/end should be provided expressed in nt coordinates, is_fwd tuples """ """ start/end should be provided expressed in nt coordinates, is_fwd tuples """
...@@ -1014,8 +1015,6 @@ class StrandInSegment(Group): ...@@ -1014,8 +1015,6 @@ class StrandInSegment(Group):
self.num_nts = int(round(nts)) self.num_nts = int(round(nts))
assert( np.isclose(self.num_nts,nts) ) assert( np.isclose(self.num_nts,nts) )
# print(" Creating {}-nt StrandInSegment in {} from {} to {} {}".format(self.num_nts, segment.name, start, end, is_fwd))
def _nucleotide_ids(self): def _nucleotide_ids(self):
nt0 = self.start # seg.contour_to_nt_pos(self.start) nt0 = self.start # seg.contour_to_nt_pos(self.start)
assert( np.abs(nt0 - round(nt0)) < 1e-5 ) assert( np.abs(nt0 - round(nt0)) < 1e-5 )
...@@ -1039,7 +1038,7 @@ class StrandInSegment(Group): ...@@ -1039,7 +1038,7 @@ class StrandInSegment(Group):
return np.linspace(c0,c1,self.num_nts) return np.linspace(c0,c1,self.num_nts)
class Strand(Group): class Strand(Group):
""" Class that holds atomic model, maps to segments """ """ Represents an entire ssDNA strand from 5' to 3' as it routes through segments """
def __init__(self, segname = None): def __init__(self, segname = None):
Group.__init__(self) Group.__init__(self)
self.num_nts = 0 self.num_nts = 0
......
...@@ -14,7 +14,7 @@ PATH=/home/cmaffeo2/anaconda3/bin:$PATH; source activate cadnano ...@@ -14,7 +14,7 @@ PATH=/home/cmaffeo2/anaconda3/bin:$PATH; source activate cadnano
if __name__ == "__main__": if __name__ == "__main__":
seg1 = DoubleStrandedSegment("strand", num_nts = 46) seg1 = DoubleStrandedSegment("strand", num_bp = 46)
seg2 = SingleStrandedSegment("strand", seg2 = SingleStrandedSegment("strand",
start_position = seg1.end_position + np.array((5,0,5)), start_position = seg1.end_position + np.array((5,0,5)),
......
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