def ECUnitTest(Nin,G, Lin, foldername = "", bridgingDepth = 20, msaWidth = 20 ):
    
    dummyParameters = logging.parameterObj()
    dummyParameters.bridgingDepth = bridgingDepth
    dummyParameters.msaWidth = msaWidth
    dummyParameters.N, dummyParameters.G, dummyParameters.L, dummyParameters.p  = Nin, G,Lin, 0.015
    dummyParameters.indel = True
    dummyParameters.defaultFolder = foldername
    dummyParameters.threshold = 5
    dummyParameters.liid = 48
    
    snpRate, typeOfGen, detail = 0.001 ,'m', "500-200-50" 
    G,N,L =  dummyParameters.G, dummyParameters.N, dummyParameters.L,
    motherGen, reads, noisyReads = logging.rawDataLoad(foldername+"UnitTest",G,N,L, "dn")  
  
    f2= logging.fmapfusedLoad(foldername+'clusteredGroup2.csv') 
    G2 = logging.loadGraph(foldername+'basicMapping.csv', foldername+'seqMapping.txt', 'simple')
    checkCondensingBasic(G2, [G2[0]], "simple")

    G3 = bridgeResolve.resolveRepeats(f2,G2,dummyParameters)
    
    checkCondensingBasic(G3, [G3[0]], "MB")

    G4 = alignmentBridge.MSAresolve(f2, G3, noisyReads, snpRate,dummyParameters)
    #G4 = G3

    #checkCondensingBasic(G4, [G4[0]], "MB")
    
    recovSeq = eulerCycle.findEC(G4)
    
    recovGen = readAns.reportRecovSeq(recovSeq, f2, noisyReads,dummyParameters)
    
    numMistakes, success = compare.subAlignCompare(recovGen, motherGen,dummyParameters)

    return numMistakes, success
def resolveRepeatsUnitTest(foldername= ""):    
    var = raw_input("Enter something: ")
    print "you entered ", var
    f2= logging.fmapfusedLoad(foldername+'clusteredGroup2.csv') 

    G2 = logging.loadGraph(foldername+'basicMapping.csv', foldername+'seqMapping.txt', 'simple')
    
    checkCondensingBasic(G2, [G2[0]], "simple")
    dummyParameters = logging.parameterObj()
    dummyParameters.bridgingDepth = 10
    
    G3 = bridgeResolve.resolveRepeats(f2,G2,dummyParameters)
    
    
    checkCondensingBasic(G3, [G3[0]], "MB")
Exemple #3
0
def resolveRepeatsUnitTest(foldername=""):
    var = raw_input("Enter something: ")
    print "you entered ", var
    f2 = logging.fmapfusedLoad(foldername + 'clusteredGroup2.csv')

    G2 = logging.loadGraph(foldername + 'basicMapping.csv',
                           foldername + 'seqMapping.txt', 'simple')

    checkCondensingBasic(G2, [G2[0]], "simple")
    dummyParameters = logging.parameterObj()
    dummyParameters.bridgingDepth = 10

    G3 = bridgeResolve.resolveRepeats(f2, G2, dummyParameters)

    checkCondensingBasic(G3, [G3[0]], "MB")
def MSAResolverEpeatUnitTest(Nin, Lin, foldername = ""):

    f2= logging.fmapfusedLoad('clusteredGroup2.csv') 
    G2 = logging.loadGraph(foldername+'basicMapping.csv', foldername+'seqMapping.txt', 'simple')
    #checkCondensingBasic(G2, [G2[0]], "simple")
    dummyParameters = logging.parameterObj()
    dummyParameters.bridgingDepth = 5
    dummyParameters.msaWidth = 20 
    
    G3 = bridgeResolve.resolveRepeats(f2,G2,dummyParameters)
    
    
    #checkCondensingBasic(G3, [G3[0]], "MB")

    N, G, L, p,snpRate, typeOfGen, detail = Nin,  10000,Lin, 0.015, 0.001 ,'m', "500-300-50" 
    motherGen, reads, noisyReads = logging.rawDataLoad(foldername+"UnitTest",G,N,L,"dn")

    alignmentBridge.MSAresolve(f2, G3, noisyReads, snpRate,dummyParameters)
