def testBandedClustering(): dummyParameters = logging.parameterObj() #dummyParameters.defaultFolder = "" dummyParameters.liid = 40 dummyParameters.K = 40 dummyParameters.threshold = 6 dummyParameters.p = 0.015 dummyParameters.indel = True dummyParameters.N, dummyParameters.G, dummyParameters.L, dummyParameters.p, typeOfGen, detail = 600, 10000,200, 0.015, 'm', "500-200-50" startFingerPrint, endFingerPrint, read1, read2 = [] , [] , [] , [] read1= np.zeros(200, dtype= np.int64) read2 = np.zeros(200, dtype= np.int64) for i in range(200): read1[i] = random.randint(1,4) read2[i] = random.randint(1,4) for i in range(50): read2[i] = 4 read1[150+i] = 4 print read1, read2 startFingerPrint, endFingerPrint = [160,8] ,[ 190,40] score , returnalignedSeq1, returnalignedSeq2 , starti, startj , endi, endj =cluster.SWAlignmentBanded(startFingerPrint, endFingerPrint,read1 ,read2 , dummyParameters) print "score", score cluster.printSeq(returnalignedSeq1) cluster.printSeq(returnalignedSeq2) print "starti, startj, endi , endj : ", starti, startj, endi , endj score , returnalignedSeq1, returnalignedSeq2 , starti, startj , endi, endj =cluster.SWAlignment(read1, read2 , dummyParameters) print "score", score cluster.printSeq(returnalignedSeq1) cluster.printSeq(returnalignedSeq2) print "starti, startj, endi , endj : ", starti, startj, endi , endj
def testBandedClustering(): dummyParameters = logging.parameterObj() #dummyParameters.defaultFolder = "" dummyParameters.liid = 40 dummyParameters.K = 40 dummyParameters.threshold = 6 dummyParameters.p = 0.015 dummyParameters.indel = True dummyParameters.N, dummyParameters.G, dummyParameters.L, dummyParameters.p, typeOfGen, detail = 600, 10000, 200, 0.015, 'm', "500-200-50" startFingerPrint, endFingerPrint, read1, read2 = [], [], [], [] read1 = np.zeros(200, dtype=np.int64) read2 = np.zeros(200, dtype=np.int64) for i in range(200): read1[i] = random.randint(1, 4) read2[i] = random.randint(1, 4) for i in range(50): read2[i] = 4 read1[150 + i] = 4 print read1, read2 startFingerPrint, endFingerPrint = [160, 8], [190, 40] score, returnalignedSeq1, returnalignedSeq2, starti, startj, endi, endj = cluster.SWAlignmentBanded( startFingerPrint, endFingerPrint, read1, read2, dummyParameters) print "score", score cluster.printSeq(returnalignedSeq1) cluster.printSeq(returnalignedSeq2) print "starti, startj, endi , endj : ", starti, startj, endi, endj score, returnalignedSeq1, returnalignedSeq2, starti, startj, endi, endj = cluster.SWAlignment( read1, read2, dummyParameters) print "score", score cluster.printSeq(returnalignedSeq1) cluster.printSeq(returnalignedSeq2) print "starti, startj, endi , endj : ", starti, startj, endi, endj
def checkBridgingFromReads(f2, xNode,frankingdepth, noisyReads, parameterRobot): isBridged, matchingList = False, [] ### Find bridging reads bridgingReads = [] K = 150 searchdepth = 5 outList = findRangeList(xNode.nodeIndexList[K: K+searchdepth], f2 ) inList = findRangeList(xNode.nodeIndexList[frankingdepth:searchdepth + frankingdepth], f2 ) print "my name is Bond", outList print inList bridgingReads = isIntersectIndel(inList, outList, K - frankingdepth) ### Determine Extension List and isBridged or not inputReads = [8 for i in range(len(xNode.listOfPrevNodes))] outputReads = [8 for i in range(len(xNode.listOfNextNodes))] inMap = [] outMap = [] threshold, liid,overhang= parameterRobot.threshold ,parameterRobot.liid ,5 speciallen = 40 for i in range(len(inputReads)): tempList = obtainReadNum(xNode.listOfPrevNodes[i][0].nodeIndexList[-speciallen], f2) tempList = sorted(tempList, key = itemgetter(1)) inputReads[i] = tempList[0][0] print "In ",i , xNode.listOfPrevNodes[i][0].nodeIndexList[-1],inputReads[i], len(xNode.listOfPrevNodes[i][0].nodeIndexList) for i in range(len(outputReads)): tempList = obtainReadNum(xNode.listOfNextNodes[i][0].nodeIndexList[speciallen], f2) tempList = sorted(tempList,key = itemgetter(1)) outputReads[i] = tempList[-1][0] print "Out ",i , xNode.listOfNextNodes[i][0].nodeIndexList[0], outputReads[i], len(xNode.listOfNextNodes[i][0].nodeIndexList) print "hi there", len(inputReads), len(outputReads), len(bridgingReads) for prevIndex, dummyindex in zip(inputReads, range(len(inputReads))): endNoisy1= 0 # print noisyReads[0][0] # print prevIndex # print endNoisy1 while (noisyReads[prevIndex][endNoisy1] != 0): endNoisy1 += 1 for bridgeIndex in bridgingReads: endNoisy2 =0 while (noisyReads[bridgeIndex][endNoisy2] != 0): endNoisy2 += 1 score, returnalignedSeq1, returnalignedSeq2 , starti, startj , endi, endj = cluster.SWAlignment(noisyReads[prevIndex][0:endNoisy1], noisyReads[bridgeIndex][0:endNoisy2], parameterRobot) check = cluster.meetRequirement(score, returnalignedSeq1, returnalignedSeq2 ,starti, startj, endi, endj, threshold, liid,overhang, endNoisy1, endNoisy2 ) if [prevIndex, bridgeIndex] == [1318, 235]: print "strange" print " starti, startj , endi, endj", starti, startj , endi, endj cluster.printSeq(returnalignedSeq1) cluster.printSeq(returnalignedSeq2) if check : inMap.append([prevIndex, bridgeIndex, 0, dummyindex]) print "inMap", inMap for nextIndex,dummyindex in zip(outputReads,range(len(outputReads))): endNoisy1= 0 while (noisyReads[nextIndex][endNoisy1] != 0): endNoisy1 += 1 for bridgeIndex in bridgingReads: endNoisy2 =0 while (noisyReads[bridgeIndex][endNoisy2] != 0): endNoisy2 += 1 score, returnalignedSeq1, returnalignedSeq2 , starti, startj , endi, endj = cluster.SWAlignment(noisyReads[nextIndex][0:endNoisy1], noisyReads[bridgeIndex][0:endNoisy2], parameterRobot) check = cluster.meetRequirement(score, returnalignedSeq1, returnalignedSeq2 ,starti, startj, endi, endj, threshold, liid,overhang, endNoisy1, endNoisy2) if [nextIndex, bridgeIndex] == [235, 235]: print "strange 2 " print " starti, startj , endi, endj", starti, startj , endi, endj cluster.printSeq(returnalignedSeq1) cluster.printSeq(returnalignedSeq2) if check : outMap.append([nextIndex, bridgeIndex, 1, dummyindex]) print "outMap,", outMap print "matchingList", matchingList for eachinmap in inMap: for eachoutmap in outMap: if eachinmap[1] == eachoutmap[1] : dummyIn = eachinmap[3] dummyOut = eachoutmap[3] print "dummyIn, dummyOut", dummyIn, dummyOut #print "eachinmap", eachinmap #print "eachoutmap",eachoutmap edgeWt = xNode.listOfPrevNodes[dummyIn][1] inKmerIndex = xNode.listOfPrevNodes[dummyIn][0].nodeIndexList[-(edgeWt+1 )] edgeWt = xNode.listOfNextNodes[dummyOut][1] outKmerIndex = xNode.listOfNextNodes[dummyOut][0].nodeIndexList[edgeWt] matchingList.append([inKmerIndex,outKmerIndex ]) ### Check isBridged if len(matchingList) > 0 : matchingList = distinct(matchingList) reverseList = [] for eachitem in matchingList: reverseList.append([eachitem[1], eachitem[0]]) if len(distinct(matchingList, "zero")) == len(inputReads) and len(distinct(reverseList, "zero")) == len(outputReads): isBridged = True else: isBridged = False #matchingList = [[28346, 32138], [28346, 4913], [30233, 32138]] return isBridged, matchingList