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
4e27840b
Commit
4e27840b
authored
2 months ago
by
Julianne
Browse files
Options
Downloads
Patches
Plain Diff
get_hash
parent
b04d18b8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
__pycache__/tp_2_miso_mphf.cpython-311.pyc
+0
-0
0 additions, 0 deletions
__pycache__/tp_2_miso_mphf.cpython-311.pyc
tp_2_miso_mphf.py
+26
-13
26 additions, 13 deletions
tp_2_miso_mphf.py
with
26 additions
and
13 deletions
__pycache__/tp_2_miso_mphf.cpython-311.pyc
+
0
−
0
View file @
4e27840b
No preview for this file type
This diff is collapsed.
Click to expand it.
tp_2_miso_mphf.py
+
26
−
13
View file @
4e27840b
...
@@ -82,8 +82,6 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
...
@@ -82,8 +82,6 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
rangs
=
[]
rangs
=
[]
# On initialise le rang maximal par 0
# On initialise le rang maximal par 0
max_rang
=
0
max_rang
=
0
#
i
=
0
# On parcours tous les kmers dans set_kmer
# On parcours tous les kmers dans set_kmer
for
kmer
in
set_kmer
:
for
kmer
in
set_kmer
:
# hacher le kmer
# hacher le kmer
...
@@ -94,9 +92,9 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
...
@@ -94,9 +92,9 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
index
=
grand_tableau
.
index
(
h2
)
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
s
=
index
-
c
rang
=
index
-
c
# ajouter à la mphf [h, rang]
# ajouter à la mphf [h, rang]
mphf
.
append
((
h2
,
rang
s
))
mphf
.
append
((
h2
,
rang
))
# mettre à jour max_rang
# mettre à jour max_rang
max_rang
+=
1
max_rang
+=
1
...
@@ -124,16 +122,21 @@ def get_hash_mphf(mphf, kmer):
...
@@ -124,16 +122,21 @@ 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
h
=
abs
(
hash
(
kmer
))
for
h_kmer
,
rang
in
mphf
:
if
h
==
h_kmer
:
return
rang
return
-
1
def
create_hash_table
(
set_kmer
,
n
):
def
create_hash_table
(
set_kmer
,
n
):
"""
for _ in range(len(index)):
"""
for _ in range(len(index)):
c = grand_tableau.count(-1)chage.
c = grand_tableau.count(-1)chage.
...
@@ -199,4 +202,14 @@ def compare_taille(n_max, fichier_sortie):
...
@@ -199,4 +202,14 @@ def compare_taille(n_max, fichier_sortie):
#compare_taille(10000,"mphf.png")
#compare_taille(10000,"mphf.png")
import
doctest
import
doctest
doctest
.
testmod
()
doctest
.
testmod
()
\ No newline at end of file
if
__name__
==
'
__main__
'
:
set_kmer
=
{
str
(
i
)
for
i
in
range
(
10
)}
mphf
=
construction_mphf
(
set_kmer
,
10
)
print
(
mphf
)
kmer
=
'
5
'
print
(
abs
(
hash
(
kmer
)))
h
=
get_hash_mphf
(
mphf
,
kmer
)
print
(
h
)
\ 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