Exemplo n.º 1
0
def rec_align(g1, g2, seed, sims, seqsims, ec_mode, ed, m, sb, sb2, delta, alpha, seednum, outputdir, alignstop, timestop=None,  debug=False):
    
    if alignstop == -1:
        alignstop = float('inf')
    else:
        alignstop = int(alignstop)

    curralign = Alignment(seed, m, ec_mode, ed, sb, sb2,  alpha, delta, seednum, outputdir, timestop, alignstop)
    curralign.logfile = g1.name + "_" + g2.name + "_" + str(seednum) + ".log" 
    curralign.statsfile = g1.name + "_" + g2.name + "_" + str(seednum) + ".stats" 

    if debug:
        print("seed: ", seed)
        print("ec_mode: ", ec_mode)
        print("ed: ", ed)
        print("m: ", m)
        print("sb: ", sb)
        print("sb2: ", sb2)
        print("delta: ", delta)
        print("alpha: ", alpha)
        print("seednum: ", seednum)
        print("outputdir: ", outputdir)
        print("timestop: ", timestop)
        print("debug: ", debug)


    candidatePairs = set()
    if debug:
        print("aligning inital seeds*************************************************************************")
        print("graph 1:")
        for i in range(len(g1)):
            print(i,":",g1.get_neighbors(i))
        print("graph 2:")
        for i in range(len(g2)):
            print(i,":",g2.get_neighbors(i))

    for seed1, seed2 in seed:
        if debug:
            print((seed1,seed2))
        curralign.g1seedstr += str(g1.nodes[seed1]) + " " 
        curralign.g2seedstr += str(g2.nodes[seed2]) + " " 
        curralign.aligned_pairs.add((seed1, seed2))
        curralign.g1alignednodes.add(seed1)
        curralign.g2alignednodes.add(seed2)
        candidatePairs.update(get_new_neighbor_pairs(g1,g2,seed1,seed2,curralign.g1alignednodes, curralign.g2alignednodes, curralign.sb, curralign.sb2, sims, seqsims)) 

    curralign.g1seedstr += curralign.g2seedstr
    curralign.k = len(curralign.aligned_pairs)

    print('initial alignment:',curralign.aligned_pairs)

    if(debug):
        print("ec1: " + str(curralign.ec1))
        print("ec2: " + str(curralign.ec2))

    aligncombs = structs.alignCombinations()
    rec_alignhelper(g1, g2, curralign, candidatePairs, aligncombs, sims, seqsims,debug)
Exemplo n.º 2
0
def rec_align(g1,
              g2,
              seed,
              ec_mode,
              ed,
              m,
              delta,
              alpha,
              seednum,
              outputdir,
              timestop=None,
              debug=False):

    curralign = Alignment(seed, m, ec_mode, ed, alpha, delta, seednum,
                          outputdir, timestop)
    curralign.logfile = g1.name + "_" + g2.name + "_" + str(seednum) + ".log"

    candidatePairs = set()
    if debug:
        print(
            "aligning inital seeds*************************************************************************"
        )
        print("graph 1:")
        for i in range(len(g1)):
            print(i, ":", g1.get_neighbors(i))
        print("graph 2:")
        for i in range(len(g2)):
            print(i, ":", g2.get_neighbors(i))

    for seed1, seed2 in seed:
        if debug:
            print((seed1, seed2))
        curralign.g1seedstr += str(g1.nodes[seed1]) + " "
        curralign.g2seedstr += str(g2.nodes[seed2]) + " "
        curralign.aligned_pairs.add((seed1, seed2))
        curralign.g1alignednodes.add(seed1)
        curralign.g2alignednodes.add(seed2)
        candidatePairs.update(
            get_new_neighbor_pairs(g1, g2, seed1, seed2,
                                   curralign.g1alignednodes,
                                   curralign.g2alignednodes))

    curralign.g1seedstr += curralign.g2seedstr
    curralign.k = len(curralign.aligned_pairs)

    print('initial alignment:', curralign.aligned_pairs)

    if (debug):
        print("ec1: " + str(curralign.ec1))
        print("ec2: " + str(curralign.ec2))

    aligncombs = structs.alignCombinations()
    rec_alignhelper(g1, g2, curralign, candidatePairs, aligncombs, debug)