def dynamicAsking(G3, f2): searchDepth = 5 var = "start none" while len(var) > 0 : command = var.split() if command[0] == "printlist": myNodeIndex = int(command[1]) myNode = [] for eachnode in G3: if eachnode.nodeIndex == myNodeIndex: myNode = eachnode print "nodeIndex, nodeIndexList : ", myNode.nodeIndex, myNode.nodeIndexList elif command[0] == "printstart": myNodeIndex = int(command[1]) frankingdepth = int(command[2]) myNode = [] for eachnode in G3: if eachnode.nodeIndex == myNodeIndex: myNode = eachnode frankinginList = myNode.nodeIndexList[frankingdepth: frankingdepth+searchDepth ] inList = bridgeResolve.findRangeList(frankinginList, f2 ) print "inList : ", inList elif command[0] == "printend": myNodeIndex = int(command[1]) frankingdepth = int(command[2]) myNode = [] for eachnode in G3: if eachnode.nodeIndex == myNodeIndex: myNode = eachnode frankingoutList = myNode.nodeIndexList[-frankingdepth- searchDepth: -frankingdepth ] outList = bridgeResolve.findRangeList(frankingoutList, f2 ) print "outList : ", outList var = raw_input("Enter Operations: ")
def dynamicAsking(G3, f2): searchDepth = 5 var = "start none" while len(var) > 0: command = var.split() if command[0] == "printlist": myNodeIndex = int(command[1]) myNode = [] for eachnode in G3: if eachnode.nodeIndex == myNodeIndex: myNode = eachnode print "nodeIndex, nodeIndexList : ", myNode.nodeIndex, myNode.nodeIndexList elif command[0] == "printstart": myNodeIndex = int(command[1]) frankingdepth = int(command[2]) myNode = [] for eachnode in G3: if eachnode.nodeIndex == myNodeIndex: myNode = eachnode frankinginList = myNode.nodeIndexList[frankingdepth:frankingdepth + searchDepth] inList = bridgeResolve.findRangeList(frankinginList, f2) print "inList : ", inList elif command[0] == "printend": myNodeIndex = int(command[1]) frankingdepth = int(command[2]) myNode = [] for eachnode in G3: if eachnode.nodeIndex == myNodeIndex: myNode = eachnode frankingoutList = myNode.nodeIndexList[-frankingdepth - searchDepth:-frankingdepth] outList = bridgeResolve.findRangeList(frankingoutList, f2) print "outList : ", outList var = raw_input("Enter Operations: ")
def formToProcessList(f2, noisyReads, currentNode, indelRobot, flankinglen): print "formToProcessList" print "NodeDetail : ", currentNode.nodeIndex, len(currentNode.nodeIndexList) , len(currentNode.listOfPrevNodes), len(currentNode.listOfNextNodes) searchDepth = 5 in1IndexList, in2IndexList, out1IndexList, out2IndexList, commonIndexList = [] ,[],[],[],[] for prevNode, i in zip( currentNode.listOfPrevNodes, range(2)): #print prevNode edgeWt = prevNode[1] KmerIndex = prevNode[0].nodeIndexList[-(edgeWt +1)] if edgeWt+1+flankinglen <= len(prevNode[0].nodeIndexList): frankingin = prevNode[0].nodeIndexList[-(edgeWt+1+flankinglen)] readList = bridgeResolve.findRangeList(prevNode[0].nodeIndexList[-(edgeWt+1+flankinglen+searchDepth):-(edgeWt+1+flankinglen)], f2 ) elif len(prevNode[0].listOfPrevNodes) > 0: edgeWt2 = prevNode[0].listOfPrevNodes[0][1] maxlen = len(prevNode[0].listOfPrevNodes[0][0].nodeIndexList) frankingin = prevNode[0].listOfPrevNodes[0][0].nodeIndexList[-min(edgeWt2 + 1 + edgeWt+flankinglen -len(prevNode[0].nodeIndexList),maxlen)] readList = bridgeResolve.findRangeList(prevNode[0].listOfPrevNodes[0][0].nodeIndexList[-min(edgeWt2 + 1 + edgeWt+flankinglen -len(prevNode[0].nodeIndexList)+ searchDepth,maxlen):-min(edgeWt2 + 1 + edgeWt+flankinglen -len(prevNode[0].nodeIndexList),maxlen)], f2 ) else: frankingin= prevNode[0].nodeIndexList[0] readList = bridgeResolve.findRangeList(prevNode[0].nodeIndexList[0:min(searchDepth, len(prevNode[0].nodeIndexList))], f2 ) #readList = bridgeResolve.obtainReadNum(frankingin, f2) if i == 0 : for eachitem in readList: in1IndexList.append(eachitem[0]) elif i == 1 : for eachitem in readList: in2IndexList.append(eachitem[0]) for nextNode, i in zip( currentNode.listOfNextNodes, range(2)): #KmerIndex = nextNode[0].nodeIndex edgeWt = nextNode[1] KmerIndex = nextNode[0].nodeIndexList[edgeWt ] if edgeWt+flankinglen < len(nextNode[0].nodeIndexList) : frankingout = nextNode[0].nodeIndexList[edgeWt+flankinglen] readList = bridgeResolve.findRangeList(nextNode[0].nodeIndexList[edgeWt+flankinglen:edgeWt+flankinglen+searchDepth], f2 ) elif len(nextNode[0].listOfNextNodes) > 0: edgeWt2 = nextNode[0].listOfNextNodes[0][1] maxlen = len(nextNode[0].listOfNextNodes[0][0].nodeIndexList) frankingout = nextNode[0].listOfNextNodes[0][0].nodeIndexList[min(edgeWt2+edgeWt+flankinglen -len(nextNode[0].nodeIndexList), maxlen-1)] readList = bridgeResolve.findRangeList(nextNode[0].listOfNextNodes[0][0].nodeIndexList[min(edgeWt2+edgeWt+flankinglen -len(nextNode[0].nodeIndexList), maxlen-1):min(edgeWt2+edgeWt+flankinglen -len(nextNode[0].nodeIndexList)+searchDepth, maxlen-1)], f2 ) else: frankingout = nextNode[0].nodeIndexList[-1] readList = bridgeResolve.findRangeList(nextNode[0].nodeIndexList[max(0, len(nextNode[0].nodeIndexList) - searchDepth):len(nextNode[0].nodeIndexList)], f2 ) #readList = bridgeResolve.obtainReadNum(frankingout, f2) if i == 0 : for eachitem in readList: out1IndexList.append(eachitem[0]) elif i == 1 : for eachitem in readList: out2IndexList.append(eachitem[0]) lrep= len(currentNode.nodeIndexList) Llong = indelRobot.Llong liid = indelRobot.liid print "lrep, Llong, liid", lrep, Llong, liid anchorPoint1 , anchorPoint2 = max ( int(lrep* 0.3 ), liid) , min ( int(lrep *0.7) , lrep - liid) print "anchorPoint1, anchorPoint2 ", anchorPoint1, anchorPoint2 readSet1 = bridgeResolve.findRangeList(currentNode.nodeIndexList[anchorPoint1:anchorPoint1+searchDepth], f2 ) print "readSet1", readSet1 readSet2 = bridgeResolve.findRangeList(currentNode.nodeIndexList[anchorPoint2: anchorPoint2 + searchDepth], f2) print "readSet2", readSet2 combinedList = bridgeResolve.distinct(readSet1,"zero") + bridgeResolve.distinct(readSet2, "zero") combinedList = sorted(combinedList) for i in range(len(combinedList) -1 ): if combinedList[i][0] == combinedList[i+1][0]: commonIndexList.append(combinedList[i][0]) commonIndexList = bridgeResolve.distinct(commonIndexList) toProcessList = [in1IndexList, in2IndexList, out1IndexList, out2IndexList, commonIndexList] for eachitem in toProcessList: print "len(eachitem)" , len(eachitem), eachitem return toProcessList
def formToProcessList(f2, noisyReads, currentNode, indelRobot, flankinglen): print "formToProcessList" print "NodeDetail : ", currentNode.nodeIndex, len( currentNode.nodeIndexList), len(currentNode.listOfPrevNodes), len( currentNode.listOfNextNodes) searchDepth = 5 in1IndexList, in2IndexList, out1IndexList, out2IndexList, commonIndexList = [] ,[],[],[],[] for prevNode, i in zip(currentNode.listOfPrevNodes, range(2)): #print prevNode edgeWt = prevNode[1] KmerIndex = prevNode[0].nodeIndexList[-(edgeWt + 1)] if edgeWt + 1 + flankinglen <= len(prevNode[0].nodeIndexList): frankingin = prevNode[0].nodeIndexList[-(edgeWt + 1 + flankinglen)] readList = bridgeResolve.findRangeList( prevNode[0].nodeIndexList[-(edgeWt + 1 + flankinglen + searchDepth):-(edgeWt + 1 + flankinglen)], f2) elif len(prevNode[0].listOfPrevNodes) > 0: edgeWt2 = prevNode[0].listOfPrevNodes[0][1] maxlen = len(prevNode[0].listOfPrevNodes[0][0].nodeIndexList) frankingin = prevNode[0].listOfPrevNodes[0][0].nodeIndexList[-min( edgeWt2 + 1 + edgeWt + flankinglen - len(prevNode[0].nodeIndexList), maxlen)] readList = bridgeResolve.findRangeList( prevNode[0].listOfPrevNodes[0][0].nodeIndexList[-min( edgeWt2 + 1 + edgeWt + flankinglen - len(prevNode[0].nodeIndexList) + searchDepth, maxlen):-min( edgeWt2 + 1 + edgeWt + flankinglen - len(prevNode[0].nodeIndexList), maxlen)], f2) else: frankingin = prevNode[0].nodeIndexList[0] readList = bridgeResolve.findRangeList( prevNode[0].nodeIndexList[ 0:min(searchDepth, len(prevNode[0].nodeIndexList))], f2) #readList = bridgeResolve.obtainReadNum(frankingin, f2) if i == 0: for eachitem in readList: in1IndexList.append(eachitem[0]) elif i == 1: for eachitem in readList: in2IndexList.append(eachitem[0]) for nextNode, i in zip(currentNode.listOfNextNodes, range(2)): #KmerIndex = nextNode[0].nodeIndex edgeWt = nextNode[1] KmerIndex = nextNode[0].nodeIndexList[edgeWt] if edgeWt + flankinglen < len(nextNode[0].nodeIndexList): frankingout = nextNode[0].nodeIndexList[edgeWt + flankinglen] readList = bridgeResolve.findRangeList( nextNode[0].nodeIndexList[edgeWt + flankinglen:edgeWt + flankinglen + searchDepth], f2) elif len(nextNode[0].listOfNextNodes) > 0: edgeWt2 = nextNode[0].listOfNextNodes[0][1] maxlen = len(nextNode[0].listOfNextNodes[0][0].nodeIndexList) frankingout = nextNode[0].listOfNextNodes[0][0].nodeIndexList[min( edgeWt2 + edgeWt + flankinglen - len(nextNode[0].nodeIndexList), maxlen - 1)] readList = bridgeResolve.findRangeList( nextNode[0].listOfNextNodes[0][0].nodeIndexList[min( edgeWt2 + edgeWt + flankinglen - len(nextNode[0].nodeIndexList), maxlen - 1):min( edgeWt2 + edgeWt + flankinglen - len(nextNode[0].nodeIndexList) + searchDepth, maxlen - 1)], f2) else: frankingout = nextNode[0].nodeIndexList[-1] readList = bridgeResolve.findRangeList( nextNode[0]. nodeIndexList[max(0, len(nextNode[0].nodeIndexList) - searchDepth):len(nextNode[0].nodeIndexList)], f2) #readList = bridgeResolve.obtainReadNum(frankingout, f2) if i == 0: for eachitem in readList: out1IndexList.append(eachitem[0]) elif i == 1: for eachitem in readList: out2IndexList.append(eachitem[0]) lrep = len(currentNode.nodeIndexList) Llong = indelRobot.Llong liid = indelRobot.liid print "lrep, Llong, liid", lrep, Llong, liid anchorPoint1, anchorPoint2 = max(int(lrep * 0.3), liid), min(int(lrep * 0.7), lrep - liid) print "anchorPoint1, anchorPoint2 ", anchorPoint1, anchorPoint2 readSet1 = bridgeResolve.findRangeList( currentNode.nodeIndexList[anchorPoint1:anchorPoint1 + searchDepth], f2) print "readSet1", readSet1 readSet2 = bridgeResolve.findRangeList( currentNode.nodeIndexList[anchorPoint2:anchorPoint2 + searchDepth], f2) print "readSet2", readSet2 combinedList = bridgeResolve.distinct( readSet1, "zero") + bridgeResolve.distinct(readSet2, "zero") combinedList = sorted(combinedList) for i in range(len(combinedList) - 1): if combinedList[i][0] == combinedList[i + 1][0]: commonIndexList.append(combinedList[i][0]) commonIndexList = bridgeResolve.distinct(commonIndexList) toProcessList = [ in1IndexList, in2IndexList, out1IndexList, out2IndexList, commonIndexList ] for eachitem in toProcessList: print "len(eachitem)", len(eachitem), eachitem return toProcessList