Beispiel #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()
Beispiel #2
0
    def setup(self):
        self.el_path = os.path.join(thisdir, 'el.txt')
        self.br_path = os.path.join(thisdir, 'br.txt')

        self.el = fasta.load_single(self.el_path)
        self.br = fasta.load_single(self.br_path)

        self.cmp = paircomp.do_rolling_nxn_compare(self.el, self.br, 20, .5)
Beispiel #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
def test():
    # construct a quick seqcomp
    el = fasta.load_single(thisdir + "el.txt")
    br = fasta.load_single(thisdir + "br.txt")

    a = do_rolling_nxn_compare(el, br, 50, 0.5)

    b = a.isolate_matching_bases(el, br)

    print "test-1bp-matches.py PASSED."
Beispiel #5
0
import sys

## import local Fasta-format library.
sys.path.append('../tests/')
import fasta

if len(sys.argv) != 6:
    sys.stderr.write("""Usage:

    %s top_seq bot_seq paircomp_file windowsize threshold
    
""" % (sys.argv[0],))

    sys.exit(-1)

top_seq = fasta.load_single(sys.argv[1])
bot_seq = fasta.load_single(sys.argv[2])
paircomp_file = open(sys.argv[3])
windowsize = int(sys.argv[4])
threshold = float(sys.argv[5])

print """
<Start>
 <First>
  <Sequence name="top sequence">
%s
  </Sequence>
  
  <!-- top sequence annotations can go here -->
  
 </First>
Beispiel #6
0
def test():
    el = fasta.load_single(thisdir + 'el.txt')
    br = fasta.load_single(thisdir + 'br.txt')
    re = fasta.load_single(thisdir + 're.txt')

    ### first break the algorithms.

    simple_cmp = None

    try:
        simple_cmp = paircomp.do_simple_nxn_compare("ATCCGRRRRUUUUU", br, 10, .5)
    except:
        pass
    assert simple_cmp is None

    # break on windowsizes
    try:
        simple_cmp = paircomp.do_simple_nxn_compare(el, br, -1, .5)
    except:
        pass
    assert simple_cmp is None

    try:
        simple_cmp = paircomp.do_simple_nxn_compare(el, br, 256, .5)
    except:
        pass
    assert simple_cmp is None

    try:
        # break on windowsizes in relation to sequence len
        simple_cmp = paircomp.do_simple_nxn_compare("AAAAAAAAAAAAAAAAAAA",
                                                    br, 20, .5)
    except:
        pass
    assert simple_cmp is None

    try:
        simple_cmp = paircomp.do_simple_nxn_compare(el, "AAAAAAAAAAAAAAAAAAA",
                                                    20, .5)
    except:
        pass
    assert simple_cmp is None

    # break on threshold
    try:
        simple_cmp = paircomp.do_simple_nxn_compare(el, br, 9, -.01)
    except:
        pass
    assert simple_cmp is None

    try:
        simple_cmp = paircomp.do_simple_nxn_compare(el, br, 9, 1.01)
    except:
        pass
    assert simple_cmp is None

    simple_cmp_1 = paircomp.do_simple_nxn_compare(el, br, 20, .5)

    simple_cmp_2 = paircomp.do_simple_nxn_compare(el, br, 22, .5)

    result = None
    try:
        result = simple_cmp_1.contains(simple_cmp_2)
    except:
        pass
    assert result is None

    try:
        result = simple_cmp_1.equals(simple_cmp_2)
    except:
        pass
    assert result is None

    try:
        result = simple_cmp_1.subtract(simple_cmp_2)
    except:
        pass
    assert result is None

    try:
        result = simple_cmp_1.intersect(simple_cmp_2)
    except:
        pass

    assert result is None

    ### test transitivity stuff

    windowsize = 20
    threshold = 0.7
    ab = paircomp.do_simple_nxn_compare(el, br, windowsize, threshold)
    ab2 = paircomp.do_simple_nxn_compare(el, br, windowsize+1, threshold)
    bc = paircomp.do_simple_nxn_compare(br, re, windowsize, threshold)
    bc2 = paircomp.do_simple_nxn_compare(br, re, windowsize+1, threshold)
    ac = paircomp.do_simple_nxn_compare(el, re, windowsize, threshold)

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

    try:
        results = paircomp.build_transitive(ab, bc, br, re, threshold)
    except Exception, e:
        pass
Beispiel #7
0
#! /usr/bin/env python
import sys
sys.path.append('/u/t/dev/motility/python/build/lib.linux-i686-2.3/')
import motility

sys.path.append('/u/t/dev/slippy/lib')
import fasta

if len(sys.argv) != 3:
    sys.stderr.write('Usage:\n\t%s <motif> <FASTA file to search>\n' % (sys.argv[0],))
    sys.exit(0)

motif = sys.argv[1]
filename = sys.argv[2]

sys.stderr.write('searching file %s with motif %s\n' % (filename, motif,))

seq = fasta.load_single(filename)
results = motility.find_iupac(seq, motif)

for (start, end, orientation, match) in results:
    print 'MATCH: %d --> %d, orientation %d; match is %s' % (start, end,
                                                             orientation,
                                                             match,)

sys.exit(0)
Beispiel #8
0
#! /usr/bin/env python
import sys, os, gc

import paircomp, fasta

A = "A"*21
B = "T"*21

dirname = os.path.dirname(__file__)
thisdir = os.path.normpath(dirname) + '/'
bindir = os.path.join(thisdir, '../../bin/')

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

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

def test():
    is_transitive(A, A, A)
    is_transitive(A, A, B)

    is_transitive(A, B, A)
Beispiel #9
0
#! /usr/bin/env python
import sys
import fasta
import paircomp

top = fasta.load_single(sys.argv[1])
bot = fasta.load_single(sys.argv[2])
windowsize = int(sys.argv[3])
threshold = float(sys.argv[4])
outfile = sys.argv[5]

cmp = paircomp.do_simple_nxn_compare(top, bot, windowsize, threshold)
cmp.save(outfile)