def get_score(c1_stranded,c2_stranded,gaplen=default_gapsize,cache={}):
    if gaplen<0.0: print(math.log(-1))
#    if cache.has_key((c1_stranded,c2_stranded,gaplen)):
#        return cache[c1_stranded,c2_stranded,gaplen]
#    if cache.has_key((c2_stranded,c1_stranded,gaplen)):
#        return cache[c2_stranded,c1_stranded,gaplen]
    o1,o2=0,0
    if c1_stranded[-2:]==".5": o1=1
    if c2_stranded[-2:]==".3": o2=1
    c1=c1_stranded[:-2]
    c2=c2_stranded[:-2]
    l1=ll[c1]
    l2=ll[c2]
    p0 = ces.p_not_a_hit(l1,l2,GenomeSize,gaplen,pn)
    if p0<0.0:
        print("wtf?  p0<0",p0,l1,l2,GenomeSize,gaplen,pn)
    thisscore=ces.llr_v0(l1,l2,o1,o2,GenomeSize,pn,links.get((c1,c2),[]),N,gaplen,p0 )
    #cache[c1_stranded,c2_stranded,gaplen]=thisscore
    return thisscore
Exemple #2
0
def get_score(c1_stranded, c2_stranded, gaplen=default_gapsize, cache={}):
    if gaplen < 0.0: print(math.log(-1))
    #    if cache.has_key((c1_stranded,c2_stranded,gaplen)):
    #        return cache[c1_stranded,c2_stranded,gaplen]
    #    if cache.has_key((c2_stranded,c1_stranded,gaplen)):
    #        return cache[c2_stranded,c1_stranded,gaplen]
    o1, o2 = 0, 0
    if c1_stranded[-2:] == ".5": o1 = 1
    if c2_stranded[-2:] == ".3": o2 = 1
    c1 = c1_stranded[:-2]
    c2 = c2_stranded[:-2]
    l1 = ll[c1]
    l2 = ll[c2]
    p0 = ces.p_not_a_hit(l1, l2, GenomeSize, gaplen, pn)
    if p0 < 0.0:
        print("wtf?  p0<0", p0, l1, l2, GenomeSize, gaplen, pn)
    thisscore = ces.llr_v0(l1, l2, o1, o2, GenomeSize, pn,
                           links.get((c1, c2), []), N, gaplen, p0)
    #cache[c1_stranded,c2_stranded,gaplen]=thisscore
    return thisscore
            f.close()

        weights = {}
        for c1 in c:
            if args.progress: print("#",c1)
            l1=ll[c1]
            for c2 in c:
                if not c1<c2: continue
                if args.joins and c2+".3" in nx.node_connected_component(og, c1+".3"): continue
                l2=ll[c2]
                if (c1,c2) not in links: continue
                for gaplen in [default_gapsize]: # [ 0, 500, 1000, 2000 , 10000, 20000, 30000, 40000, 100000, 200000, 500000 ]:
                    p0 = ces.p_not_a_hit(l1,l2,GenomeSize,gaplen,pn) 
                    s={}
                    for (o1,o2,suf1,suf2) in ((0,0,".3",".5"),(0,1,".3",".3"),(1,0,".5",".5"),(1,1,".5",".3")):
                        weights[c1+suf1,c2+suf2] = ces.llr_v0( l1,l2,o1,o2,GenomeSize,pn,links.get((c1,c2),[]),N,gaplen,p0 )
                        weights[c2+suf2,c1+suf1] = weights[c1+suf1,c2+suf2] 
                        if args.progress: print("#",c1+suf1,c2+suf2,len(links[c1,c2]),weights[c1+suf1,c2+suf2])

        link_pairs = list(weights.keys())
        link_pairs.sort(key = lambda x: weights[x], reverse=True)

        for c1,c2 in link_pairs:
            if not c1<c2: continue
            if weights[c1,c2]>12:
                if c2 in nx.node_connected_component(og, c1):  # link within one of the scaffolds.  
                    if c1 in linked and linked[c1]==c2: continue # this join pre made!
                    if (not c1 in linked) and (not c2 in linked):  # this would circularize
                        pass
                    elif ( c1 in linked) and ( c2 in linked):      # test to invert (or excize circle?)
                        if og.has_edge(c1,c2): 
Exemple #4
0
                if not c1 < c2: continue
                if args.joins and c2 + ".3" in nx.node_connected_component(
                        og, c1 + ".3"):
                    continue
                l2 = ll[c2]
                if (c1, c2) not in links: continue
                for gaplen in [
                        default_gapsize
                ]:  # [ 0, 500, 1000, 2000 , 10000, 20000, 30000, 40000, 100000, 200000, 500000 ]:
                    p0 = ces.p_not_a_hit(l1, l2, GenomeSize, gaplen, pn)
                    s = {}
                    for (o1, o2, suf1,
                         suf2) in ((0, 0, ".3", ".5"), (0, 1, ".3", ".3"),
                                   (1, 0, ".5", ".5"), (1, 1, ".5", ".3")):
                        weights[c1 + suf1, c2 + suf2] = ces.llr_v0(
                            l1, l2, o1, o2, GenomeSize, pn,
                            links.get((c1, c2), []), N, gaplen, p0)
                        weights[c2 + suf2, c1 + suf1] = weights[c1 + suf1,
                                                                c2 + suf2]
                        if args.progress:
                            print("#", c1 + suf1, c2 + suf2,
                                  len(links[c1, c2]), weights[c1 + suf1,
                                                              c2 + suf2])

        link_pairs = list(weights.keys())
        link_pairs.sort(key=lambda x: weights[x], reverse=True)

        for c1, c2 in link_pairs:
            if not c1 < c2: continue
            if weights[c1, c2] > 12:
                if c2 in nx.node_connected_component(