Skip to content
Snippets Groups Projects
Commit ec4abf5c authored by elabaron's avatar elabaron
Browse files

suffic_tree.py: change missmatch to mismatch

parent 88f4e9c0
No related branches found
No related tags found
No related merge requests found
......@@ -98,13 +98,13 @@ class Tree:
General suffixtree
"""
def __init__(self, missmatch=None):
def __init__(self, mismatch=None):
"""
Initialisation of a General suffixtree
"""
self.size = 0
self.root = Node()
self.missmatch = missmatch
self.mismatch = mismatch
def __del__(self):
self.root.__del__()
......@@ -141,7 +141,7 @@ class Tree:
qual=qual,
tree=self,
cache=cache,
missmatch=self.missmatch,
mismatch=self.mismatch,
verbose=verbose,
)
if verbose:
......@@ -160,7 +160,7 @@ class TreeCrawler:
Helper Class to search suffixtree
"""
def __init__(self, seq, qual, tree, cache=True, missmatch=None,
def __init__(self, seq, qual, tree, cache=True, mismatch=None,
verbose=False):
"""
Initialisation of a General suffixtree
......@@ -171,7 +171,7 @@ class TreeCrawler:
self.qual = qual
self.tree = tree
self.barcode = None
self.missmatch = missmatch
self.mismatch = mismatch
if verbose:
print(self.seq)
for i in range(len(self.qual)):
......@@ -183,13 +183,13 @@ class TreeCrawler:
def split_search(self, curr_node, pos, dist=0, verbose=False):
"""
Multiply the barcode search in case of missmatch
Multiply the barcode search in case of mismatch
"""
if verbose:
print((pos, self.seq[pos], curr_node.base,
list(curr_node.childs.keys()), dist, curr_node.barcode))
if len(self.seq) > pos+1:
# we search with n missmatch
# we search with n mismatch
for base in curr_node.childs.keys():
curr_dist = dist
search_result = curr_node[base].get_barcode(
......@@ -202,9 +202,9 @@ class TreeCrawler:
self.barcodes.append(search_result[0])
else:
# if no results with one missmath we search with n+1
# missmatch
if self.missmatch is not None:
self.missmatch -= 1
# mismatch
if self.mismatch is not None:
self.mismatch -= 1
curr_dist += distance(qual=self.qual, pos=pos + 1)
self.split_search(
curr_node=curr_node[base],
......@@ -243,8 +243,8 @@ class TreeCrawler:
pos=0
)
if self.barcode is None:
if self.missmatch is not None:
self.missmatch -= 1
if self.mismatch is not None:
self.mismatch -= 1
dist = distance(qual=self.qual, pos=pos) + pos
self.split_search(
curr_node=curr_node,
......@@ -256,8 +256,8 @@ class TreeCrawler:
print((self.barcodes, self.dists))
if self.barcodes:
min_dist = max(self.dists)
if self.missmatch is not None:
if self.missmatch < 0:
if self.mismatch is not None:
if self.mismatch < 0:
return None
min_dist_index = self.dists.index(min_dist)
self.barcode = self.barcodes[min_dist_index]
......@@ -272,12 +272,12 @@ class Forest:
"""
Forest of suffixtree
"""
def __init__(self, missmatch=None):
def __init__(self, mismatch=None):
"""
Initialisation of a Forest
"""
self.adaptators = dict()
self.missmatch = missmatch
self.mismatch = mismatch
def __del__(self):
for adaptator in self.adaptators:
......@@ -292,7 +292,7 @@ class Forest:
params: barcode str()
"""
if adaptator not in self.adaptators:
self.adaptators[adaptator] = Tree(missmatch=self.missmatch)
self.adaptators[adaptator] = Tree(mismatch=self.mismatch)
self.adaptators[adaptator].add_sequence(
sequence=sequence,
barcode=barcode
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment