Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PyFastANI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Monitor
Incidents
Service Desk
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
PyFastANI
Commits
a1147089
Commit
a1147089
authored
3 years ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Add small unit tests for `pyfastani.Sketch` behaviours without data dependency
parent
2347d978
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyfastani/tests/test_sketch.py
+49
-0
49 additions, 0 deletions
pyfastani/tests/test_sketch.py
with
49 additions
and
0 deletions
pyfastani/tests/test_sketch.py
0 → 100644
+
49
−
0
View file @
a1147089
import
os
import
sys
import
unittest
import
warnings
import
pyfastani
class
TestSketch
(
unittest
.
TestCase
):
def
test_init_errors
(
self
):
"""
Check that constructor parameters are properly validated.
"""
self
.
assertRaises
(
TypeError
,
pyfastani
.
Sketch
,
k
=
"
1
"
)
self
.
assertRaises
(
TypeError
,
pyfastani
.
Sketch
,
fragment_length
=
"
1
"
)
self
.
assertRaises
(
TypeError
,
pyfastani
.
Sketch
,
minimum_fraction
=
"
0.5
"
)
self
.
assertRaises
(
OverflowError
,
pyfastani
.
Sketch
,
k
=
2
**
32
)
self
.
assertRaises
(
ValueError
,
pyfastani
.
Sketch
,
k
=
0
)
self
.
assertRaises
(
ValueError
,
pyfastani
.
Sketch
,
p_value
=-
1.0
)
self
.
assertRaises
(
ValueError
,
pyfastani
.
Sketch
,
percentage_identity
=-
1.0
)
self
.
assertRaises
(
ValueError
,
pyfastani
.
Sketch
,
percentage_identity
=
200.0
)
def
test_reinit
(
self
):
"""
Check that calling `__init__` more than once does not crash.
"""
sketch
=
pyfastani
.
Sketch
()
sketch
.
add_genome
(
"
test
"
,
"
ATGC
"
*
1000
)
self
.
assertEqual
(
sketch
.
names
,
[
"
test
"
])
sketch
.
__init__
()
self
.
assertEqual
(
sketch
.
names
,
[])
def
test_add_draft_warnings
(
self
):
"""
Check that `Sketch.add_draft` raises warnings as expected.
"""
sketch
=
pyfastani
.
Sketch
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
catch
:
sketch
.
add_draft
(
"
short_seq
"
,
[
"
ATGC
"
*
1000
,
"
ATGC
"
])
self
.
assertEqual
(
len
(
catch
),
1
)
# second sequence is too short
def
test_add_sequence_short
(
self
):
"""
Check that a sequence too short to be hashed is still recorded.
"""
sketch
=
pyfastani
.
Sketch
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
catch
:
warnings
.
simplefilter
(
"
ignore
"
)
sketch
.
add_draft
(
"
short_seq
"
,
[
"
ATGC
"
*
1000
,
"
ATGC
"
])
self
.
assertEqual
(
sketch
.
names
,
[
"
short_seq
"
])
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