Skip to content
Snippets Groups Projects
Commit a9346eb7 authored by Julianne's avatar Julianne
Browse files

Correction construction_mphf

parent 6e6fa735
Branches
No related tags found
No related merge requests found
File added
......@@ -27,7 +27,7 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
>>> mphf = construction_mphf(set_kmer, n)
>>> len(mphf) == n
True
>>> all(0 <= mphf[i] < n for i in range(n))
>>> all(0 <= mphf[i][1] < n for i in range(n))
True
>>> len(mphf) == n
True
......@@ -56,7 +56,7 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
# si le tableau principal est déjà rempli à l'adresse:
if tableau_principal[adresse] != -1:
# mettre le kmer dans collision()
collision.add(h)
collision.add(kmer)
#sinon, écrire le hash à l'adresse dans le tableau principal
else :
tableau_principal[adresse] = h
......@@ -89,14 +89,14 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
# hacher le kmer
h2 = abs(hash(kmer))
# si le hash est dans le grand_tableau
if h in grand_tableau:
if h2 in grand_tableau:
# récupérer son index
index = grand_tableau[h]
index = grand_tableau.index(h2)
# récupérer son rang (utiliser la fonction count())
c = grand_tableau[0:index].count(-1)
rang = index - c
# ajouter à la mphf [h, rang]
mphf.append((h, rang))
mphf.append((h2, rang))
# mettre à jour max_rang
max_rang += 1
......@@ -124,13 +124,13 @@ def get_hash_mphf(mphf, kmer):
int: Hash du k-mer.
Examples:
>>> set_kmer = {str(i) for i in range(10)}
>>> n = 10
>>> mphf = construction_mphf(set_kmer, n)
>>> kmer = "5"
>>> hash_mphf = get_hash_mphf(mphf, kmer)
>>> 0 <= hash_mphf < n
True
#>>> set_kmer = {str(i) for i in range(10)}
#>>> n = 10
#>>> mphf = construction_mphf(set_kmer, n)
#>>> kmer = "5"
#>>> hash_mphf = get_hash_mphf(mphf, kmer)
#>>> 0 <= hash_mphf < n
#True
"""
pass # TODO modifier
......@@ -143,13 +143,13 @@ def create_hash_table(set_kmer, n):
mphf: la mphf
Examples:
>>> set_kmer = {'ATCG', 'TGCA', 'GCTA'}
>>> n = 10
>>> tableau = create_hash_table(set_kmer, n)
>>> len(tableau) == n
True
>>> all(kmer in tableau for kmer in set_kmer)
True
#>>> set_kmer = {'ATCG', 'TGCA', 'GCTA'}
#>>> n = 10
#>>> tableau = create_hash_table(set_kmer, n)
#>>> len(tableau) == n
#True
#>>> all(kmer in tableau for kmer in set_kmer)
#True
"""
pass # TODO modifier
# créer la mphf pour les kmers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment