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
bbde5508
Commit
bbde5508
authored
9 months ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Reorganize tests in `lightmotif` crate
parent
8872b834
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/tests/dna.rs
+126
-80
126 additions, 80 deletions
lightmotif/tests/dna.rs
lightmotif/tests/encode.rs
+74
-21
74 additions, 21 deletions
lightmotif/tests/encode.rs
with
200 additions
and
101 deletions
lightmotif/tests/dna.rs
+
126
−
80
View file @
bbde5508
...
...
@@ -89,6 +89,35 @@ fn test_score<C: StrictlyPositive, P: Score<f32, Dna, C>>(pli: &P) {
}
}
fn
test_score_discrete
<
C
:
StrictlyPositive
,
P
:
Score
<
u8
,
Dna
,
C
>>
(
pli
:
&
P
)
{
let
encoded
=
EncodedSequence
::
<
Dna
>
::
encode
(
SEQUENCE
)
.unwrap
();
let
mut
striped
=
Pipeline
::
generic
()
.stripe
(
encoded
);
let
cm
=
CountMatrix
::
<
Dna
>
::
from_sequences
(
PATTERNS
.iter
()
.map
(|
x
|
EncodedSequence
::
encode
(
x
)
.unwrap
()),
)
.unwrap
();
let
pbm
=
cm
.to_freq
(
0.1
);
let
pwm
=
pbm
.to_weight
(
None
);
let
pssm
=
pwm
.to_scoring
();
let
dm
=
pssm
.to_discrete
();
striped
.configure
(
&
pssm
);
let
result
=
pli
.score
(
&
dm
,
&
striped
);
let
scores
=
result
.unstripe
();
assert_eq!
(
scores
.len
(),
EXPECTED
.len
());
for
i
in
0
..
scores
.len
()
{
assert!
(
dm
.unscale
(
scores
[
i
])
>=
EXPECTED
[
i
],
"{} != {} at position {}"
,
dm
.unscale
(
scores
[
i
]),
EXPECTED
[
i
],
i
);
}
}
fn
test_argmax
<
C
:
StrictlyPositive
,
P
:
Score
<
f32
,
Dna
,
C
>
+
Maximum
<
f32
,
C
>>
(
pli
:
&
P
)
{
let
encoded
=
EncodedSequence
::
<
Dna
>
::
encode
(
SEQUENCE
)
.unwrap
();
let
mut
striped
=
Pipeline
::
generic
()
.stripe
(
encoded
);
...
...
@@ -197,104 +226,121 @@ mod generic {
}
}
#[test]
fn
test_score_dispatch
()
{
let
pli
=
Pipeline
::
dispatch
();
test_score
(
&
pli
);
}
mod
dispatch
{
use
super
::
*
;
#[test]
fn
test_
argmax_dispatch
()
{
let
pli
=
Pipeline
::
dispatch
();
test_argmax
(
&
pli
);
}
#[test]
fn
test_
score
()
{
let
pli
=
Pipeline
::
dispatch
();
super
::
test_score
::
<
U32
,
_
>
(
&
pli
);
}
#[test]
fn
test_
threshold_dispatch
()
{
let
pli
=
Pipeline
::
dispatch
();
test_threshold
(
&
pli
);
}
#[test]
fn
test_
score_rows
()
{
let
pli
=
Pipeline
::
dispatch
();
super
::
test_score_rows
::
<
U32
,
_
>
(
&
pli
);
}
#[cfg(target_feature
=
"sse2"
)]
#[test]
fn
test_score_sse2
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
();
test_score
::
<
U16
,
_
>
(
&
pli
);
}
#[test]
fn
test_argmax
()
{
let
pli
=
Pipeline
::
dispatch
();
super
::
test_argmax
::
<
U32
,
_
>
(
&
pli
);
}
#[cfg(target_feature
=
"sse2"
)
]
#[test]
fn
test_argmax_sse2
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
(
);
test_argmax
::
<
U16
,
_
>
(
&
pli
);
#[test
]
fn
test_threshold
()
{
let
pli
=
Pipeline
::
dispatch
();
super
::
test_threshold
::
<
U32
,
_
>
(
&
pli
);
}
}
#[cfg(target_feature
=
"sse2"
)]
#[test]
fn
test_threshold_sse2
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
();
test_threshold
::
<
U16
,
_
>
(
&
pli
);
}
mod
sse2
{
use
super
::
*
;
#[cfg(target_feature
=
"sse2"
)
]
#[test]
fn
test_score_sse2_32
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
(
);
test_score
::
<
U
32
,
_
>
(
&
pli
);
}
#[test
]
fn
test_score
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
();
super
::
test_score
::
<
U32
,
_
>
(
&
pli
);
super
::
test_score
::
<
U
16
,
_
>
(
&
pli
);
}
#[cfg(target_feature
=
"sse2"
)
]
#[test]
fn
test_argmax_sse2_32
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
(
);
test_argmax
::
<
U
32
,
_
>
(
&
pli
);
}
#[test
]
fn
test_score_rows
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
();
super
::
test_score_rows
::
<
U32
,
_
>
(
&
pli
);
super
::
test_score_rows
::
<
U
16
,
_
>
(
&
pli
);
}
#[cfg(target_feature
=
"sse2"
)
]
#[test]
fn
test_threshold_sse2_32
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
(
);
test_threshold
::
<
U
32
,
_
>
(
&
pli
);
}
#[test
]
fn
test_argmax
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
();
super
::
test_argmax
::
<
U32
,
_
>
(
&
pli
);
super
::
test_argmax
::
<
U
16
,
_
>
(
&
pli
);
}
#[cfg(target_feature
=
"avx2"
)]
#[test]
fn
test_score_avx2
()
{
let
pli
=
Pipeline
::
avx2
()
.unwrap
();
test_score
(
&
pli
);
#[test]
fn
test_threshold
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
();
super
::
test_threshold
::
<
U32
,
_
>
(
&
pli
);
super
::
test_threshold
::
<
U16
,
_
>
(
&
pli
);
}
}
#[cfg(target_feature
=
"avx2"
)]
#[test]
fn
test_argmax_avx2
()
{
let
pli
=
Pipeline
::
avx2
()
.unwrap
();
test_argmax
(
&
pli
);
}
mod
avx2
{
use
super
::
*
;
#[cfg(target_feature
=
"avx2"
)]
#[test]
fn
test_threshold_avx2
()
{
let
pli
=
Pipeline
::
avx2
()
.unwrap
();
test_threshold
::
<
U32
,
_
>
(
&
pli
);
}
#[test]
fn
test_score
()
{
let
pli
=
Pipeline
::
avx2
()
.unwrap
();
super
::
test_score
::
<
U32
,
_
>
(
&
pli
);
}
#[cfg(target_feature
=
"neon"
)]
#[test]
fn
test_score_neon
()
{
let
pli
=
Pipeline
::
neon
()
.unwrap
();
test_score
::
<
U16
,
_
>
(
&
pli
);
}
#[test]
fn
test_score_rows
()
{
let
pli
=
Pipeline
::
avx2
()
.unwrap
();
super
::
test_score_rows
::
<
U32
,
_
>
(
&
pli
);
}
#[cfg(target_feature
=
"neon"
)]
#[test]
fn
test_argmax_neon
()
{
let
pli
=
Pipeline
::
neon
()
.unwrap
();
test_argmax
::
<
U16
,
_
>
(
&
pli
);
#[test]
fn
test_argmax
()
{
let
pli
=
Pipeline
::
avx2
()
.unwrap
();
super
::
test_argmax
::
<
U32
,
_
>
(
&
pli
);
}
#[test]
fn
test_threshold
()
{
let
pli
=
Pipeline
::
avx2
()
.unwrap
();
super
::
test_threshold
::
<
U32
,
_
>
(
&
pli
);
}
}
#[cfg(target_feature
=
"neon"
)]
#[test]
fn
test_threshold_neon
()
{
let
pli
=
Pipeline
::
neon
()
.unwrap
();
test_threshold
::
<
U16
,
_
>
(
&
pli
);
mod
neon
{
use
super
::
*
;
#[test]
fn
test_score
()
{
let
pli
=
Pipeline
::
neon
()
.unwrap
();
super
::
test_score
::
<
U16
,
_
>
(
&
pli
);
}
#[test]
fn
test_score_rows
()
{
let
pli
=
Pipeline
::
neon
()
.unwrap
();
super
::
test_score_rows
::
<
U16
,
_
>
(
&
pli
);
}
#[test]
fn
test_argmax
()
{
let
pli
=
Pipeline
::
neon
()
.unwrap
();
super
::
test_argmax
::
<
U16
,
_
>
(
&
pli
);
}
#[test]
fn
test_threshold
()
{
let
pli
=
Pipeline
::
neon
()
.unwrap
();
super
::
test_threshold
::
<
U16
,
_
>
(
&
pli
);
}
}
This diff is collapsed.
Click to expand it.
lightmotif/tests/encode.rs
+
74
−
21
View file @
bbde5508
...
...
@@ -15,42 +15,95 @@ const EXPECTED: &[Nucleotide] = &[
A
,
T
,
G
,
T
,
C
,
C
,
C
,
A
,
A
,
C
,
A
,
A
,
C
,
G
,
A
,
T
,
A
,
C
,
C
,
C
,
C
,
G
,
A
,
G
,
C
,
C
,
C
,
A
,
T
,
C
,
G
,
C
,
C
,
G
,
T
,
C
,
A
,
T
,
C
,
G
,
G
,
C
,
T
,
C
,
G
,
G
,
C
,
A
,
T
,
G
,
C
,
A
,
G
,
A
,
T
,
T
,
C
,
C
,
C
,
A
,
G
,
G
,
C
,
G
];
fn
test_encode
<
P
:
Encode
<
Dna
>>
(
pli
:
&
P
)
{
fn
test_encode
_sequence
<
P
:
Encode
<
Dna
>>
(
pli
:
&
P
)
{
let
encoded
=
pli
.encode
(
SEQUENCE
)
.unwrap
();
assert_eq!
(
encoded
,
EXPECTED
);
}
fn
test_encode_unknown
<
P
:
Encode
<
Dna
>>
(
pli
:
&
P
)
{
let
err
=
pli
.encode
(
UNKNOWNS
)
.unwrap_err
();
assert_eq!
(
err
.0
,
'.'
);
}
#[test]
fn
test_encode_generic
()
{
let
pli
=
Pipeline
::
generic
();
test_encode
(
&
pli
);
mod
generic
{
use
super
::
*
;
#[test]
fn
test_sequence
()
{
let
pli
=
Pipeline
::
generic
();
test_encode_sequence
(
&
pli
);
}
#[test]
fn
test_unknown
()
{
let
pli
=
Pipeline
::
generic
();
test_encode_unknown
(
&
pli
);
}
}
#[test]
fn
test_encode_dispatch
()
{
let
pli
=
Pipeline
::
dispatch
();
test_encode
(
&
pli
);
mod
dispatch
{
use
super
::
*
;
#[test]
fn
test_sequence
()
{
let
pli
=
Pipeline
::
dispatch
();
test_encode_sequence
(
&
pli
);
}
#[test]
fn
test_unknown
()
{
let
pli
=
Pipeline
::
dispatch
();
test_encode_unknown
(
&
pli
);
}
}
#[cfg(target_feature
=
"sse2"
)]
#[test]
fn
test_encode_sse2
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
();
test_encode
(
&
pli
);
mod
sse2
{
use
super
::
*
;
#[test]
fn
test_sequence
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
();
test_encode_sequence
(
&
pli
);
}
#[test]
fn
test_unknown
()
{
let
pli
=
Pipeline
::
sse2
()
.unwrap
();
test_encode_unknown
(
&
pli
);
}
}
#[cfg(target_feature
=
"avx2"
)]
#[test]
fn
test_encode_avx2
()
{
let
pli
=
Pipeline
::
avx2
()
.unwrap
();
test_encode
(
&
pli
);
mod
avx2
{
use
super
::
*
;
#[test]
fn
test_sequence
()
{
let
pli
=
Pipeline
::
avx2
()
.unwrap
();
test_encode_sequence
(
&
pli
);
}
#[test]
fn
test_unknown
()
{
let
pli
=
Pipeline
::
avx2
()
.unwrap
();
test_encode_unknown
(
&
pli
);
}
}
#[cfg(target_feature
=
"neon"
)]
#[test]
fn
test_encode_neon
()
{
let
pli
=
Pipeline
::
neon
()
.unwrap
();
test_encode
(
&
pli
);
mod
neon
{
use
super
::
*
;
#[test]
fn
test_sequence
()
{
let
pli
=
Pipeline
::
neon
()
.unwrap
();
test_encode_sequence
(
&
pli
);
}
#[test]
fn
test_unknown
()
{
let
pli
=
Pipeline
::
neon
()
.unwrap
();
test_encode_unknown
(
&
pli
);
}
}
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