def rand_kmer_coords(f,nodes):
	N = {}
	while len(N) < nodes:
		rk = rand_kmer(f,nodes)
		if rk['q'].count(2) < 3:
			N[len(N)] = list(letters_to_coords(rk))
	return N
Exemple #2
0
def read_sequence(initial_read,H,Hp,W,k=None,known_path_length=2):
	forward_extension = []
	backward_extension = []
	forward_extension_bins = ()
	backward_extension_bins = ()
	initial_sequence = list(letters_to_coords(initial_read))
	if not k:
		k = len(initial_sequence)
	while True:
		extended_sequence = initial_sequence + forward_extension
		extension = longest_path(extended_sequence[-k:],H,W,True)
		if extension:
			forward_extension += extension[0]
			forward_extension_bins += extension[1]
			if forward_extension_bins[-known_path_length:] in Hp:
				forward_extension_bins += Hp[forward_extension_bins[-known_path_length:]]
				break
		else:
			break
	while True:
		extended_sequence = backward_extension + initial_sequence
		extension = longest_path(extended_sequence[:k],H,W,False)
		if extension:
			backward_extension = extension[0] + backward_extension
			backward_extension_bins = extension[1] + backward_extension_bins
			if backward_extension_bins[:known_path_length] in Hp:
				backward_extension_bins = Hp[backward_extension_bins[:known_path_length]] + backward_extension_bins
				break
		else:
			break
	return forward_extension_bins,backward_extension_bins
Exemple #3
0
def read_sequence(initial_read, H, Hp, W, k=None, known_path_length=2):
    forward_extension = []
    backward_extension = []
    forward_extension_bins = ()
    backward_extension_bins = ()
    initial_sequence = list(letters_to_coords(initial_read))
    if not k:
        k = len(initial_sequence)
    while True:
        extended_sequence = initial_sequence + forward_extension
        extension = longest_path(extended_sequence[-k:], H, W, True)
        if extension:
            forward_extension += extension[0]
            forward_extension_bins += extension[1]
            if forward_extension_bins[-known_path_length:] in Hp:
                forward_extension_bins += Hp[
                    forward_extension_bins[-known_path_length:]]
                break
        else:
            break
    while True:
        extended_sequence = backward_extension + initial_sequence
        extension = longest_path(extended_sequence[:k], H, W, False)
        if extension:
            backward_extension = extension[0] + backward_extension
            backward_extension_bins = extension[1] + backward_extension_bins
            if backward_extension_bins[:known_path_length] in Hp:
                backward_extension_bins = Hp[
                    backward_extension_bins[:known_path_length]] + backward_extension_bins
                break
        else:
            break
    return forward_extension_bins, backward_extension_bins
def rand_kmer_coords(f, nodes):
    N = {}
    while len(N) < nodes:
        rk = rand_kmer(f, nodes)
        if rk['q'].count(2) < 3:
            N[len(N)] = list(letters_to_coords(rk))
    return N
Exemple #5
0
	for a in range(len(A)):
		if H.get(B[0][a],False):
			E.append(([A[a]],(B[0][a],)))
		# POSSIBLE TO USE MULTIPLE WHEELS HERE
		#extension_bins = ()
		#for b in range(len(B)):
		#	if H.get(B[b][a],False):
		#		extension_bins += (B[b][a],)
		#	else:
		#		break
		#if len(extension_bins) == len(B):
		#	E.append(([A[a]],(extension_bins,)))
	return E

Alphabet = {'s': 'ATCG'}
Mapped_Alphabet = letters_to_coords(Alphabet)
def extend_kmer(s,forward=True):
	A = []
	C = []
	for a in Mapped_Alphabet:
		if forward:
			C.append(s[1:] + [a])
		else:
			C.append([a] + s[:-1])
		A.append(a)
	return A,C

def longest_path(s0,H,W,fb):
	k = len(s0)
	P = extend_path(s0,H,W,fb)
	while len(P) > 1:
Exemple #6
0
        if H.get(B[0][a], False):
            E.append(([A[a]], (B[0][a], )))
        # POSSIBLE TO USE MULTIPLE WHEELS HERE
        #extension_bins = ()
        #for b in range(len(B)):
        #	if H.get(B[b][a],False):
        #		extension_bins += (B[b][a],)
        #	else:
        #		break
        #if len(extension_bins) == len(B):
        #	E.append(([A[a]],(extension_bins,)))
    return E


Alphabet = {'s': 'ATCG'}
Mapped_Alphabet = letters_to_coords(Alphabet)


def extend_kmer(s, forward=True):
    A = []
    C = []
    for a in Mapped_Alphabet:
        if forward:
            C.append(s[1:] + [a])
        else:
            C.append([a] + s[:-1])
        A.append(a)
    return A, C


def longest_path(s0, H, W, fb):