Exemple #5
0
def MSAResolverEpeatUnitTest(Nin, Lin, foldername=""):

    f2 = logging.fmapfusedLoad('clusteredGroup2.csv')
    G2 = logging.loadGraph(foldername + 'basicMapping.csv',
                           foldername + 'seqMapping.txt', 'simple')
    #checkCondensingBasic(G2, [G2[0]], "simple")
    dummyParameters = logging.parameterObj()
    dummyParameters.bridgingDepth = 5
    dummyParameters.msaWidth = 20

    G3 = bridgeResolve.resolveRepeats(f2, G2, dummyParameters)

    #checkCondensingBasic(G3, [G3[0]], "MB")

    N, G, L, p, snpRate, typeOfGen, detail = Nin, 10000, Lin, 0.015, 0.001, 'm', "500-300-50"
    motherGen, reads, noisyReads = logging.rawDataLoad(foldername + "UnitTest",
                                                       G, N, L, "dn")

    alignmentBridge.MSAresolve(f2, G3, noisyReads, snpRate, dummyParameters)
Exemple #6
0
def ECUnitTest(Nin, G, Lin, foldername="", bridgingDepth=20, msaWidth=20):

    dummyParameters = logging.parameterObj()
    dummyParameters.bridgingDepth = bridgingDepth
    dummyParameters.msaWidth = msaWidth
    dummyParameters.N, dummyParameters.G, dummyParameters.L, dummyParameters.p = Nin, G, Lin, 0.015
    dummyParameters.indel = True
    dummyParameters.defaultFolder = foldername
    dummyParameters.threshold = 5
    dummyParameters.liid = 48

    snpRate, typeOfGen, detail = 0.001, 'm', "500-200-50"
    G, N, L = dummyParameters.G, dummyParameters.N, dummyParameters.L,
    motherGen, reads, noisyReads = logging.rawDataLoad(foldername + "UnitTest",
                                                       G, N, L, "dn")

    f2 = logging.fmapfusedLoad(foldername + 'clusteredGroup2.csv')
    G2 = logging.loadGraph(foldername + 'basicMapping.csv',
                           foldername + 'seqMapping.txt', 'simple')
    checkCondensingBasic(G2, [G2[0]], "simple")

    G3 = bridgeResolve.resolveRepeats(f2, G2, dummyParameters)

    checkCondensingBasic(G3, [G3[0]], "MB")

    G4 = alignmentBridge.MSAresolve(f2, G3, noisyReads, snpRate,
                                    dummyParameters)
    #G4 = G3

    #checkCondensingBasic(G4, [G4[0]], "MB")

    recovSeq = eulerCycle.findEC(G4)

    recovGen = readAns.reportRecovSeq(recovSeq, f2, noisyReads,
                                      dummyParameters)

    numMistakes, success = compare.subAlignCompare(recovGen, motherGen,
                                                   dummyParameters)

    return numMistakes, success
