Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PyHMMER
Manage
Activity
Members
Labels
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
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
PyHMMER
Commits
54259b60
Commit
54259b60
authored
5 months ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Fix type annotations in `pyhmmer.hmmer` to pass the query type transparently
parent
e64bb172
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
pyhmmer/hmmer.py
+23
-17
23 additions, 17 deletions
pyhmmer/hmmer.py
pyhmmer/utils.py
+15
-7
15 additions, 7 deletions
pyhmmer/utils.py
with
38 additions
and
24 deletions
pyhmmer/hmmer.py
+
23
−
17
View file @
54259b60
...
...
@@ -62,6 +62,13 @@ _T = typing.TypeVar("_T")
_R
=
typing
.
TypeVar
(
"
_R
"
)
_I
=
typing
.
TypeVar
(
"
_I
"
)
# generic profile type
_P
=
typing
.
TypeVar
(
"
_P
"
,
HMM
,
Profile
,
OptimizedProfile
)
# generic alignment type
_M
=
typing
.
TypeVar
(
"
_M
"
,
DigitalSequence
,
DigitalMSA
)
# generic nucleotide query type
_N
=
typing
.
TypeVar
(
"
_N
"
,
DigitalSequence
,
DigitalMSA
,
HMM
,
Profile
,
OptimizedProfile
)
# type aliases
_AnyProfile
=
typing
.
Union
[
HMM
,
Profile
,
OptimizedProfile
]
...
...
@@ -778,15 +785,14 @@ class _SCANDispatcher(
# --- hmmsearch --------------------------------------------------------------
def
hmmsearch
(
queries
:
typing
.
Union
[
_SEARCHQueryType
,
typing
.
Iterable
[
_SEARCHQueryType
]],
queries
:
typing
.
Union
[
_P
,
typing
.
Iterable
[
_P
]],
#
typing.Union[_SEARCHQueryType, typing.Iterable[_SEARCHQueryType]],
sequences
:
typing
.
Iterable
[
DigitalSequence
],
*
,
cpus
:
int
=
0
,
callback
:
typing
.
Optional
[
typing
.
Callable
[[
_
SEARCHQueryType
,
int
],
None
]]
=
None
,
callback
:
typing
.
Optional
[
typing
.
Callable
[[
_
P
,
int
],
None
]]
=
None
,
**
options
,
# type: object
)
->
typing
.
Iterator
[
"
TopHits[_
SEARCHQueryType
]
"
]:
)
->
typing
.
Iterator
[
"
TopHits[_
P
]
"
]:
"""
Search HMM profiles against a sequence database.
In HMMER many-to-many comparisons, a *search* is the operation of
...
...
@@ -879,27 +885,27 @@ def hmmsearch(
queries
=
queries
,
targets
=
targets
,
cpus
=
_cpus
,
callback
=
callback
,
callback
=
callback
,
# type: ignore
alphabet
=
alphabet
,
builder
=
None
,
pipeline_class
=
Pipeline
,
**
options
,
# type: ignore
)
return
dispatcher
.
run
()
return
dispatcher
.
run
()
# type: ignore
# --- phmmer -----------------------------------------------------------------
def
phmmer
(
queries
:
typing
.
Union
[
_
PHMMERQueryType
,
typing
.
Iterable
[
_
PHMMERQueryType
]],
queries
:
typing
.
Union
[
_
M
,
typing
.
Iterable
[
_
M
]],
sequences
:
typing
.
Iterable
[
DigitalSequence
],
*
,
cpus
:
int
=
0
,
callback
:
typing
.
Optional
[
typing
.
Callable
[[
_
PHMMERQueryType
,
int
],
None
]]
=
None
,
callback
:
typing
.
Optional
[
typing
.
Callable
[[
_
M
,
int
],
None
]]
=
None
,
builder
:
typing
.
Optional
[
Builder
]
=
None
,
**
options
,
# type: object
)
->
typing
.
Iterator
[
"
TopHits[_
PHMMERQueryType
]
"
]:
)
->
typing
.
Iterator
[
"
TopHits[_
M
]
"
]:
"""
Search protein sequences against a sequence database.
Arguments:
...
...
@@ -973,13 +979,13 @@ def phmmer(
queries
=
queries
,
targets
=
targets
,
cpus
=
_cpus
,
callback
=
callback
,
callback
=
callback
,
# type: ignore
pipeline_class
=
Pipeline
,
alphabet
=
alphabet
,
builder
=
_builder
,
**
options
,
# type: ignore
)
return
dispatcher
.
run
()
return
dispatcher
.
run
()
# type: ignore
# --- jackhmmer -----------------------------------------------------------------
...
...
@@ -1040,7 +1046,7 @@ def jackhmmer(
sequences
:
typing
.
Iterable
[
DigitalSequence
],
*
,
max_iterations
:
typing
.
Optional
[
int
]
=
5
,
select_hits
:
typing
.
Optional
[
typing
.
Callable
[[
"
TopHits[
Any
]
"
],
None
]]
=
None
,
select_hits
:
typing
.
Optional
[
typing
.
Callable
[[
"
TopHits[
_JACKHMMERQueryType
]
"
],
None
]]
=
None
,
checkpoints
:
bool
=
False
,
cpus
:
int
=
0
,
callback
:
typing
.
Optional
[
typing
.
Callable
[[
_JACKHMMERQueryType
,
int
],
None
]]
=
None
,
...
...
@@ -1159,14 +1165,14 @@ def jackhmmer(
def
nhmmer
(
queries
:
typing
.
Union
[
_N
HMMERQueryType
,
typing
.
Iterable
[
_N
HMMERQueryType
]],
queries
:
typing
.
Union
[
_N
,
typing
.
Iterable
[
_N
]],
sequences
:
typing
.
Iterable
[
DigitalSequence
],
*
,
cpus
:
int
=
0
,
callback
:
typing
.
Optional
[
typing
.
Callable
[[
_N
HMMERQueryType
,
int
],
None
]]
=
None
,
callback
:
typing
.
Optional
[
typing
.
Callable
[[
_N
,
int
],
None
]]
=
None
,
builder
:
typing
.
Optional
[
Builder
]
=
None
,
**
options
,
# type: object
)
->
typing
.
Iterator
[
"
TopHits[_N
HMMERQueryType
]
"
]:
)
->
typing
.
Iterator
[
"
TopHits[_N]
"
]:
"""
Search nucleotide sequences against a sequence database.
Arguments:
...
...
@@ -1253,13 +1259,13 @@ def nhmmer(
queries
=
queries
,
targets
=
targets
,
cpus
=
_cpus
,
callback
=
callback
,
callback
=
callback
,
# type: ignore
pipeline_class
=
LongTargetsPipeline
,
alphabet
=
alphabet
,
builder
=
_builder
,
**
options
,
# type: ignore
)
return
dispatcher
.
run
()
return
dispatcher
.
run
()
# type: ignore
# --- hmmpress ---------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
pyhmmer/utils.py
+
15
−
7
View file @
54259b60
...
...
@@ -75,25 +75,33 @@ class singledispatchmethod(typing.Generic[_T]):
return
_method
@typing.overload
def
register
(
self
,
cls
:
typing
.
Type
[
typing
.
Any
],
method
:
None
=
...
def
register
(
# type: ignore
self
,
cls
:
typing
.
Type
[
typing
.
Any
],
method
:
None
=
...
)
->
typing
.
Callable
[[
typing
.
Callable
[...,
_T
]],
typing
.
Callable
[...,
_T
]]:
...
@typing.overload
def
register
(
self
,
cls
:
typing
.
Callable
[...,
_T
],
method
:
None
=
...
def
register
(
# type: ignore
self
,
cls
:
typing
.
Callable
[...,
_T
],
method
:
None
=
...
)
->
typing
.
Callable
[...,
_T
]:
...
@typing.overload
def
register
(
self
,
cls
:
typing
.
Type
[
typing
.
Any
],
method
:
typing
.
Callable
[...,
_T
]
def
register
(
# type: ignore
self
,
cls
:
typing
.
Type
[
typing
.
Any
],
method
:
typing
.
Callable
[...,
_T
]
)
->
typing
.
Callable
[...,
_T
]:
...
def
register
(
self
,
cls
:
typing
.
Any
,
method
:
typing
.
Optional
[
typing
.
Callable
[...,
_T
]]
=
None
self
,
cls
:
typing
.
Any
,
method
:
typing
.
Optional
[
typing
.
Callable
[...,
_T
]]
=
None
)
->
typing
.
Any
:
"""
Registers a new implementation for the given class.
"""
return
self
.
dispatcher
.
register
(
cls
,
func
=
method
)
...
...
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