Example #1
0
def nxPerformBreaks(oligo, breakItems, tokenList, startingToken,
                    minStapleLegLen):
    """ fullBreakptSoln is in the format of an IBS (see breakStrands).
    This function performs the breaks proposed by the solution. """
    part = oligo.part()
    if breakItems:
        util.beginSuperMacro(part, desc="Auto-Break")

        # temp = []
        # for s in oligo.strand5p().generator3pStrand():
        #     temp.append(s.length())
        # print "the segments", sum(temp), temp

        # print "the sum is ", sum(breakList[1]), "==", oligo.length(), "isLoop", oligo.isLoop()
        # print "the breakItems", breakItems

        strand = oligo.strand5p()
        if oligo.isLoop():
            # start things off make first cut
            length0 = sum(tokenList[0:startingToken + 1])
            strand, idx, is5to3 = getStrandAtLengthInOligo(
                strand, length0 - minStapleLegLen)
            sS = strand.strandSet()
            found, sSIdx = sS.getStrandIndex(strand)
            # found, overlap, sSIdx = sS._findIndexOfRangeFor(strand)
            strand.split(idx, updateSequence=False)
            strand = sS._strandList[sSIdx +
                                    1] if is5to3 else sS._strandList[sSIdx]

        # now iterate through all the breaks
        for b in breakItems[0:-1]:
            if strand.oligo().length() > b:
                strand, idx, is5to3 = getStrandAtLengthInOligo(strand, b)
                sS = strand.strandSet()
                found, sSIdx = sS.getStrandIndex(strand)
                # found, overlap, sSIdx = sS._findIndexOfRangeFor(strand)
                strand.split(idx, updateSequence=False)
                strand = sS._strandList[sSIdx +
                                        1] if is5to3 else sS._strandList[sSIdx]
            else:
                raise Exception(
                    "Oligo length %d is shorter than break length %d" %
                    (strand.oligo().length(), b))
        util.endSuperMacro(part)
Example #2
0
def performBreaks(part, fullBreakptSoln):
    """ fullBreakptSoln is in the format of an IBS (see breakStrands).
    This function performs the breaks proposed by the solution. """
    util.beginSuperMacro(part, desc="Auto-Break")
    breakList, oligo = [], None  # Only for logging purposes
    if fullBreakptSoln != None:  # Skip the first breakpoint
        fullBreakptSoln = fullBreakptSoln[1]
    while fullBreakptSoln != None:
        curNode = fullBreakptSoln[2]
        fullBreakptSoln = fullBreakptSoln[1]  # Walk up the linked list
        if fullBreakptSoln == None:  # Skip last breakpoint
            break
        pos, strand, idx, isTerminal = curNode
        if strand.isDrawn5to3():
            idx -= 1  # Our indices correspond to the left side of the base
        strand.split(idx, updateSequence=False)
        breakList.append(curNode)  # Logging purposes only
    # print 'Breaks for %s at: %s'%(oligo, ' '.join(str(p) for p in breakList))
    util.endSuperMacro(part)
Example #3
0
def performBreaks(part, fullBreakptSoln):
    """ fullBreakptSoln is in the format of an IBS (see breakStrands).
    This function performs the breaks proposed by the solution. """
    util.beginSuperMacro(part, desc="Auto-Break")
    breakList, oligo = [], None  # Only for logging purposes
    if fullBreakptSoln != None:  # Skip the first breakpoint
        fullBreakptSoln = fullBreakptSoln[1]
    while fullBreakptSoln != None:
        curNode = fullBreakptSoln[2]
        fullBreakptSoln = fullBreakptSoln[1]  # Walk up the linked list
        if fullBreakptSoln == None:  # Skip last breakpoint
            break
        pos, strand, idx, isTerminal = curNode
        if strand.isDrawn5to3():
            idx -= 1 # Our indices correspond to the left side of the base
        strand.split(idx, updateSequence=False)
        breakList.append(curNode)  # Logging purposes only
    # print 'Breaks for %s at: %s'%(oligo, ' '.join(str(p) for p in breakList))
    util.endSuperMacro(part)
Example #4
0
    def mouseReleaseEvent(self, event):
        """docstring for mouseReleaseEvent"""
        part = self.part()
        uS = part.undoStack()
        strands = []
        # Look at the undo stack in reverse order
        for i in range(uS.index()-1, 0, -1):
            # Check for contiguous strand additions
            m = _strand_re.match(uS.text(i))
            if m:
                strands.insert(0, map(int, m.groups()))
            else:
                break

        if len(strands) > 1:
            autoScafType = app().prefs.getAutoScafType()
            util.beginSuperMacro(part, "Auto-connect")
            if autoScafType == "Mid-seam":
                self.autoScafMidSeam(strands)
            elif autoScafType == "Raster":
                self.autoScafRaster(strands)
            util.endSuperMacro(part)
Example #5
0
def nxPerformBreaks(oligo, breakItems, tokenList, startingToken, minStapleLegLen):
    """ fullBreakptSoln is in the format of an IBS (see breakStrands).
    This function performs the breaks proposed by the solution. """
    part = oligo.part()
    if breakItems:
        util.beginSuperMacro(part, desc="Auto-Break")

        # temp = []
        # for s in oligo.strand5p().generator3pStrand():
        #     temp.append(s.length())
        # print "the segments", sum(temp), temp

        # print "the sum is ", sum(breakList[1]), "==", oligo.length(), "isLoop", oligo.isLoop()
        # print "the breakItems", breakItems

        strand = oligo.strand5p()
        if oligo.isLoop():
            # start things off make first cut
            length0 = sum(tokenList[0:startingToken+1])
            strand, idx, is5to3 = getStrandAtLengthInOligo(strand, length0-minStapleLegLen)
            sS = strand.strandSet()
            found, sSIdx = sS.getStrandIndex(strand)
            # found, overlap, sSIdx = sS._findIndexOfRangeFor(strand)
            strand.split(idx, updateSequence=False)
            strand = sS._strandList[sSIdx+1] if is5to3 else sS._strandList[sSIdx]

        # now iterate through all the breaks
        for b in breakItems[0:-1]:
            if strand.oligo().length() > b:
                strand, idx, is5to3 = getStrandAtLengthInOligo(strand, b)
                sS = strand.strandSet()
                found, sSIdx = sS.getStrandIndex(strand)
                # found, overlap, sSIdx = sS._findIndexOfRangeFor(strand)
                strand.split(idx, updateSequence=False)
                strand = sS._strandList[sSIdx+1] if is5to3 else sS._strandList[sSIdx]
            else:
                raise Exception("Oligo length %d is shorter than break length %d" % (strand.oligo().length(), b))
        util.endSuperMacro(part)