def interactiveNodeRemoval(foldername, modeOfOpt = "skip"):
     
    '''
    delnode 1002
    deledge 1004, 1028
    addedge 1023 , 3434
    '''
    
    G2 = []
    if modeOfOpt == "skip":
        varList = ["start none", ""]
    elif modeOfOpt == "desiredOpt":
        varList = ["start none", "delnode 734288", "delnode 1716432", "fusenode 1438104", "fusenode 1166060" , "view", ""] 
    
    var = varList.pop(0)
    
    while len(var) > 0 :
        
        command = var.split()
        if command[0] == "start":   
            print "Start"
            G2 = logging.loadGraph(foldername+'basicMapping.csv', foldername+'seqMapping.txt', 'simple')
                
        elif command[0] == "delnode":
            print "To delete node"
            currentNodeIndex = int(command[1])
            print "currentNodeIndex", currentNodeIndex
            for eachnode in G2: 
                if eachnode.nodeIndex == currentNodeIndex:
                    currentNode = eachnode
                    
            for eachitem in currentNode.listOfPrevNodes:
                eachitem.listOfNextNodes.remove(currentNode)
            currentNode.listOfPrevNodes = []
            
            for eachitem in currentNode.listOfNextNodes:
                eachitem.listOfPrevNodes.remove(currentNode)
            currentNode.listOfNextNodes = []
            
            currentNode.nodeIndexList = [] 
            graphForm.condenseGraph(G2)    
                          
        elif command[0] == "deledge":
            node1 = int(command[1])
            node2 = int(command[2])
            startNode, endNode = [] , []
            for eachnode in G2: 
                if eachnode.nodeIndex == node1:
                    startNode = eachnode
                     
                if eachnode.nodeIndex == node2:
                    endNode = eachnode
                    
            startNode.listOfNextNodes.remove(endNode)
            endNode.listOfPrevNodes.remove(startNode)
                    
            print "To insert nodes"
        elif command[0] == "addedge" : 
            node1 = int(command[1])
            node2 = int(command[2])
            startNode, endNode = [] , []
            for eachnode in G2: 
                if eachnode.nodeIndex == node1:
                    startNode = eachnode
                if eachnode.nodeIndex == node2:
                    endNode = eachnode
            
            startNode.listOfNextNodes.append(endNode)
            endNode.listOfPrevNodes.append(startNode)
        elif command[0] == "fusenode":
            myNodeIndex = int(command[1])
            for eachnode in G2:
                if eachnode.nodeIndex == myNodeIndex:
                    currentNode = eachnode
            if len(currentNode.listOfPrevNodes) == 1:
                prevNode = currentNode.listOfPrevNodes[0]
                for eachnextnode in currentNode.listOfNextNodes:
                    eachnextnode.listOfPrevNodes.remove(currentNode)
                    eachnextnode.listOfPrevNodes.append(prevNode)
                    prevNode.listOfNextNodes.append(eachnextnode)
                
                prevNode.listOfNextNodes.remove(currentNode)
                currentNode.listOfNextNodes = [] 
                currentNode.listOfPrevNodes =[]
                currentNode.nodeIndexList = [] 
            
            elif len(currentNode.listOfNextNodes) ==1 :
                nextNode = currentNode.listOfNextNodes[0]
                for eachprevnode in currentNode.listOfPrevNodes:
                    eachprevnode.listOfNextNodes.remove(currentNode)
                    eachprevnode.listOfNextNodes.append(nextNode)
                    nextNode.listOfPrevNodes.append(eachprevnode)
                
                nextNode.listOfPrevNodes.remove(currentNode)
                currentNode.listOfNextNodes = []
                currentNode.listOfPrevNodes = []
                currentNode.nodeIndexList = [] 
            
        elif command[0] == "view":
            G2 = graphForm.newCondensingStep(G2)
            G2 = G2[0]
            checkCondensingBasic(G2, [G2[0]], "simple")
        #var = raw_input("Enter Operations: ")
        var = varList.pop(0)
    
        

    dummyParameters = logging.parameterObj()
    dummyParameters.bridgingDepth = 20
    
    print "Loading fmap and graph "
    f2= logging.fmapfusedLoad(foldername+'clusteredGroup2.csv') 
    
    G3 = bridgeResolve.resolveRepeats(f2,G2,dummyParameters)
    assert(1==2)
    
    G3 = G2
    print "Done Loading the fmap and graph"
    
    #checkCondensingBasic(G3, [G3[0]], "MB")
    
    return  G3,f2
