Exemplo n.º 1
0
def addBackDeleted(recovSeq, f2,readSortedf2, noisyReads, parameterRobot):
    newRecovSeq = np.zeros(len(recovSeq)*2, dtype= np.int64)
    W = int(100*parameterRobot.L/2000)
    
    counter = 0 
    for eachindex in range(len(recovSeq)-1):
        KmerIndex = recovSeq[eachindex]
        currentList =bridgeResolve.obtainReadDetail(KmerIndex, f2) 
    
        KmerIndex = recovSeq[eachindex+1 ]
        nextList =bridgeResolve.obtainReadDetail(KmerIndex, f2) 
        
        countDiffMax,readListOfInterest = countDiff(currentList, nextList,W)
        
        if countDiffMax >1 :
            #print "countDiffMax", countDiffMax
            
            for dummy in range(countDiffMax):
              
                newKmerIndex = findIndex(readListOfInterest, f2,readSortedf2, dummy)
                newRecovSeq[counter+ dummy] = newKmerIndex 
            counter = counter + countDiffMax
        elif countDiffMax == 1 :
            newRecovSeq[counter] = currentList[0][0]
            counter = counter + 1 

    
    return newRecovSeq[0:counter]
Exemplo n.º 2
0
def segmentedAdd(recovSeq, f2 ,readSortedf2,  noisyReads, parameterRobot):
    try : 
        recovSeqNew = np.zeros(2*len(recovSeq), dtype = np.int64)
        thres = 2
        W = int(100*parameterRobot.L/2000)
        
        
        #print "W", W
        counter = 0 
        runningSum = 0
        
        while counter< len(recovSeq)-W:
            KmerIndex = recovSeq[counter]
            currentList =bridgeResolve.obtainReadDetail(KmerIndex, f2) 
        
            KmerIndex = recovSeq[counter+W ]
            nextList =bridgeResolve.obtainReadDetail(KmerIndex, f2) 
            
            countDiffMax, readListOfInterest = countDiff(currentList, nextList, W, 5)
            
            skip = checkSkip(currentList)
            
            if (not skip and -thres <=countDiffMax - W <= thres) or countDiffMax ==0 or len(readListOfInterest) == 0:
                recovSeqNew[runningSum] = recovSeq[counter]
                
                counter += 1
                runningSum += 1
            else:
                for dummy in range(countDiffMax):
                    newKmerIndex = findIndex(readListOfInterest, f2,readSortedf2, dummy)
                    recovSeqNew[runningSum+ dummy] = newKmerIndex 
                
                #print "counter, runningSum", counter ,runningSum
                counter = counter + W
                runningSum += countDiffMax
                
        for counter in range(len(recovSeq)-W, len(recovSeq)):
            recovSeqNew[runningSum] = recovSeq[counter] 
            runningSum += 1
    except Exception:
        print "recovSeqNew[runningSum+ dummy] = newKmerIndex ", len(recovSeqNew), runningSum, dummy,  newKmerIndex 
        
    return recovSeqNew[0:runningSum]
Exemplo n.º 3
0
def convertSeqtoBase(recovSeq, f2, noisyReads, parameterRobot):
    correctedGen = np.zeros(len(recovSeq), dtype = np.int8)  
    
    for eachindex in range(len(recovSeq)): 
        KmerIndex = recovSeq[eachindex]
        readsList =bridgeResolve.obtainReadDetail(KmerIndex, f2)
        if len(readsList) == 0:
            print len(readsList), eachindex
        readNum, offset = readsList[0][1:3] 
        correctedGen[eachindex] = noisyReads[readNum][offset]
    
    return  correctedGen
Exemplo n.º 4
0
def deleteExtra(recovSeq, f2, noisyReads, parameterRobot):
    newRecovSeq = np.zeros(len(recovSeq), dtype = np.int64)
    thresTrue = 3
    counter = 0 
    for eachindex in range(len(recovSeq)):
        KmerIndex = recovSeq[eachindex]
        readsList =bridgeResolve.obtainReadDetail(KmerIndex, f2)
        if len(readsList) >= thresTrue: 
            newRecovSeq[counter] = KmerIndex
            counter = counter + 1 
    
    return newRecovSeq[0:counter]
Exemplo n.º 5
0
def reportRecovSeqOriginal(recovSeq, f2, noisyReads, parameterRobot):
    
    thresTrust = 50 
    G = parameterRobot.G
    
    f2 = sorted(f2)
    recoveredGenome =  np.zeros(2*G,dtype = np.int8)
    correctedGen = np.zeros(G, dtype = np.int8)
    # -1 : fused, 0 : Snps

    print "len(recovSeq)", len(recovSeq)
    ### MajorityVote

    runningIndex = 0 
    for eachindex in range(len(recovSeq)):

        KmerIndex = recovSeq[eachindex]
        readsList =bridgeResolve.obtainReadDetail(KmerIndex, f2)
        if eachindex % thresTrust == 0 :
            readNum, offset = readsList[0][1:3]
            recoveredGenome[runningIndex : runningIndex+ thresTrust] = noisyReads[readNum][offset: offset + thresTrust]
            runningIndex += thresTrust
          
    correctedGen= recoveredGenome[0:runningIndex] 
    print correctedGen[-10:-1], len(correctedGen)
    countfused = 0
    countsnps = 0
    for eachitem in correctedGen:
        if eachitem == -1 :
            countfused = countfused  +1
        if eachitem == 0: 
            countsnps = countsnps +1 
    
    print "correctedGen[0:30]" ,correctedGen[0:30]  , len(correctedGen)
    print "Not corrected yet", countfused, countsnps
        
    return correctedGen[0:int(G*1.1)]