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): ...@@ -27,7 +27,7 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
>>> mphf = construction_mphf(set_kmer, n) >>> mphf = construction_mphf(set_kmer, n)
>>> len(mphf) == n >>> len(mphf) == n
True True
>>> all(0 <= mphf[i] < n for i in range(n)) >>> all(0 <= mphf[i][1] < n for i in range(n))
True True
>>> len(mphf) == n >>> len(mphf) == n
True True
...@@ -56,7 +56,7 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3): ...@@ -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: # si le tableau principal est déjà rempli à l'adresse:
if tableau_principal[adresse] != -1: if tableau_principal[adresse] != -1:
# mettre le kmer dans collision() # mettre le kmer dans collision()
collision.add(h) collision.add(kmer)
#sinon, écrire le hash à l'adresse dans le tableau principal #sinon, écrire le hash à l'adresse dans le tableau principal
else : else :
tableau_principal[adresse] = h tableau_principal[adresse] = h
...@@ -89,14 +89,14 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3): ...@@ -89,14 +89,14 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
# hacher le kmer # hacher le kmer
h2 = abs(hash(kmer)) h2 = abs(hash(kmer))
# si le hash est dans le grand_tableau # si le hash est dans le grand_tableau
if h in grand_tableau: if h2 in grand_tableau:
# récupérer son index # récupérer son index
index = grand_tableau[h] index = grand_tableau.index(h2)
# récupérer son rang (utiliser la fonction count()) # récupérer son rang (utiliser la fonction count())
c = grand_tableau[0:index].count(-1) c = grand_tableau[0:index].count(-1)
rang = index - c rang = index - c
# ajouter à la mphf [h, rang] # ajouter à la mphf [h, rang]
mphf.append((h, rang)) mphf.append((h2, rang))
# mettre à jour max_rang # mettre à jour max_rang
max_rang += 1 max_rang += 1
...@@ -124,13 +124,13 @@ def get_hash_mphf(mphf, kmer): ...@@ -124,13 +124,13 @@ def get_hash_mphf(mphf, kmer):
int: Hash du k-mer. int: Hash du k-mer.
Examples: Examples:
>>> set_kmer = {str(i) for i in range(10)} #>>> set_kmer = {str(i) for i in range(10)}
>>> n = 10 #>>> n = 10
>>> mphf = construction_mphf(set_kmer, n) #>>> mphf = construction_mphf(set_kmer, n)
>>> kmer = "5" #>>> kmer = "5"
>>> hash_mphf = get_hash_mphf(mphf, kmer) #>>> hash_mphf = get_hash_mphf(mphf, kmer)
>>> 0 <= hash_mphf < n #>>> 0 <= hash_mphf < n
True #True
""" """
pass # TODO modifier pass # TODO modifier
...@@ -143,13 +143,13 @@ def create_hash_table(set_kmer, n): ...@@ -143,13 +143,13 @@ def create_hash_table(set_kmer, n):
mphf: la mphf mphf: la mphf
Examples: Examples:
>>> set_kmer = {'ATCG', 'TGCA', 'GCTA'} #>>> set_kmer = {'ATCG', 'TGCA', 'GCTA'}
>>> n = 10 #>>> n = 10
>>> tableau = create_hash_table(set_kmer, n) #>>> tableau = create_hash_table(set_kmer, n)
>>> len(tableau) == n #>>> len(tableau) == n
True #True
>>> all(kmer in tableau for kmer in set_kmer) #>>> all(kmer in tableau for kmer in set_kmer)
True #True
""" """
pass # TODO modifier pass # TODO modifier
# créer la mphf pour les kmers # 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