Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PyFastANI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Martin Larralde
PyFastANI
Commits
16180c2c
Commit
16180c2c
authored
2 years ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Allow configuring thread count when calling `Mapper` query methods
parent
0592817c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyfastani/_fastani.pyi
+2
-2
2 additions, 2 deletions
pyfastani/_fastani.pyi
pyfastani/_fastani.pyx
+16
-10
16 additions, 10 deletions
pyfastani/_fastani.pyx
with
18 additions
and
12 deletions
pyfastani/_fastani.pyi
+
2
−
2
View file @
16180c2c
...
@@ -51,8 +51,8 @@ class Mapper(Generic[N], _Parameterized):
...
@@ -51,8 +51,8 @@ class Mapper(Generic[N], _Parameterized):
minimizers
:
Minimizers
minimizers
:
Minimizers
def
__getstate__
(
self
)
->
Dict
[
str
,
object
]:
...
def
__getstate__
(
self
)
->
Dict
[
str
,
object
]:
...
def
__setstate__
(
self
,
state
:
Dict
[
str
,
object
])
->
None
:
...
def
__setstate__
(
self
,
state
:
Dict
[
str
,
object
])
->
None
:
...
def
query_draft
(
self
,
contigs
:
Iterable
[
Seq
])
->
List
[
Hit
[
N
]]:
...
def
query_draft
(
self
,
contigs
:
Iterable
[
Seq
]
,
threads
:
int
)
->
List
[
Hit
[
N
]]:
...
def
query_genome
(
self
,
sequence
:
Seq
)
->
List
[
Hit
[
N
]]:
...
def
query_genome
(
self
,
sequence
:
Seq
,
threads
:
int
)
->
List
[
Hit
[
N
]]:
...
class
Hit
(
Generic
[
N
]):
class
Hit
(
Generic
[
N
]):
...
...
This diff is collapsed.
Click to expand it.
pyfastani/_fastani.pyx
+
16
−
10
View file @
16180c2c
...
@@ -963,7 +963,7 @@ cdef class Mapper(_Parameterized):
...
@@ -963,7 +963,7 @@ cdef class Mapper(_Parameterized):
final_mappings
.
_vec
final_mappings
.
_vec
)
)
cdef
list
_query_draft
(
self
,
object
contigs
):
cdef
list
_query_draft
(
self
,
object
contigs
,
int
threads
=
0
):
"""
Query the sketcher for the given contigs.
"""
Query the sketcher for the given contigs.
Adapted from the ``skch::Map::mapQuery`` method in ``computeMap.hpp``.
Adapted from the ``skch::Map::mapQuery`` method in ``computeMap.hpp``.
...
@@ -1002,7 +1002,7 @@ cdef class Mapper(_Parameterized):
...
@@ -1002,7 +1002,7 @@ cdef class Mapper(_Parameterized):
final_mappings
=
_FinalMappings
.
__new__
(
_FinalMappings
)
final_mappings
=
_FinalMappings
.
__new__
(
_FinalMappings
)
# spawn a thread pool to map fragments in parallel for all the contigs
# spawn a thread pool to map fragments in parallel for all the contigs
with
multiprocessing
.
pool
.
ThreadPool
()
as
pool
:
with
multiprocessing
.
pool
.
ThreadPool
(
threads
or
None
)
as
pool
:
for
contig
in
contigs
:
for
contig
in
contigs
:
# check length of contig is enough for computing mapping
# check length of contig is enough for computing mapping
slen
=
len
(
contig
)
slen
=
len
(
contig
)
...
@@ -1082,14 +1082,17 @@ cdef class Mapper(_Parameterized):
...
@@ -1082,14 +1082,17 @@ cdef class Mapper(_Parameterized):
))
))
return
hits
return
hits
cpdef
list
query_draft
(
self
,
object
contigs
):
cpdef
list
query_draft
(
self
,
object
contigs
,
int
threads
=
0
):
"""
query_draft(self, contigs)
\n
--
"""
query_draft(self, contigs
, threads=0
)
\n
--
Query the mapper for a complete genome.
Query the mapper for a complete genome.
Arguments:
Arguments:
contigs (iterable or `str` or `bytes`): The genome to query the mapper
contigs (iterable or `str` or `bytes`): The genome to query the
with.
mapper with.
threads (`int`): The number of threads to use to run the
fragment mapping in parallel. Pass *0* (the default) to
auto-detect the number of threads on the local machine.
Returns:
Returns:
`list` of `~pyfastani.Hit`: The hits found for the query.
`list` of `~pyfastani.Hit`: The hits found for the query.
...
@@ -1106,16 +1109,19 @@ cdef class Mapper(_Parameterized):
...
@@ -1106,16 +1109,19 @@ cdef class Mapper(_Parameterized):
"""
"""
# delegate to C code
# delegate to C code
return
self
.
_query_draft
(
contigs
)
return
self
.
_query_draft
(
contigs
,
threads
=
threads
)
cpdef
list
query_genome
(
self
,
object
sequence
):
cpdef
list
query_genome
(
self
,
object
sequence
,
int
threads
=
0
):
"""
query_genome(self, sequence)
\n
--
"""
query_genome(self, sequence
, threads=0
)
\n
--
Query the mapper for a complete genome.
Query the mapper for a complete genome.
Arguments:
Arguments:
sequence (`str` or `bytes`): The closed genome to query the
sequence (`str` or `bytes`): The closed genome to query the
mapper with.
mapper with.
threads (`int`): The number of threads to use to run the
fragment mapping in parallel. Pass *0* (the default) to
auto-detect the number of threads on the local machine.
Returns:
Returns:
`list` of `~pyfastani.Hit`: The hits found for the query.
`list` of `~pyfastani.Hit`: The hits found for the query.
...
@@ -1132,7 +1138,7 @@ cdef class Mapper(_Parameterized):
...
@@ -1132,7 +1138,7 @@ cdef class Mapper(_Parameterized):
"""
"""
# delegate to C code
# delegate to C code
return
self
.
_query_draft
((
sequence
,))
return
self
.
_query_draft
((
sequence
,)
,
threads
=
threads
)
cdef
class
Minimizers
:
cdef
class
Minimizers
:
...
...
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