Skip to content
Snippets Groups Projects
Commit 6fe31ba6 authored by Lecocq Simon's avatar Lecocq Simon
Browse files

create table

parent a89bcaf0
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ import random ...@@ -8,7 +8,7 @@ import random
###### PARTIE 1 ###### ###### PARTIE 1 ######
def construction_mphf(set_kmer:set[str], n:int, gamma:float=2, nb_niveaux:int=3) -> list[list[int]]: def construction_mphf(set_kmer:set[str], n:int, gamma:float=2, nb_niveaux:int=3) -> list[list[int]]:
""" """
Construit une fonction de hachage minimale parfaite (MPHF) pour un ensemble de k-mers. Construit une fonction de hachage minimale parfaite (MPHF) pour un ensemble de k-mers.
...@@ -98,36 +98,36 @@ def get_hash_mphf(mphf, kmer): ...@@ -98,36 +98,36 @@ def get_hash_mphf(mphf, kmer):
True True
""" """
h = abs(hash(kmer)) h = abs(hash(kmer))
for h-mphf,rang in mphf: for h_mphf,rang in mphf:
if h-mohf == h : if h_mphf == h :
return rang return rang
def create_hash_table(set_kmer, n): def create_hash_table(set_kmer, n):
""" """
Crée une table de hachage à partir d'un ensemble de k-mers et d'une mphf Crée une table de hachage à partir d'un ensemble de k-mers et d'une mphf
Parameters: Parameters:
set_kmer (set): Ensemble de k-mers. set_kmer (set): Ensemble de k-mers.
n (int): Taille de la table de hachage. n (int): Taille de la table de hachage.
Returns: Returns:
list: Table de hachage créée à partir des k-mers list: Table de hachage créée à partir des k-mers
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 mphf = construction_mphf(set_kmer, n)
# créer la mphf pour les kmers table = [-1 for i in range(n)]
# initialiser un tableau de taille n (une liste) for h_kmer, rang in mphf:
# écrire les kmers aux adresses du tableau données par la mphf table[rang] = h_kmer
# retourner le tableau et la mphf return table, mphf
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment