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
8d763605
Commit
8d763605
authored
1 year ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Make `StripedSequence::new` return an error when given an invalid length
parent
e26e11ef
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
lightmotif/src/pli/mod.rs
+2
-2
2 additions, 2 deletions
lightmotif/src/pli/mod.rs
lightmotif/src/seq.rs
+11
-6
11 additions, 6 deletions
lightmotif/src/seq.rs
with
13 additions
and
8 deletions
lightmotif/src/pli/mod.rs
+
2
−
2
View file @
8d763605
...
...
@@ -142,7 +142,7 @@ pub trait Stripe<A: Alphabet, C: StrictlyPositive> {
let
s
=
seq
.as_ref
();
let
length
=
s
.len
();
let
rows
=
(
length
/
C
::
USIZE
)
+
((
length
%
C
::
USIZE
>
0
)
as
usize
);
let
mut
striped
=
StripedSequence
::
new
(
DenseMatrix
::
new
(
rows
),
length
);
let
mut
striped
=
StripedSequence
::
new
(
DenseMatrix
::
new
(
rows
),
length
)
.unwrap
()
;
self
.stripe_into
(
s
,
&
mut
striped
);
striped
}
...
...
@@ -159,7 +159,7 @@ pub trait Stripe<A: Alphabet, C: StrictlyPositive> {
for
(
i
,
&
x
)
in
s
.iter
()
.enumerate
()
{
data
[
i
%
rows
][
i
/
rows
]
=
x
;
}
for
i
in
s
.len
()
..
m
at
rix
.rows
()
*
m
at
rix
.columns
()
{
for
i
in
s
.len
()
..
d
at
a
.rows
()
*
d
at
a
.columns
()
{
data
[
i
%
rows
][
i
/
rows
]
=
A
::
default_symbol
();
}
}
...
...
This diff is collapsed.
Click to expand it.
lightmotif/src/seq.rs
+
11
−
6
View file @
8d763605
...
...
@@ -11,6 +11,7 @@ use typenum::marker_traits::Unsigned;
use
super
::
abc
::
Alphabet
;
use
super
::
abc
::
Symbol
;
use
super
::
dense
::
DenseMatrix
;
use
super
::
err
::
InvalidData
;
use
super
::
err
::
InvalidSymbol
;
use
super
::
num
::
StrictlyPositive
;
use
super
::
pwm
::
ScoringMatrix
;
...
...
@@ -145,12 +146,16 @@ pub struct StripedSequence<A: Alphabet, C: StrictlyPositive> {
impl
<
A
:
Alphabet
,
C
:
StrictlyPositive
>
StripedSequence
<
A
,
C
>
{
/// Create a new striped sequence from the given dense matrix.
pub
fn
new
(
data
:
DenseMatrix
<
A
::
Symbol
,
C
>
,
length
:
usize
)
->
Self
{
Self
{
data
,
length
,
wrap
:
0
,
alphabet
:
std
::
marker
::
PhantomData
,
pub
fn
new
(
data
:
DenseMatrix
<
A
::
Symbol
,
C
>
,
length
:
usize
)
->
Result
<
Self
,
InvalidData
>
{
if
data
.rows
()
*
data
.columns
()
<
length
{
Err
(
InvalidData
)
}
else
{
Ok
(
Self
{
data
,
length
,
wrap
:
0
,
alphabet
:
std
::
marker
::
PhantomData
,
})
}
}
...
...
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