Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LightMotif
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
Container 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
Martin Larralde
LightMotif
Commits
2670dee0
Commit
2670dee0
authored
1 year ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Add `StripedScores.threshold` method to `lightmotif-py`
parent
b9504e91
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lightmotif-py/lightmotif/lib.rs
+38
-0
38 additions, 0 deletions
lightmotif-py/lightmotif/lib.rs
with
38 additions
and
0 deletions
lightmotif-py/lightmotif/lib.rs
+
38
−
0
View file @
2670dee0
...
...
@@ -5,12 +5,15 @@ extern crate lightmotif;
extern
crate
pyo3
;
use
lightmotif
::
abc
::
Alphabet
;
use
lightmotif
::
abc
::
Dna
;
use
lightmotif
::
abc
::
Symbol
;
use
lightmotif
::
dense
::
DenseMatrix
;
use
lightmotif
::
num
::
StrictlyPositive
;
use
lightmotif
::
num
::
Unsigned
;
use
lightmotif
::
pli
::
platform
::
Backend
;
use
lightmotif
::
pli
::
Pipeline
;
use
lightmotif
::
pli
::
Score
;
use
lightmotif
::
pli
::
Threshold
;
use
pyo3
::
exceptions
::
PyBufferError
;
use
pyo3
::
exceptions
::
PyIndexError
;
...
...
@@ -286,6 +289,10 @@ impl ScoringMatrix {
/// of the input sequence, stored into a striped matrix for fast
/// vectorized operations.
///
/// Note:
/// This method uses the best implementation for the local platform,
/// prefering AVX2 if available.
///
pub
fn
calculate
(
slf
:
PyRef
<
'_
,
Self
>
,
sequence
:
&
mut
StripedSequence
,
...
...
@@ -378,6 +385,37 @@ impl StripedScores {
Ok
(())
}
/// Return all positions with a score greater or equal to the threshold.
///
/// Returns:
/// `list` of `int`: The indices of the position with a score greater or
/// equal to the given threshold. Note that the indices may or may not
/// be sorted, depending on the implementation.
///
/// Note:
/// This method uses the best implementation for the local platform,
/// prefering AVX2 if available.
///
pub
fn
threshold
(
slf
:
PyRef
<
'_
,
Self
>
,
threshold
:
f32
)
->
PyResult
<
Vec
<
usize
>>
{
let
scores
=
&
slf
.scores
;
let
indices
=
slf
.py
()
.allow_threads
(||
{
#[cfg(any(target_arch
=
"x86"
,
target_arch
=
"x86_64"
))]
if
let
Ok
(
pli
)
=
Pipeline
::
<
Dna
,
_
>
::
avx2
()
{
return
pli
.threshold
(
scores
,
threshold
);
}
#[cfg(any(target_arch
=
"x86"
,
target_arch
=
"x86_64"
))]
if
let
Ok
(
pli
)
=
Pipeline
::
<
Dna
,
_
>
::
sse2
()
{
return
pli
.threshold
(
scores
,
threshold
);
}
#[cfg(any(target_arch
=
"arm"
,
target_arch
=
"aarch64"
))]
if
let
Ok
(
pli
)
=
Pipeline
::
<
Dna
,
_
>
::
neon
()
{
return
pli
.threshold
(
scores
,
threshold
);
}
Pipeline
::
<
Dna
,
_
>
::
generic
()
.threshold
(
scores
,
threshold
)
});
Ok
(
indices
)
}
}
impl
From
<
lightmotif
::
pli
::
StripedScores
<
C
>>
for
StripedScores
{
...
...
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