Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tp2 sdd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pacome Riobe
tp2 sdd
Commits
6fc784b5
Commit
6fc784b5
authored
1 month ago
by
Pacome Riobe
Browse files
Options
Downloads
Patches
Plain Diff
Partie 1 terminée
parent
6bb763c4
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tp_2_miso_mphf.py
+31
-15
31 additions, 15 deletions
tp_2_miso_mphf.py
with
31 additions
and
15 deletions
tp_2_miso_mphf.py
+
31
−
15
View file @
6fc784b5
...
...
@@ -54,12 +54,9 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
collision
=
set
()
# on replace les positions non-hachées en tant que set pour le hachage
# Construction de la MPHF
mphf
=
[]
grand_tableau
=
[]
for
tableau
in
tableaux
:
grand_tableau
.
extend
(
tableau
)
# on ajoute tous les éléments de tous les tabeaux dans le tableau final, sans renvoyer de valeur
rangs
=
[]
max_rang
=
0
count
=
0
list_h_pos
=
[]
for
pos
in
range
(
len
(
grand_tableau
)):
...
...
@@ -121,9 +118,9 @@ def get_hash_mphf(mphf, kmer):
hashkmer
=
abs
(
hash
(
kmer
))
for
hach
in
mphf
:
if
hach
[
0
]
==
hashkmer
:
return
ha
ch
[
0
]
return
ha
shkmer
else
:
return
"
ça existe pô
"
return
"
not in the table
"
def
create_hash_table
(
set_kmer
,
n
):
...
...
@@ -147,7 +144,13 @@ def create_hash_table(set_kmer, n):
>>>
all
(
kmer
in
tableau
for
kmer
in
set_kmer
)
True
"""
pass
# TODO modifier
mphf
=
construction_mphf
(
set_kmer
,
n
)
liste
=
[
0
]
*
n
n
=
0
for
kmer
in
mphf
:
liste
[
n
]
=
kmer
[
0
]
n
+=
1
return
liste
,
mphf
# créer la mphf pour les kmers
# initialiser un tableau de taille n (une liste)
# écrire les kmers aux adresses du tableau données par la mphf
...
...
@@ -166,20 +169,28 @@ def generer_kmers(n, k):
def
compare_taille
(
n_max
,
fichier_sortie
):
n_values
=
[]
table_size
=
[]
dict_size
=
[]
k
=
21
"""
Crée un graphique de la taille de la table de hachage comparée à la taille d
'
un dictionnaire pour stocker jusqu
'
à n-max kmers
:param n_max: nombre maximum de kmers traités
:param fichier_sortie: chemin dans l
'
arborescence de fichiers pour récupérer le graphique
:return: outfile
"""
n_values
=
[]
# table pour les plots
table_size
=
[]
# table pour la mphf
dict_size
=
[]
# table pour le dictionnaire
k
=
21
# taille des kmers générés
for
n
in
range
(
100
,
n_max
,
1000
):
set_kmer
=
generer_kmers
(
n
,
k
)
tableau
,
mphf
=
create_hash_table
(
set_kmer
,
n
)
set_kmer
=
generer_kmers
(
n
,
k
)
# génération de jusqu'à n_max kmers
tableau
,
mphf
=
create_hash_table
(
set_kmer
,
n
)
# création de la table de hachage
n_values
.
append
(
n
)
n_values
.
append
(
n
)
# valeurs de l'axe des abscisse
table_size
.
append
(
sys
.
getsizeof
(
tableau
)
+
sys
.
getsizeof
(
mphf
))
# pourquoi ici on ne mesure pas juste la taille en mémoire du tableau ?
mphf
))
# pourquoi ici on ne mesure pas juste la taille en mémoire du tableau ? Car on a également besoin
# de garder en mémoire la mphf, à cause des collisions
dict_size
.
append
(
sys
.
getsizeof
(
set_kmer
))
# création du plot
plt
.
plot
(
n_values
,
table_size
,
label
=
'
Table avec MPHF
'
)
plt
.
plot
(
n_values
,
dict_size
,
label
=
'
Dict
'
)
plt
.
xlabel
(
'
n
'
)
...
...
@@ -200,4 +211,9 @@ if __name__ == "__main__":
print
(
'
mpfh
'
)
print
(
mphf
)
print
(
'
get
'
)
print
(
get_hash_mphf
(
mphf
,
"
prout
"
))
\ No newline at end of file
print
(
get_hash_mphf
(
mphf
,
"
chenille
"
))
print
(
"
hash table
"
)
n
=
len
(
mphf
)
print
(
create_hash_table
(
set_kmer
,
n
))
print
(
"
compare_taille
"
)
print
(
compare_taille
(
10000
,
"
/home/m1miso/pacome.riobe.etu/PycharmProjects/pythonProjectsdd2/sortie.png
"
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment