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()
def do_3way_regression(a, b, c, windowsize, threshold): """ Run the current paircomp 3-way and return it in a similar path format for comparison purposes. """ ab = paircomp.do_rolling_nxn_compare(a, b, windowsize, threshold) bc = paircomp.do_rolling_nxn_compare(b, c, windowsize, threshold) ac = paircomp.do_rolling_nxn_compare(a, c, windowsize, threshold) (ab, bc, ac) = paircomp.parser.filter_transitively(ab, bc, ac) paths = [] for i in range(0, len(a)): matches = ab[i] for m in matches: bot = m.bot if m.orientation == -1: bot = bot - windowsize + 1 apos = _PosO(i, -1) else: apos = _PosO(i, 1) matches2 = bc[bot] for m2 in matches2: bpos = _PosO(bot, m2.orientation) if m2.orientation == -1: cpos = _PosO(m2.bot - windowsize + 1, 1) else: cpos = _PosO(m2.bot, 1) paths += [ [apos, bpos, cpos] ] paths.sort() return paths
def test(): thresh = 14.0/21 A='tttttttttttttttttttttttttttttttttttttttttttttttttt' B='tttttttttttttttttttttttttttttttttttttttttttttttttt' C='tttttttttttttttttttttttttttttttttttttttttttttttttt' AB=paircomp.do_rolling_nxn_compare(A, B, 21, thresh) BC=paircomp.do_rolling_nxn_compare(B, C, 21, thresh) AC=paircomp.do_rolling_nxn_compare(A, C, 21, thresh) a=time.time() tran=paircomp.parser.filter_transitively(AB,BC,AC) b=time.time() print 'A B C are same '+str(b-a)
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)
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."
def add_sequence(self, seq): """ """ n = len(self.seqs) for i in range(0, n): cmp = paircomp.do_rolling_nxn_compare(self.seqs[i], seq, self.windowsize, self.threshold) d = self.cmps.get(i, {}) d[n] = cmp self.cmps[i] = d self.seqs.append(seq)
#! /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_rolling_nxn_compare(top, bot, windowsize, threshold) cmp.save(outfile)