本文整理汇总了Python中cadnano.strand.Strand类的典型用法代码示例。如果您正苦于以下问题:Python Strand类的具体用法?Python Strand怎么用?Python Strand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Strand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: redo
def redo(self):
# Remove the strand
strand = self._strand
strandset = self._strandset
# strandset._removeFromStrandList(strand)
doc = strandset._doc
doc.removeStrandFromSelection(strand)
strandset._strand_list.pop(self._s_set_idx)
strand5p = self._old_strand5p
strand3p = self._old_strand3p
oligo = self._oligo
olg5p = self._new_oligo5p
olg3p = self._new_oligo3p
#oligo.incrementLength(-strand.totalLength())
oligo.removeFromPart()
if strand5p is not None:
strand5p.setConnection3p(None)
if strand3p is not None:
strand3p.setConnection5p(None)
# Clear connections and update oligos
if strand5p is not None:
for s5p in oligo.strand5p().generator3pStrand():
Strand.setOligo(s5p, olg5p)
olg5p.refreshLength()
olg5p.addToPart(strandset.part())
if self._solo:
part = strandset.part()
vh = strandset.virtualHelix()
part.partActiveVirtualHelixChangedSignal.emit(part, vh)
#strand5p.strandXover5pChangedSignal.emit(strand5p, strand)
strand5p.strandUpdateSignal.emit(strand5p)
# end if
if strand3p is not None:
if not oligo.isLoop():
# apply 2nd oligo copy to all 3' downstream strands
for s3p in strand3p.generator3pStrand():
Strand.setOligo(s3p, olg3p)
olg3p.addToPart(strandset.part())
if self._solo:
part = strandset.part()
vh = strandset.virtualHelix()
part.partActiveVirtualHelixChangedSignal.emit(part, vh)
# strand.strandXover5pChangedSignal.emit(strand, strand3p)
strand3p.strandUpdateSignal.emit(strand3p)
# end if
# Emit a signal to notify on completion
strand.strandRemovedSignal.emit(strand)
if self.mids[0] is not None:
strand.part().removeModStrandInstance(strand, strand.lowIdx(), self.mids[0])
# strand.strandModsRemovedSignal.emit(strand, self.mids[0], strand.lowIdx())
if self.mids[1] is not None:
strand.part().removeModStrandInstance(strand, strand.highIdx(), self.mids[1])
# strand.strandModsRemovedSignal.emit(strand, self.mids[1], strand.highIdx())
# for updating the Slice View displayed helices
strandset.part().partStrandChangedSignal.emit(strandset.part(), strandset.virtualHelix())
示例2: redo
def redo(self):
visited = {}
doc = self._part.document()
for vh in self._part.getVirtualHelices():
stap_ss = vh.stapleStrandSet()
for strand in stap_ss:
visited[strand] = False
if self.include_scaffold:
scap_ss = vh.scaffoldStrandSet()
for strand in scap_ss:
visited[strand] = False
colors = self.colors
for strand in list(visited.keys()):
if visited[strand]:
continue
visited[strand] = True
start_oligo = strand.oligo()
if colors is not None:
if strand.isStaple():
start_oligo.setColor(colors[1])
else:
start_oligo.setColor(colors[0])
strand5gen = strand.generator5pStrand()
# this gets the oligo and burns a strand in the generator
strand5 = next(strand5gen)
for strand5 in strand5gen:
oligo5 = strand5.oligo()
if oligo5 != start_oligo:
oligo5.removeFromPart()
Strand.setOligo(strand5, start_oligo) # emits strandHasNewOligoSignal
visited[strand5] = True
# end for
start_oligo.setStrand5p(strand5)
# is it a loop?
if strand.connection3p() == strand5:
start_oligo.setLoop(True)
else:
strand3gen = strand.generator3pStrand()
strand3 = next(strand3gen) # burn one
for strand3 in strand3gen:
oligo3 = strand3.oligo()
if oligo3 != start_oligo:
oligo3.removeFromPart()
Strand.setOligo(strand3, start_oligo) # emits strandHasNewOligoSignal
visited[strand3] = True
# end for
start_oligo.refreshLength()
# end for
for strand in visited.keys():
strand.strandUpdateSignal.emit(strand)
示例3: redo
def redo(self):
ss = self._s_set
sL = self._strand_low
sH = self._strand_high
oS = self._old_strand
idx = self._s_set_idx
olg = self._old_oligo
doc = ss.document()
l_olg = self._l_oligo
h_olg = self._h_oligo
was_not_loop = l_olg != h_olg
# Remove old Strand from the s_set
ss._removeFromStrandList(oS)
# Add new strands to the s_set (reusing idx, so order matters)
ss._addToStrandList(sH, idx)
ss._addToStrandList(sL, idx)
# update connectivity of strands
sLcL = sL.connectionLow()
if sLcL:
if (oS.isDrawn5to3() and sLcL.isDrawn5to3()) or \
(not oS.isDrawn5to3() and not sLcL.isDrawn5to3()):
sLcL.setConnectionHigh(sL)
else:
sLcL.setConnectionLow(sL)
sHcH = sH.connectionHigh()
if sHcH:
if (oS.isDrawn5to3() and sHcH.isDrawn5to3()) or \
(not oS.isDrawn5to3() and not sHcH.isDrawn5to3()):
sHcH.setConnectionLow(sH)
else:
sHcH.setConnectionHigh(sH)
# Traverse the strands via 3'conns to assign the new oligos
for strand in l_olg.strand5p().generator3pStrand():
Strand.setOligo(strand, l_olg) # emits strandHasNewOligoSignal
if was_not_loop: # do the second oligo which is different
for strand in h_olg.strand5p().generator3pStrand():
# emits strandHasNewOligoSignal
Strand.setOligo(strand, h_olg)
# Add new oligo and remove old oligos from the part
olg.removeFromPart()
l_olg.addToPart(sL.part())
if was_not_loop:
h_olg.addToPart(sH.part())
# Emit Signals related to destruction and addition
oS.strandRemovedSignal.emit(oS)
ss.strandsetStrandAddedSignal.emit(ss, sH)
ss.strandsetStrandAddedSignal.emit(ss, sL)
示例4: resizeSelection
def resizeSelection(self, delta, use_undostack=True):
"""
Moves the selected idxs by delta by first iterating over all strands
to calculate new idxs (method will return if snap-to behavior would
create illegal state), then applying a resize command to each strand.
"""
resize_list = []
# calculate new idxs
for strandset_dict in self._selection_dict.values():
for strand, selected in strandset_dict.items():
part = strand.virtualHelix().part()
idxL, idxH = strand.idxs()
newL, newH = strand.idxs()
deltaL = deltaH = delta
# process xovers to get revised delta
if selected[0] and strand.connectionLow():
newL = part.xoverSnapTo(strand, idxL, delta)
if newL == None:
return
deltaH = newL-idxL
if selected[1] and strand.connectionHigh():
newH = part.xoverSnapTo(strand, idxH, delta)
if newH == None:
return
deltaL = newH-idxH
# process endpoints
if selected[0] and not strand.connectionLow():
newL = idxL + deltaL
if selected[1] and not strand.connectionHigh():
newH = idxH + deltaH
if newL > newH: # check for illegal state
return
resize_list.append((strand, newL, newH))
# end for
# end for
# execute the resize commands
if use_undostack:
self.undoStack().beginMacro("Resize Selection")
for strand, idxL, idxH in resize_list:
Strand.resize(strand, (idxL, idxH), use_undostack)
if use_undostack:
self.undoStack().endMacro()
示例5: undo
def undo(self):
ss = self._s_set
doc = ss._doc
sL = self._strand_low
sH = self._strand_high
nS = self._new_strand
idx = self._s_set_idx
olg = self._new_oligo
l_olg = self._s_low_oligo
h_olg = self._s_high_oligo
# Remove the new_strand from the s_set
ss._removeFromStrandList(nS)
# Add old strands to the s_set (reusing idx, so order matters)
ss._addToStrandList(sH, idx)
ss._addToStrandList(sL, idx)
# update connectivity of strands
sLcL = sL.connectionLow()
if sLcL:
if (sL.isDrawn5to3() and sLcL.isDrawn5to3()) or \
(not sL.isDrawn5to3() and not sLcL.isDrawn5to3()):
sLcL.setConnectionHigh(sL)
else:
sLcL.setConnectionLow(sL)
sHcH = sH.connectionHigh()
if sHcH:
if (sH.isDrawn5to3() and sHcH.isDrawn5to3()) or \
(not sH.isDrawn5to3() and not sHcH.isDrawn5to3()):
sHcH.setConnectionLow(sH)
else:
sHcH.setConnectionHigh(sH)
# Traverse the strands via 3'conns to assign the old oligo
for strand in l_olg.strand5p().generator3pStrand():
Strand.setOligo(strand, l_olg) # emits strandHasNewOligoSignal
for strand in h_olg.strand5p().generator3pStrand():
Strand.setOligo(strand, h_olg) # emits strandHasNewOligoSignal
# Remove new oligo and add old oligos
olg.removeFromPart()
l_olg.addToPart(sL.part())
if h_olg != l_olg:
h_olg.addToPart(sH.part())
# Emit Signals related to destruction and addition
nS.strandRemovedSignal.emit(nS)
ss.strandsetStrandAddedSignal.emit(ss, sL)
ss.strandsetStrandAddedSignal.emit(ss, sH)
# end def
# end class
示例6: undo
def undo(self):
ss = self._s_set
sL = self._strand_low
sH = self._strand_high
oS = self._old_strand
idx = self._s_set_idx
olg = self._old_oligo
doc = ss.document()
l_olg = self._l_oligo
h_olg = self._h_oligo
was_not_loop = l_olg != h_olg
# Remove new strands from the s_set (reusing idx, so order matters)
ss._removeFromStrandList(sL)
ss._removeFromStrandList(sH)
# Add the old strand to the s_set
ss._addToStrandList(oS, idx)
# update connectivity of strands
oScL = oS.connectionLow()
if oScL:
if (oS.isDrawn5to3() and oScL.isDrawn5to3()) or \
(not oS.isDrawn5to3() and not oScL.isDrawn5to3()):
oScL.setConnectionHigh(oS)
else:
oScL.setConnectionLow(oS)
oScH = oS.connectionHigh()
if oScH:
if (oS.isDrawn5to3() and oScH.isDrawn5to3()) or \
(not oS.isDrawn5to3() and not oScH.isDrawn5to3()):
oScH.setConnectionLow(oS)
else:
oScH.setConnectionHigh(oS)
# Traverse the strands via 3'conns to assign the old oligo
for strand in olg.strand5p().generator3pStrand():
Strand.setOligo(strand, olg)
# Add old oligo and remove new oligos from the part
olg.addToPart(ss.part())
l_olg.removeFromPart()
if was_not_loop:
h_olg.removeFromPart()
# Emit Signals related to destruction and addition
sL.strandRemovedSignal.emit(sL)
sH.strandRemovedSignal.emit(sH)
ss.strandsetStrandAddedSignal.emit(ss, oS)
# end def
# end class
示例7: sortedSelectedStrands
def sortedSelectedStrands(self, strandset):
# outList = self._selection_dict[strandset].keys()
# outList.sort(key=Strand.lowIdx)
out_list = [x for x in self._selection_dict[strandset].items()]
getLowIdx = lambda x: Strand.lowIdx(itemgetter(0)(x))
out_list.sort(key=getLowIdx)
return out_list
示例8: redo
def redo(self):
ss = self._s_set
doc = ss._doc
sL = self._strand_low
sH = self._strand_high
nS = self._new_strand
idx = self._s_set_idx
olg = self._new_oligo
l_olg = sL.oligo()
h_olg = sH.oligo()
# Remove old strands from the s_set (reusing idx, so order matters)
ss._removeFromStrandList(sL)
ss._removeFromStrandList(sH)
# Add the new_strand to the s_set
ss._addToStrandList(nS, idx)
# update connectivity of strands
nScL = nS.connectionLow()
if nScL:
if (nS.isDrawn5to3() and nScL.isDrawn5to3()) or \
(not nS.isDrawn5to3() and not nScL.isDrawn5to3()):
nScL.setConnectionHigh(nS)
else:
nScL.setConnectionLow(nS)
nScH = nS.connectionHigh()
if nScH:
if (nS.isDrawn5to3() and nScH.isDrawn5to3()) or \
(not nS.isDrawn5to3() and not nScH.isDrawn5to3()):
nScH.setConnectionLow(nS)
else:
nScH.setConnectionHigh(nS)
# Traverse the strands via 3'conns to assign the new oligo
for strand in olg.strand5p().generator3pStrand():
Strand.setOligo(strand, olg) # emits strandHasNewOligoSignal
# Add new oligo and remove old oligos
olg.addToPart(ss.part())
l_olg.removeFromPart()
if h_olg != l_olg: # check if a loop was created
h_olg.removeFromPart()
# Emit Signals related to destruction and addition
sL.strandRemovedSignal.emit(sL)
sH.strandRemovedSignal.emit(sH)
ss.strandsetStrandAddedSignal.emit(ss, nS)
示例9: sequenceExport
def sequenceExport(self, output):
""" Iterative appending to argument `output` which is a dictionary of
lists
Args:
output (dict): dictionary with keys given in `NucleicAcidPart.getSequences`
Returns:
dict:
"""
part = self.part()
vh_num5p = self.strand5p().idNum()
strand5p = self.strand5p()
idx5p = strand5p.idx5Prime()
seq = []
a_seq = []
if self.isLoop():
# print("A loop exists")
raise Exception
for strand in strand5p.generator3pStrand():
seq.append(Strand.sequence(strand, for_export=True))
a_seq.append(Strand.abstractSeq(strand))
if strand.connection3p() is None: # last strand in the oligo
vh_num3p = strand.idNum()
idx3p = strand.idx3Prime()
a_seq = ','.join(a_seq)
a_seq = "(%s)" % (a_seq)
modseq5p, modseq5p_name = part.getStrandModSequence(strand5p, idx5p,
ModType.END_5PRIME)
modseq3p, modseq3p_name = part.getStrandModSequence(strand, idx3p,
ModType.END_3PRIME)
seq = ''.join(seq)
seq = modseq5p + seq + modseq3p
# output = "%d[%d]\t%d[%d]\t%s\t%s\t%s\t%s\t(%s)\n" % \
# (vh_num5p, idx5p, vh_num3p, idx3p, self.getColor(),
# modseq5p_name, seq, modseq3p_name, a_seq)
# these are the keys
# keys = ['Start','End','Color', 'Mod5',
# 'Sequence','Mod3','AbstractSequence']
output['Start'].append("%d[%d]" % (vh_num5p, idx5p))
output['End'].append("%d[%d]" % (vh_num3p, idx3p))
output['Color'].append(self.getColor())
output['Mod5'].append(modseq5p_name)
output['Sequence'].append(seq)
output['Mod3'].append(modseq3p_name)
output['AbstractSequence'].append(a_seq)
return output
示例10: redo
def redo(self):
part = self._part
strand5p = self._strand5p
strand5p_idx = self._strand5p_idx
strand3p = self._strand3p
strand3p_idx = self._strand3p_idx
olg5p = strand5p.oligo()
old_olg3p = self._old_oligo3p
# 0. Deselect the involved strands
doc = strand5p.document()
doc.removeStrandFromSelection(strand5p)
doc.removeStrandFromSelection(strand3p)
if self._update_oligo:
# Test for Loopiness
if olg5p == strand3p.oligo():
olg5p.setLoop(True)
else:
# 1. update preserved oligo length
olg5p.incrementLength(old_olg3p.length())
# 2. Remove the old oligo and apply the 5' oligo to the 3' strand
old_olg3p.removeFromPart()
for strand in strand3p.generator3pStrand():
# emits strandHasNewOligoSignal
Strand.setOligo(strand, olg5p)
# 3. install the Xover
strand5p.setConnection3p(strand3p)
strand3p.setConnection5p(strand5p)
#print('strand5p = %s, connection3p = %s'%(strand5p._name, strand3p._name))
ss5 = strand5p.strandSet()
vh5p = ss5.virtualHelix()
st5p = ss5.strandType()
ss3 = strand3p.strandSet()
vh3p = ss3.virtualHelix()
st3p = ss3.strandType()
part.partActiveVirtualHelixChangedSignal.emit(part, vh5p)
# strand5p.strandXover5pChangedSignal.emit(strand5p, strand3p)
# if self._update_oligo and not getBatch():
if self._update_oligo:
strand5p.strandUpdateSignal.emit(strand5p)
strand3p.strandUpdateSignal.emit(strand3p)
示例11: _strandMergeUpdate
def _strandMergeUpdate(self, old_strand_low: Strand,
old_strand_high: Strand,
new_strand: Strand):
"""This method sets the isCircular status of the oligo and the oligo's
5' strand.
"""
# check loop status
if old_strand_low.oligo() == old_strand_high.oligo():
self._is_circular = True
self._strand5p = new_strand
return
# leave the _strand5p as is?
# end if
# Now get correct 5p end to oligo
if old_strand_low.isForward():
if old_strand_low.connection5p() is not None:
self._strand5p = old_strand_low.oligo()._strand5p
else:
self._strand5p = new_strand
else:
if old_strand_high.connection5p() is not None:
self._strand5p = old_strand_high.oligo()._strand5p
else:
self._strand5p = new_strand
示例12: sequence
def sequence(self):
temp = self.strand5p()
if not temp:
return None
if temp.sequence():
return ''.join([Strand.sequence(strand) \
for strand in self.strand5p().generator3pStrand()])
else:
return None
示例13: isModelStrandSelected
def isModelStrandSelected(self, strand: Strand) -> bool:
ss = strand.strandSet()
if ss in self._selection_dict:
if strand in self._selection_dict[ss]:
return True
else:
return False
else:
return False
示例14: undo
def undo(self):
part = self._part
strand5p = self._strand5p
strand5p_idx = self._strand5p_idx
strand3p = self._strand3p
strand3p_idx = self._strand3p_idx
olg5p = strand5p.oligo()
new_olg3p = self._new_oligo3p
# 0. Deselect the involved strands
doc = strand5p.document()
doc.removeStrandFromSelection(strand5p)
doc.removeStrandFromSelection(strand3p)
if self._isLoop:
olg5p.setLoop(True)
# No need to restore whatever the old Oligo._strand5p was
else:
# 1. update preserved oligo length
olg5p.incrementLength(new_olg3p.length())
# 2. Remove the old oligo and apply the 5' oligo to the 3' strand
new_olg3p.removeFromPart()
for strand in strand3p.generator3pStrand():
# emits strandHasNewOligoSignal
Strand.setOligo(strand, olg5p)
# end else
# 3. install the Xover
strand5p.setConnection3p(strand3p)
strand3p.setConnection5p(strand5p)
ss5 = strand5p.strandSet()
vh5p = ss5.virtualHelix()
st5p = ss5.strandType()
ss3 = strand3p.strandSet()
vh3p = ss3.virtualHelix()
st3p = ss3.strandType()
part.partActiveVirtualHelixChangedSignal.emit(part, vh5p)
# strand5p.strandXover5pChangedSignal.emit(strand5p, strand3p)
strand5p.strandUpdateSignal.emit(strand5p)
strand3p.strandUpdateSignal.emit(strand3p)
# end def
# end class
示例15: __init__
def __init__(self, strandset, base_idx_low, base_idx_high, strandset_idx):
super(CreateStrandCommand, self).__init__("create strand")
self._strandset = strandset
self._s_set_idx = strandset_idx
doc = strandset.document()
self._strand = Strand(strandset, base_idx_low, base_idx_high)
colorList = prefs.STAP_COLORS if strandset.isStaple() else prefs.SCAF_COLORS
color = random.choice(colorList).name()
self._new_oligo = Oligo(None, color) # redo will set part
self._new_oligo.setLength(self._strand.totalLength())