Exemple #8
0
def interactiveNodeRemoval(foldername, modeOfOpt="skip"):
    '''
    delnode 1002
    deledge 1004, 1028
    addedge 1023 , 3434
    '''

    G2 = []
    if modeOfOpt == "skip":
        varList = ["start none", ""]
    elif modeOfOpt == "desiredOpt":
        varList = [
            "start none", "delnode 734288", "delnode 1716432",
            "fusenode 1438104", "fusenode 1166060", "view", ""
        ]

    var = varList.pop(0)

    while len(var) > 0:

        command = var.split()
        if command[0] == "start":
            print "Start"
            G2 = logging.loadGraph(foldername + 'basicMapping.csv',
                                   foldername + 'seqMapping.txt', 'simple')

        elif command[0] == "delnode":
            print "To delete node"
            currentNodeIndex = int(command[1])
            print "currentNodeIndex", currentNodeIndex
            for eachnode in G2:
                if eachnode.nodeIndex == currentNodeIndex:
                    currentNode = eachnode

            for eachitem in currentNode.listOfPrevNodes:
                eachitem.listOfNextNodes.remove(currentNode)
            currentNode.listOfPrevNodes = []

            for eachitem in currentNode.listOfNextNodes:
                eachitem.listOfPrevNodes.remove(currentNode)
            currentNode.listOfNextNodes = []

            currentNode.nodeIndexList = []
            graphForm.condenseGraph(G2)

        elif command[0] == "deledge":
            node1 = int(command[1])
            node2 = int(command[2])
            startNode, endNode = [], []
            for eachnode in G2:
                if eachnode.nodeIndex == node1:
                    startNode = eachnode

                if eachnode.nodeIndex == node2:
                    endNode = eachnode

            startNode.listOfNextNodes.remove(endNode)
            endNode.listOfPrevNodes.remove(startNode)

            print "To insert nodes"
        elif command[0] == "addedge":
            node1 = int(command[1])
            node2 = int(command[2])
            startNode, endNode = [], []
            for eachnode in G2:
                if eachnode.nodeIndex == node1:
                    startNode = eachnode
                if eachnode.nodeIndex == node2:
                    endNode = eachnode

            startNode.listOfNextNodes.append(endNode)
            endNode.listOfPrevNodes.append(startNode)
        elif command[0] == "fusenode":
            myNodeIndex = int(command[1])
            for eachnode in G2:
                if eachnode.nodeIndex == myNodeIndex:
                    currentNode = eachnode
            if len(currentNode.listOfPrevNodes) == 1:
                prevNode = currentNode.listOfPrevNodes[0]
                for eachnextnode in currentNode.listOfNextNodes:
                    eachnextnode.listOfPrevNodes.remove(currentNode)
                    eachnextnode.listOfPrevNodes.append(prevNode)
                    prevNode.listOfNextNodes.append(eachnextnode)

                prevNode.listOfNextNodes.remove(currentNode)
                currentNode.listOfNextNodes = []
                currentNode.listOfPrevNodes = []
                currentNode.nodeIndexList = []

            elif len(currentNode.listOfNextNodes) == 1:
                nextNode = currentNode.listOfNextNodes[0]
                for eachprevnode in currentNode.listOfPrevNodes:
                    eachprevnode.listOfNextNodes.remove(currentNode)
                    eachprevnode.listOfNextNodes.append(nextNode)
                    nextNode.listOfPrevNodes.append(eachprevnode)

                nextNode.listOfPrevNodes.remove(currentNode)
                currentNode.listOfNextNodes = []
                currentNode.listOfPrevNodes = []
                currentNode.nodeIndexList = []

        elif command[0] == "view":
            G2 = graphForm.newCondensingStep(G2)
            G2 = G2[0]
            checkCondensingBasic(G2, [G2[0]], "simple")
        #var = raw_input("Enter Operations: ")
        var = varList.pop(0)

    dummyParameters = logging.parameterObj()
    dummyParameters.bridgingDepth = 20

    print "Loading fmap and graph "
    f2 = logging.fmapfusedLoad(foldername + 'clusteredGroup2.csv')

    G3 = bridgeResolve.resolveRepeats(f2, G2, dummyParameters)
    assert (1 == 2)

    G3 = G2
    print "Done Loading the fmap and graph"

    #checkCondensingBasic(G3, [G3[0]], "MB")

    return G3, f2