示例#1
0
def test():

    el = fasta.load_single(thisdir + 'el.txt')
    br = fasta.load_single(thisdir + 'br.txt')
    re = fasta.load_single(thisdir + 're.txt')

    print 'testing comparison:'
    print 'GC\tloop count'

    for i in range(0, 100):
        if i % 10 == 0:
            print gc.collect(), '\t', i
        cmp = paircomp.do_rolling_nxn_compare(el, br, 20, .5)

    ### test transitivity, too.

    ab = paircomp.do_rolling_nxn_compare(el, br, 20, .7)
    bc = paircomp.do_rolling_nxn_compare(br, re, 20, .7)
    ac = paircomp.do_rolling_nxn_compare(el, re, 20, .7)

    print 'testing transitivity:'
    print 'GC\tloop count'
    for i in range(0, 100):
        if i % 10 == 0:
            print gc.collect(), '\t', i
        (new_ab, new_bc, new_ac) = paircomp.filter_transitively(ab, bc, ac)

    del new_ab, new_bc, new_ac
    del ab, bc, ac

    print 'remaining objects to collect:'
    print gc.collect()
示例#2
0
def is_transitive(A, B, C, windowsize=20, threshold=.5):
    ab = paircomp.do_simple_nxn_compare(A, B, windowsize, threshold)
    bc = paircomp.do_simple_nxn_compare(B, C, windowsize, threshold)
    ac = paircomp.do_simple_nxn_compare(A, C, windowsize, threshold)

    ac_tran1 = paircomp.build_transitive(ab, bc, A, C, threshold)
    ac_tran2 = paircomp.filter_transitively(ab, bc, ac)[2]

    assert ac_tran1 == ac_tran2
示例#3
0
def test():
    t1 = fasta.load_single(thisdir + 't1.fa', force='DNA')
    t2 = fasta.load_single(thisdir + 't2.fa', force='DNA')
    t3 = fasta.load_single(thisdir + 't3.fa', force='DNA')

    AB = paircomp.do_simple_nxn_compare(t1, t2, 4, 1.0)
    BC = paircomp.do_simple_nxn_compare(t2, t3, 4, 1.0)
    AC = paircomp.do_simple_nxn_compare(t1, t3, 4, 1.0)

    (new_AB, new_BC, new_AC) = paircomp.filter_transitively(AB, BC, AC)

    #print_cmp(new_AB)
    #print_cmp(new_BC)
    #print_cmp(new_AC)

    expected = \
    """
    4:0,0,20
    4:0,0,-5
    4:0,29,20
    4:0,29,-5
    4:0,-16,-5
    4:0,-16,20
    4:33,6,33
    4:33,6,-33
    4:33,43,33
    4:33,43,-33
    4:33,-43,-33
    4:33,-43,33
    4:33,-6,-33
    4:33,-6,33\
    """

    print 'Comparing paircomp output to Mussa\'s...',

    l = print_tristan_3way(new_AB, new_BC, new_AC)
    l.sort()

    l2 = parse_tristan_3way(expected)
    l2.sort()

    assert l == l2
    print 'success'

    if l != l2:
        print 'DIFF: CTB'

        for x in l:
            if not x in l2:
                print x

        print 'vs TDB'

        for x in l2:
            if not x in l:
                print x
示例#4
0
        results = paircomp.build_transitive(ab, bc, br, re, threshold)
    except Exception, e:
        pass
    assert results is None

    try:
        results = paircomp.build_transitive(ab2, bc, el, re, threshold)
    except:
        pass
    assert results is None

    try:
        results = paircomp.build_transitive(ab, bc2, el, re, threshold)
    except:
        pass
    assert results is None

    try:
        results = paircomp.filter_transitively(ab2, bc, ac)
    except:
        pass
    assert results is None

    try:
        results = paircomp.filter_transitively(ab, bc2, ac)
    except:
        pass
    assert results is None

    print 'SUCCESS.'