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
7b513398
Commit
7b513398
authored
2 months ago
by
Clara Moreno
Browse files
Options
Downloads
Patches
Plain Diff
avancement sur construction mpfm
parent
e83f864c
Branches
Branches containing commit
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
+63
-44
63 additions, 44 deletions
tp_2_miso_mphf.py
with
63 additions
and
44 deletions
tp_2_miso_mphf.py
+
63
−
44
View file @
7b513398
...
...
@@ -32,50 +32,69 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
>>>
len
(
mphf
)
==
n
True
"""
# Initialisation
set_kmer_courant
=
set_kmer
.
copy
()
tableaux
=
[]
collision
=
set
()
for
_
in
range
(
nb_niveaux
):
if
len
(
set_kmer_courant
)
>
0
:
l
=
len
(
set_kmer_courant
)
tableau_principal
=
[
-
1
]
*
(
gamma
*
l
)
for
kmer
in
set_kmer_courant
:
pass
# compléter
# hacher le k-mer (attention, hash() peut rendre des entiers signés, nous voulons des entiers positifs)
# récupérer l'adresse
# si le tableau principal est déjà rempli à l'adresse:
# mettre le kmer dans collision()
#sinon, écrire le hash à l'adresse dans le tableau principal
tableaux
.
append
(
tableau_principal
)
# expliquer
set_kmer_courant
=
collision
.
copy
()
# expliquer
collision
=
set
()
# expliquer
# Construction de la MPHF
mphf
=
[]
grand_tableau
=
[]
for
tableau
in
tableaux
:
grand_tableau
.
extend
(
tableau
)
# expliquer
rangs
=
[]
max_rang
=
0
i
=
0
for
kmer
in
set_kmer
:
pass
# compléter:
# hacher le kmer
# si le hash est dans le grand_tableau
# récupérer son index
# récupérer son rang (utiliser la fonction count())
# ajouter à la mphf [h, rang]
# mettre à jour max_rang
for
kmer
in
set_kmer_courant
:
#gestion des collisions: expliquer les 3 lignes du dessous
max_rang
+=
1
h
=
abs
(
hash
(
kmer
))
mphf
.
append
([
h
,
max_rang
])
return
mphf
# Initialisation
set_kmer_courant
=
set_kmer
.
copy
()
tableaux
=
[]
collision
=
set
()
for
_
in
range
(
nb_niveaux
):
if
len
(
set_kmer_courant
)
>
0
:
l
=
len
(
set_kmer_courant
)
tableau_principal
=
[
-
1
]
*
(
gamma
*
l
)
for
kmer
in
set_kmer_courant
:
hachage
=
abs
(
hash
(
kmer
))
# positif
print
(
hachage
)
adresse
=
hachage
%
len
(
tableau_principal
)
if
tableau_principal
[
adresse
]
!=
-
1
:
# Collision
collision
.
add
(
kmer
)
else
:
tableau_principal
[
adresse
]
=
hachage
# Stocker le hachage
tableaux
.
append
(
tableau_principal
)
# expliquer
set_kmer_courant
=
collision
.
copy
()
# expliquer
collision
=
set
()
# expliquer
# Construction de la MPHF
mphf
=
[]
grand_tableau
=
[]
for
tableau
in
tableaux
:
grand_tableau
.
extend
(
tableau
)
# expliquer
rangs
=
[]
max_rang
=
0
count
=
0
list_h_pos
=
[]
for
pos
in
range
(
len
(
grand_tableau
)):
h_tab
=
grand_tableau
[
pos
]
if
h_tab
!=
-
1
:
count
+=
1
list_h_pos
.
append
((
h_tab
,
count
))
col
=
[]
h
=
abs
(
hash
(
kmer
))
for
k
in
kmer
:
h
=
abs
(
hash
(
k
))
ok
=
0
for
e
in
range
(
len
(
list_h_pos
)):
if
list_h_pos
[
e
][
0
]
==
h
:
ok
+=
1
if
ok
==
0
:
col
.
append
(
h
)
# compléter
# hacher le kmer
# si le hash est dans le grand_tableau
# récupérer son index
# récupérer son rang (utiliser la fonction count())
# ajouter à la mphf [h, rang]
# mettre à jour max_rang
for
kmer
in
set_kmer_courant
:
# gestion des collisions: expliquer les 3 lignes du dessous
max_rang
+=
1
h
=
abs
(
hash
(
kmer
))
mphf
.
append
([
h
,
max_rang
])
return
mphf
def
get_hash_mphf
(
mphf
,
kmer
):
...
...
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