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
8b5f5a6f
Commit
8b5f5a6f
authored
1 year ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Add getter to the raw data of a `FrequencyMatrix`
parent
d560ad86
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lightmotif/src/pwm.rs
+12
-2
12 additions, 2 deletions
lightmotif/src/pwm.rs
with
12 additions
and
2 deletions
lightmotif/src/pwm.rs
+
12
−
2
View file @
8b5f5a6f
...
@@ -180,9 +180,13 @@ impl<A: Alphabet> FrequencyMatrix<A> {
...
@@ -180,9 +180,13 @@ impl<A: Alphabet> FrequencyMatrix<A> {
/// Create a new frequency matrix.
/// Create a new frequency matrix.
///
///
/// The matrix must contain frequency data, i.e. rows should all sum to 1.
/// The matrix must contain frequency data, i.e. rows should all sum to 1
/// (with a tolerance of 0.01).
pub
fn
new
(
data
:
DenseMatrix
<
f32
,
A
::
K
>
)
->
Result
<
Self
,
InvalidData
>
{
pub
fn
new
(
data
:
DenseMatrix
<
f32
,
A
::
K
>
)
->
Result
<
Self
,
InvalidData
>
{
if
data
.iter
()
.all
(|
row
|
row
.iter
()
.sum
::
<
f32
>
()
==
1.0
)
{
if
data
.iter
()
.all
(|
row
|
(
row
.iter
()
.sum
::
<
f32
>
()
-
1.0
)
.abs
()
<
0.01
)
{
Ok
(
Self
::
new_unchecked
(
data
))
Ok
(
Self
::
new_unchecked
(
data
))
}
else
{
}
else
{
Err
(
InvalidData
)
Err
(
InvalidData
)
...
@@ -235,6 +239,12 @@ impl<A: Alphabet> FrequencyMatrix<A> {
...
@@ -235,6 +239,12 @@ impl<A: Alphabet> FrequencyMatrix<A> {
}
}
ScoringMatrix
::
new
(
bg
,
scores
)
ScoringMatrix
::
new
(
bg
,
scores
)
}
}
/// The raw frequencies from the frequency matrix.
#[inline]
pub
fn
frequencies
(
&
self
)
->
&
DenseMatrix
<
f32
,
A
::
K
>
{
&
self
.data
}
}
}
impl
<
A
:
ComplementableAlphabet
>
FrequencyMatrix
<
A
>
{
impl
<
A
:
ComplementableAlphabet
>
FrequencyMatrix
<
A
>
{
...
...
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