Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TP2_sd
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
Julianne Cocq
TP2_sd
Commits
41decfab
Commit
41decfab
authored
2 months ago
by
Soltane Maxime
Browse files
Options
Downloads
Patches
Plain Diff
create_hash_table
parent
4e27840b
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
+19
-7
19 additions, 7 deletions
tp_2_miso_mphf.py
with
19 additions
and
7 deletions
tp_2_miso_mphf.py
+
19
−
7
View file @
41decfab
...
...
@@ -106,7 +106,10 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
h
=
abs
(
hash
(
kmer
))
# On l'ajoute à la fin du tableau final
mphf
.
append
([
h
,
max_rang
])
# On trie la mphf par rang
mphf
=
sorted
(
mphf
,
key
=
lambda
x
:
x
[
1
])
return
mphf
...
...
@@ -138,8 +141,9 @@ def get_hash_mphf(mphf, kmer):
return
-
1
def
create_hash_table
(
set_kmer
,
n
):
"""
for _ in range(len(index)):
c = grand_tableau.count(-1)chage.
"""
for _ in range(len(index)):
c = grand_tableau.count(-1)chage.
Returns:
list: Table de hachage créée à partir des k-mers
...
...
@@ -154,12 +158,18 @@ def create_hash_table(set_kmer, n):
#>>> all(kmer in tableau for kmer in set_kmer)
#True
"""
pass
# TODO modifier
# créer la mphf pour les kmers
mphf
=
construction_mphf
(
set_kmer
,
n
)
# initialiser un tableau de taille n (une liste)
# écrire les kmers aux adresses du tableau données par la mphf
tableau
=
[
None
]
*
n
# écrire les kmers aux adresses du tableau données par la mphf
for
kmer
in
set_kmer
:
h
=
abs
(
hash
(
kmer
))
rang
=
get_hash_mphf
(
mphf
,
kmer
)
tableau
[
rang
]
=
kmer
# retourner le tableau et la mphf
return
tableau
,
mphf
...
...
@@ -212,4 +222,6 @@ if __name__ == '__main__':
kmer
=
'
5
'
print
(
abs
(
hash
(
kmer
)))
h
=
get_hash_mphf
(
mphf
,
kmer
)
print
(
h
)
\ No newline at end of file
print
(
h
)
print
(
"
hello world
"
)
print
(
create_hash_table
(
set_kmer
,
10
))
\ 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