Ejemplo n.º 1
0
 def applyColor(self, color, useUndoStack=True):
     if color == self._color:
         return  # oligo already has color
     c = Oligo.ApplyColorCommand(self, color)
     util.execCommandList(self, [c],
                          desc="Color Oligo",
                          useUndoStack=useUndoStack)
Ejemplo n.º 2
0
 def _addPart(self, part, useUndoStack=True):
     """Add part to the document via AddPartCommand."""
     c = self.AddPartCommand(self, part)
     util.execCommandList(self, [c],
                          desc="Add part",
                          useUndoStack=useUndoStack)
     return c.part()
Ejemplo n.º 3
0
 def resize(self, newIdxs, useUndoStack=True):
     cmds = []
     if self.strandSet().isScaffold():
         cmds.append(self.oligo().applySequenceCMD(None))
     cmds += self.getRemoveInsertionCommands(newIdxs)
     cmds.append(Strand.ResizeCommand(self, newIdxs))
     util.execCommandList(
                         self, cmds, desc="Resize strand",
                         useUndoStack=useUndoStack)
Ejemplo n.º 4
0
 def resize(self, newIdxs, useUndoStack=True):
     cmds = []
     if self.strandSet().isScaffold():
         cmds.append(self.oligo().applySequenceCMD(None))
     cmds += self.getRemoveInsertionCommands(newIdxs)
     cmds.append(Strand.ResizeCommand(self, newIdxs))
     util.execCommandList(
                         self, cmds, desc="Resize strand",
                         useUndoStack=useUndoStack)
