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
a9346eb7
Commit
a9346eb7
authored
2 months ago
by
Julianne
Browse files
Options
Downloads
Patches
Plain Diff
Correction construction_mphf
parent
6e6fa735
Branches
Branches containing commit
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
+19
-19
19 additions, 19 deletions
tp_2_miso_mphf.py
with
19 additions
and
19 deletions
__pycache__/tp_2_miso_mphf.cpython-311.pyc
0 → 100644
+
0
−
0
View file @
a9346eb7
File added
This diff is collapsed.
Click to expand it.
tp_2_miso_mphf.py
+
19
−
19
View file @
a9346eb7
...
...
@@ -27,7 +27,7 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
>>>
mphf
=
construction_mphf
(
set_kmer
,
n
)
>>>
len
(
mphf
)
==
n
True
>>>
all
(
0
<=
mphf
[
i
]
<
n
for
i
in
range
(
n
))
>>>
all
(
0
<=
mphf
[
i
]
[
1
]
<
n
for
i
in
range
(
n
))
True
>>>
len
(
mphf
)
==
n
True
...
...
@@ -56,7 +56,7 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
# si le tableau principal est déjà rempli à l'adresse:
if
tableau_principal
[
adresse
]
!=
-
1
:
# mettre le kmer dans collision()
collision
.
add
(
h
)
collision
.
add
(
kmer
)
#sinon, écrire le hash à l'adresse dans le tableau principal
else
:
tableau_principal
[
adresse
]
=
h
...
...
@@ -89,14 +89,14 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
# hacher le kmer
h2
=
abs
(
hash
(
kmer
))
# si le hash est dans le grand_tableau
if
h
in
grand_tableau
:
if
h
2
in
grand_tableau
:
# récupérer son index
index
=
grand_tableau
[
h
]
index
=
grand_tableau
.
index
(
h2
)
# récupérer son rang (utiliser la fonction count())
c
=
grand_tableau
[
0
:
index
].
count
(
-
1
)
rang
=
index
-
c
# ajouter à la mphf [h, rang]
mphf
.
append
((
h
,
rang
))
mphf
.
append
((
h
2
,
rang
))
# mettre à jour max_rang
max_rang
+=
1
...
...
@@ -124,13 +124,13 @@ def get_hash_mphf(mphf, kmer):
int: Hash du k-mer.
Examples:
>>>
set_kmer
=
{
str
(
i
)
for
i
in
range
(
10
)}
>>>
n
=
10
>>>
mphf
=
construction_mphf
(
set_kmer
,
n
)
>>>
kmer
=
"
5
"
>>>
hash_mphf
=
get_hash_mphf
(
mphf
,
kmer
)
>>>
0
<=
hash_mphf
<
n
True
#
>>> set_kmer = {str(i) for i in range(10)}
#
>>> n = 10
#
>>> mphf = construction_mphf(set_kmer, n)
#
>>> kmer =
"
5
"
#
>>> hash_mphf = get_hash_mphf(mphf, kmer)
#
>>> 0 <= hash_mphf < n
#
True
"""
pass
# TODO modifier
...
...
@@ -143,13 +143,13 @@ def create_hash_table(set_kmer, n):
mphf: la mphf
Examples:
>>>
set_kmer
=
{
'
ATCG
'
,
'
TGCA
'
,
'
GCTA
'
}
>>>
n
=
10
>>>
tableau
=
create_hash_table
(
set_kmer
,
n
)
>>>
len
(
tableau
)
==
n
True
>>>
all
(
kmer
in
tableau
for
kmer
in
set_kmer
)
True
#
>>> set_kmer = {
'
ATCG
'
,
'
TGCA
'
,
'
GCTA
'
}
#
>>> n = 10
#
>>> tableau = create_hash_table(set_kmer, n)
#
>>> len(tableau) == n
#
True
#
>>> all(kmer in tableau for kmer in set_kmer)
#
True
"""
pass
# TODO modifier
# créer la mphf pour les kmers
...
...
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