Ejemplo n.º 1
0
def guess_alleles(fastq_records, library, redis_db, max_hamming_dist = 2):
	n_unmatched = 0
	i = 0
	for read in fastq_records:
		rev_comp = read.get_barcode_rev_comp() 
		got = redis_db.get(dict_prefix + rev_comp)
		#if read not in read_to_allele:
		if got is None:
			allele, hamming_dist = hamming.calc_min_hamming(rev_comp, library, max_hamming_dist)
			# TODO: don't try hamming correction if it's another group's
			if allele is None:
				n_unmatched += 1
			else:
				redis_db.set(dict_prefix + rev_comp, allele)
				#read_to_allele[rev_comp] = allele
			#try:
			#	read_to_allele[rev_comp] = library[rev_comp]
			#except KeyError:
			#	n_unmatched += 1
		i += 1
		if i % 100000 == 0:
			print("Ran " + str(i))
	print("There were %i unmatched reads." % n_unmatched)
Ejemplo n.º 2
0
def guess_alleles(fastq_records, library, redis_db, max_hamming_dist=2):
    n_unmatched = 0
    i = 0
    for read in fastq_records:
        rev_comp = read.get_barcode_rev_comp()
        got = redis_db.get(dict_prefix + rev_comp)
        #if read not in read_to_allele:
        if got is None:
            allele, hamming_dist = hamming.calc_min_hamming(
                rev_comp, library, max_hamming_dist)
            # TODO: don't try hamming correction if it's another group's
            if allele is None:
                n_unmatched += 1
            else:
                redis_db.set(dict_prefix + rev_comp, allele)
                #read_to_allele[rev_comp] = allele
            #try:
            #	read_to_allele[rev_comp] = library[rev_comp]
            #except KeyError:
            #	n_unmatched += 1
        i += 1
        if i % 100000 == 0:
            print("Ran " + str(i))
    print("There were %i unmatched reads." % n_unmatched)
Ejemplo n.º 3
0
import hamming
import pickle

with open('../../allele_dic_with_WT.pkl', 'rb') as f:
    library = pickle.load(f)

test_strings = [chr(x) * 18 for x in range(ord('A'), ord('Z'))]

for s in range(1, 4000):
    found, dist = hamming.calc_min_hamming('A' * 18, library)
Ejemplo n.º 4
0
import hamming
import pickle

with open('../../allele_dic_with_WT.pkl', 'rb') as f:
	library = pickle.load(f)

test_strings = [chr(x) * 18 for x in range(ord('A'), ord('Z'))]

for s in range(1, 4000):
	found, dist = hamming.calc_min_hamming('A' * 18, library)
Ejemplo n.º 5
0
import hamming

library = ['AABB', 'EEFF', 'ZYZY']

found, dist = hamming.calc_min_hamming('AAAA', library)
assert found == 'AABB'
assert dist == 2

found, dist = hamming.calc_min_hamming('QQQY', library)
assert found == None
assert dist == 4

found, dist = hamming.calc_min_hamming('EEFF', library)
assert found == 'EEFF'
assert dist == 0

found, dist = hamming.calc_min_hamming('AABC', library)
assert found == 'AABB'
assert dist == 1