Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TP3_SD_Sania_Ayat
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
Ayat Chergui
TP3_SD_Sania_Ayat
Commits
cd05ae9c
Commit
cd05ae9c
authored
2 months ago
by
Ayât Chergui
Browse files
Options
Downloads
Patches
Plain Diff
docteste
parent
c46bf5bb
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
querykmers_tpmiso.py
+32
-2
32 additions, 2 deletions
querykmers_tpmiso.py
with
32 additions
and
2 deletions
querykmers_tpmiso.py
+
32
−
2
View file @
cd05ae9c
...
...
@@ -6,18 +6,37 @@ class SimpleBloomFilter:
self
.
num_hashes
=
num_hashes
self
.
bit_array
=
[
0
]
*
size
def
_hashes
(
self
,
item
):
def
_hashes
(
self
,
item
):
"""
Donnes des valeurs de hachage pour un élément donnée
>>>
bf
=
SimpleBloomFilter
(
10
,
2
)
>>>
len
(
bf
.
_hasches
(
"
test
"
))
==
2
True
"""
hash_values
=
[]
for
i
in
range
(
self
.
num_hashes
):
hash_func
=
hashlib
.
sha256
((
str
(
i
)
+
item
).
encode
()).
hexdigest
()
hash_func
=
hashlib
.
sha256
((
str
(
i
)
+
item
).
encode
()).
hexdigest
()
hash_values
.
append
(
int
(
hash_func
,
16
)
%
self
.
size
)
return
hash_values
def
add
(
self
,
item
):
"""
Ajoute un élément dans le Filtre Bloom
"""
for
pos
in
self
.
_hashes
(
item
):
self
.
bit_array
[
pos
]
=
1
def
contains
(
self
,
item
):
"""
Verifie si un élemnt est présent dans le filtre de Bloom
>>>
bf
=
SimpleBloomFilter
(
10
,
2
)
>>>
bf
.
add
(
"
test
"
)
>>>
bf
.
contains
(
"
test
"
)
True
>>>
bf
.
contains
(
"
not_in
"
)
False
"""
return
all
(
self
.
bit_array
[
pos
]
for
pos
in
self
.
_hashes
(
item
))
def
merge
(
self
,
other
):
...
...
@@ -70,6 +89,17 @@ class Structure:
return
nodes
[
0
]
if
nodes
else
None
def
query
(
self
,
kmer
):
"""
>>>
datasets
=
[
"
D1
"
,
"
D2
"
]
>>>
kmers_dict
=
{
"
D1
"
:
[
"
ACGT
"
],
"
D2
"
:
[
"
TGCA
"
]}
>>>
s
=
Structure
(
datasets
,
kmers_dict
,
10
,
1
)
>>>
s
.
query
(
"
ACGT
"
)
[
'
D1
'
]
>>>
s
.
query
(
"
TGCA
"
)
[
'
D2
'
]
>>>
s
.
query
(
"
GCTA
"
)
[]
"""
results
=
[]
self
.
_query_recursive
(
self
.
root
,
kmer
,
results
)
return
results
...
...
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