Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
panacota
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amandine PERRIN
panacota
Commits
566fca5a
Commit
566fca5a
authored
5 years ago
by
Amandine PERRIN
Browse files
Options
Downloads
Patches
Plain Diff
First test for prepare:filter_genomes
parent
895fb9cf
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_unit/test_prepare/test_filter.py
+54
-0
54 additions, 0 deletions
test/test_unit/test_prepare/test_filter.py
with
54 additions
and
0 deletions
test/test_unit/test_prepare/test_filter.py
+
54
−
0
View file @
566fca5a
...
...
@@ -6,5 +6,59 @@ Unit tests for the download_genomes_func submodule in prepare module
"""
import
os
import
logging
import
shutil
import
PanACoTA.prepare_module.filter_genomes
as
filterg
DATA_TEST_DIR
=
os
.
path
.
join
(
"
test
"
,
"
data
"
,
"
prepare
"
)
def
test_write_output
(
caplog
):
"""
Check that the files with kept genomes and discarded genomes are created
"""
corresp_genomes
=
{
"
ACOR001
"
:
"
ACOR001.0519.fna.gz
"
,
"
ACOR002
"
:
"
ACOR002.0519.fna.gz
"
,
"
ACOR003
"
:
"
ACOR003.0519.fna.gz
"
}
sorted_genomes
=
[
os
.
path
.
join
(
DATA_TEST_DIR
,
"
genomes
"
,
"
refseq
"
,
"
bacteria
"
,
gen
,
gz
)
for
gen
,
gz
in
corresp_genomes
.
items
()]
genomes
=
{
genome_file
:[
"
gname
"
,
"
ori_name
"
,
"
path_annotate
"
,
12
,
10
,
1
]
for
genome_file
in
sorted_genomes
}
genomes
[
"
toto
"
]
=
[
'
totoname
'
,
'
ori toto
'
,
'
path_toto
'
,
13
,
5
,
6
]
genomes_removed
=
{
"
genome
"
:
[
"
ref
"
,
10
]}
# Define output directory for generated files
outdir
=
os
.
path
.
join
(
DATA_TEST_DIR
,
"
test_filter_write_output
"
)
os
.
makedirs
(
outdir
)
gspecies
=
"
Acetobacter_fabarum
"
min_dist
=
0.06
# Check everything works without error
assert
filterg
.
write_outputfiles
(
genomes
,
sorted_genomes
,
genomes_removed
,
outdir
,
gspecies
,
min_dist
)
==
0
# Check outfiles exist
list_file
=
os
.
path
.
join
(
outdir
,
"
LSTINFO-Acetobacter_fabarum-filtered-0.06.txt
"
)
discard_file
=
os
.
path
.
join
(
outdir
,
"
discarded-by-minhash-Acetobacter_fabarum-0.06.txt
"
)
assert
os
.
path
.
isfile
(
list_file
)
assert
os
.
path
.
isfile
(
discard_file
)
# Check content of out files
with
open
(
list_file
)
as
lf
:
# Check header
assert
"
to_annotate
\t
gsize
\t
nb_conts
\t
L90
"
in
lf
.
readline
()
# Check there are 3 genomes, with expected information
assert
"
path_annotate 12
\t
10
\t
1
"
in
lf
.
readline
()
assert
"
path_annotate
\t
12
\t
10
\t
1
"
in
lf
.
readline
()
assert
"
path_annotate
\t
12
\t
10
\t
1
"
in
lf
.
readline
()
assert
"
path_annotate
\t
12
\t
10
\t
1
"
in
lf
.
readline
()
assert
lf
.
readline
()
==
"
\n
"
with
open
(
discard_file
)
as
df
:
# Check header
assert
"
genome_name
\t
problem_compared_with
\t
dist
"
in
df
.
readline
()
# Check genome line
assert
"
genome
"
in
df
.
readline
()
# Check no more genomes
assert
df
.
readline
()
==
'
\n
'
# Remove test folder
# shutil.rmtree(outdir)
\ No newline at end of file
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