Ejemplo n.º 5
0
 def removeInsertion(self,  idx, useUndoStack=True):
     cmds = []
     idxLow, idxHigh = self.idxs()
     if idxLow <= idx <= idxHigh:
         if self.hasInsertionAt(idx):
             cmds.append(self.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
             for strand in self.getComplementStrands():
                 cmds.append(strand.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
             cmds.append(Strand.RemoveInsertionCommand(self, idx))
             util.execCommandList(
                                 self, cmds, desc="Remove Insertion",
                                 useUndoStack=useUndoStack)
Ejemplo n.º 6
0
 def removeInsertion(self,  idx, useUndoStack=True):
     cmds = []
     idxLow, idxHigh = self.idxs()
     if idxLow <= idx <= idxHigh:
         if self.hasInsertionAt(idx):
             cmds.append(self.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
             for strand in self.getComplementStrands():
                 cmds.append(strand.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
             cmds.append(Strand.RemoveInsertionCommand(self, idx))
             util.execCommandList(
                                 self, cmds, desc="Remove Insertion",
                                 useUndoStack=useUndoStack)
Ejemplo n.º 7
0
 def mergeStrands(self, priorityStrand, otherStrand, useUndoStack=True):
     """
     Merge the priorityStrand and otherStrand into a single new strand.
     The oligo of priority should be propagated to the other and all of
     its connections.
     """
     lowAndHighStrands = self.strandsCanBeMerged(priorityStrand, otherStrand)
     if lowAndHighStrands:
         strandLow, strandHigh = lowAndHighStrands
         isInSet, overlap, lowStrandSetIdx = self._findIndexOfRangeFor(strandLow)
         if isInSet:
             c = StrandSet.MergeCommand(strandLow, strandHigh, \
                                         lowStrandSetIdx, priorityStrand)
             util.execCommandList(self, [c], desc="Merge", useUndoStack=useUndoStack)
Ejemplo n.º 8
0
 def splitStrand(self, strand, baseIdx, updateSequence=True, useUndoStack=True):
     """
     Break strand into two strands. Reapply sequence by default (disabled
     during autostaple).
     """
     if self.strandCanBeSplit(strand, baseIdx):
         isInSet, overlap, strandSetIdx = self._findIndexOfRangeFor(strand)
         if isInSet:
             c = StrandSet.SplitCommand(strand, baseIdx, strandSetIdx, updateSequence)
             util.execCommandList(self, [c], desc="Split", useUndoStack=useUndoStack)
             return True
         else:
             return False
     else:
         return False
Ejemplo n.º 9
0
 def createDeserializedStrand(self, baseIdxLow, baseIdxHigh, useUndoStack=False):
     """
     Passes a strand to AddStrandCommand that was read in from file input.
     Omits the step of checking _couldStrandInsertAtLastIndex, since
     we assume that deserialized strands will not cause collisions.
     """
     boundsLow, boundsHigh = self.getBoundsOfEmptyRegionContaining(baseIdxLow)
     assert(baseIdxLow < baseIdxHigh)
     assert(boundsLow <= baseIdxLow)
     assert(baseIdxHigh <= boundsHigh)
     canInsert, strandSetIdx = self.getIndexToInsert(baseIdxLow, baseIdxHigh)
     if canInsert:
         c = StrandSet.CreateStrandCommand(self, baseIdxLow, baseIdxHigh, strandSetIdx)
         util.execCommandList(self, [c], desc=None, useUndoStack=useUndoStack)
         return strandSetIdx
     else:
         return -1
Ejemplo n.º 10
0
 def removeStrand(self, strand, strandSetIdx=None, useUndoStack=True, solo=True):
     """
     solo is an argument to enable limiting signals emiting from
     the command in the case the command is instantiated part of a larger
     command
     """
     cmds = []
     if strandSetIdx == None:
         isInSet, overlap, strandSetIdx = self._findIndexOfRangeFor(strand)
         if not isInSet:
             raise IndexError
     if self.isScaffold() and strand.sequence() != None:
         cmds.append(strand.oligo().applySequenceCMD(None))
     cmds += strand.clearDecoratorCommands()
     cmds.append(StrandSet.RemoveStrandCommand(self, strand, strandSetIdx, solo))
     util.execCommandList(self, cmds, desc="Remove strand", useUndoStack=useUndoStack)
     return strandSetIdx
Ejemplo n.º 11
0
 def changeInsertion(self, idx, length, useUndoStack=True):
     cmds = []
     idxLow, idxHigh = self.idxs()
     if idxLow <= idx <= idxHigh:
         if self.hasInsertionAt(idx):
             if length == 0:
                 self.removeInsertion(idx)
             else:
                 # make sure length is -1 if a skip
                 if length < 0:
                     length = -1
                 cmds.append(self.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
                 for strand in self.getComplementStrands():
                     cmds.append(strand.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
                 cmds.append(
                         Strand.ChangeInsertionCommand(self, idx, length))
                 util.execCommandList(
                                     self, cmds, desc="Change Insertion",
                                     useUndoStack=useUndoStack)
Ejemplo n.º 12
0
 def createStrand(self, baseIdxLow, baseIdxHigh, useUndoStack=True):
     """
     Assumes a strand is being created at a valid set of indices.
     """
     boundsLow, boundsHigh = \
                         self.getBoundsOfEmptyRegionContaining(baseIdxLow)
     canInsert, strandSetIdx = \
                             self.getIndexToInsert(baseIdxLow, baseIdxHigh)
     if canInsert:
         c = StrandSet.CreateStrandCommand(self,
                                     baseIdxLow, baseIdxHigh, strandSetIdx)
         row, col = self._virtualHelix.coord()
         # d = "(%d,%d).%d + [%d,%d]" % \
         #             (row, col, self._strandType, baseIdxLow, baseIdxHigh)
         d = "(%d,%d).%d^%d" % (row, col, self._strandType, strandSetIdx)
         util.execCommandList(self, [c], desc=d, useUndoStack=useUndoStack)
         return strandSetIdx
     else:
         return -1
Ejemplo n.º 13
0
 def changeInsertion(self, idx, length, useUndoStack=True):
     cmds = []
     idxLow, idxHigh = self.idxs()
     if idxLow <= idx <= idxHigh:
         if self.hasInsertionAt(idx):
             if length == 0:
                 self.removeInsertion(idx)
             else:
                 # make sure length is -1 if a skip
                 if length < 0:
                     length = -1
                 cmds.append(self.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
                 for strand in self.getComplementStrands():
                     cmds.append(strand.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
                 cmds.append(
                         Strand.ChangeInsertionCommand(self, idx, length))
                 util.execCommandList(
                                     self, cmds, desc="Change Insertion",
                                     useUndoStack=useUndoStack)
Ejemplo n.º 14
0
 def addInsertion(self, idx, length, useUndoStack=True):
     """
     Adds an insertion or skip at idx.
     length should be
         >0 for an insertion
         -1 for a skip
     """
     cmds = []
     idxLow, idxHigh = self.idxs()
     if idxLow <= idx <= idxHigh:
         if not self.hasInsertionAt(idx):
             # make sure length is -1 if a skip
             if length < 0:
                 length = -1
             cmds.append(self.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
             for strand in self.getComplementStrands():
                 cmds.append(strand.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
             cmds.append(Strand.AddInsertionCommand(self, idx, length))
             util.execCommandList(
                                 self, cmds, desc="Add Insertion",
                                 useUndoStack=useUndoStack)
Ejemplo n.º 15
0
 def addInsertion(self, idx, length, useUndoStack=True):
     """
     Adds an insertion or skip at idx.
     length should be
         >0 for an insertion
         -1 for a skip
     """
     cmds = []
     idxLow, idxHigh = self.idxs()
     if idxLow <= idx <= idxHigh:
         if not self.hasInsertionAt(idx):
             # make sure length is -1 if a skip
             if length < 0:
                 length = -1
             cmds.append(self.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
             for strand in self.getComplementStrands():
                 cmds.append(strand.oligo().applySequenceCMD(None, useUndoStack=useUndoStack))
             cmds.append(Strand.AddInsertionCommand(self, idx, length))
             util.execCommandList(
                                 self, cmds, desc="Add Insertion",
                                 useUndoStack=useUndoStack)
Ejemplo n.º 16
0
 def applySequence(self, sequence, useUndoStack=True):
     c = Oligo.ApplySequenceCommand(self, sequence)
     util.execCommandList(self, [c],
                          desc="Apply Sequence",
                          useUndoStack=useUndoStack)
Ejemplo n.º 17
0
 def remove(self, useUndoStack=True):
     c = Oligo.RemoveOligoCommand(self)
     util.execCommandList(self, [c],
                          desc="Color Oligo",
                          useUndoStack=useUndoStack)
Ejemplo n.º 18
0
 def applySequence(self, sequence, useUndoStack=True):
     c = Oligo.ApplySequenceCommand(self, sequence)
     util.execCommandList(self, [c], desc="Apply Sequence", useUndoStack=useUndoStack)
Ejemplo n.º 19
0
 def applyColor(self, color, useUndoStack=True):
     if color == self._color:
         return  # oligo already has color
     c = Oligo.ApplyColorCommand(self, color)
     util.execCommandList(self, [c], desc="Color Oligo", useUndoStack=useUndoStack)
Ejemplo n.º 20
0
 def _addPart(self, part, useUndoStack=True):
     """Add part to the document via AddPartCommand."""
     c = self.AddPartCommand(self, part)
     util.execCommandList(
                     self, [c], desc="Add part", useUndoStack=useUndoStack)
     return c.part()
Ejemplo n.º 21
0
 def remove(self, useUndoStack=True):
     c = Oligo.RemoveOligoCommand(self)
     util.execCommandList(self, [c], desc="Color Oligo", useUndoStack=useUndoStack)