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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amandine PERRIN
panacota
Commits
f6510f0d
Commit
f6510f0d
authored
4 years ago
by
Amandine PERRIN
Browse files
Options
Downloads
Patches
Plain Diff
Add possibility to choose assembly level while downloading genomes from NCBI
parent
0b90c4b7
No related branches found
No related tags found
No related merge requests found
Pipeline
#39521
failed
4 years ago
Stage: test
Stage: coverage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
PanACoTA/prepare_module/download_genomes_func.py
+6
-2
6 additions, 2 deletions
PanACoTA/prepare_module/download_genomes_func.py
test/test_unit/test_prepare/test_download.py
+9
-5
9 additions, 5 deletions
test/test_unit/test_prepare/test_download.py
with
15 additions
and
7 deletions
PanACoTA/prepare_module/download_genomes_func.py
+
6
−
2
View file @
f6510f0d
...
...
@@ -53,7 +53,7 @@ from PanACoTA import utils
logger
=
logging
.
getLogger
(
"
prepare.dds
"
)
def
download_from_refseq
(
species_linked
,
NCBI_species
,
NCBI_taxid
,
outdir
,
threads
):
def
download_from_refseq
(
species_linked
,
NCBI_species
,
NCBI_taxid
,
levels
,
outdir
,
threads
):
"""
Download refseq genomes of given species
...
...
@@ -79,7 +79,7 @@ def download_from_refseq(species_linked, NCBI_species, NCBI_taxid, outdir, threa
"""
# Name of summary file, with metadata for each strain:
sumfile
=
os
.
path
.
join
(
outdir
,
"
assembly_summary-{
}.txt
"
.
format
(
species_linked
)
)
sumfile
=
os
.
path
.
join
(
outdir
,
f
"
assembly_summary-
{
species_linked
}
.txt
"
)
abs_sumfile
=
os
.
path
.
abspath
(
sumfile
)
# arguments needed to download all genomes of the given species
...
...
@@ -99,6 +99,10 @@ def download_from_refseq(species_linked, NCBI_species, NCBI_taxid, outdir, threa
message
+=
f
"
(NCBI_taxid =
{
NCBI_taxid
}
).
"
else
:
message
+=
f
"
NCBI_taxid =
{
NCBI_taxid
}
"
# If assembly level(s) given, add it to arguments, and write to info message
if
levels
:
keyargs
[
"
assembly_levels
"
]
=
levels
message
+=
f
"
(Only those assembly levels:
{
levels
}
).
"
logger
.
info
(
f
"
Metadata for all genomes will be saved in
{
sumfile
}
"
)
logger
.
info
(
message
)
...
...
This diff is collapsed.
Click to expand it.
test/test_unit/test_prepare/test_download.py
+
9
−
5
View file @
f6510f0d
...
...
@@ -204,9 +204,10 @@ def test_download():
NCBI_taxid
=
"
104099
"
outdir
=
os
.
path
.
join
(
DATA_TEST_DIR
,
"
test_download_refseq
"
)
threads
=
1
levels
=
""
db_dir
,
nb_gen
=
downg
.
download_from_refseq
(
species_linked
,
NCBI_species
,
NCBI_taxid
,
outdir
,
threads
)
db_dir
,
nb_gen
=
downg
.
download_from_refseq
(
species_linked
,
NCBI_species
,
NCBI_taxid
,
levels
,
outdir
,
threads
)
# Check path to uncompressed files is as expected
assert
db_dir
==
os
.
path
.
join
(
outdir
,
"
Database_init
"
)
# Check number of genomes downloaded. We cannot know the exact value, as it is updated everyday. But in nov. 2019, there are 4 genomes. So, there must be at least those 4 genomes
...
...
@@ -241,8 +242,9 @@ def test_download_noSpeName():
NCBI_taxid
=
"
104099
"
outdir
=
os
.
path
.
join
(
DATA_TEST_DIR
,
"
test_download_refseq_noSpe
"
)
threads
=
1
levels
=
""
db_dir
,
nb_gen
=
downg
.
download_from_refseq
(
species_linked
,
NCBI_species
,
NCBI_taxid
,
db_dir
,
nb_gen
=
downg
.
download_from_refseq
(
species_linked
,
NCBI_species
,
NCBI_taxid
,
levels
,
outdir
,
threads
)
# Check path to uncompressed files is as expected
...
...
@@ -277,8 +279,9 @@ def test_download_wrongTaxID(caplog):
NCBI_taxid
=
"
10409
"
outdir
=
os
.
path
.
join
(
DATA_TEST_DIR
,
"
test_download_refseq_wrongTaxID
"
)
threads
=
1
levels
=
""
with
pytest
.
raises
(
SystemExit
):
downg
.
download_from_refseq
(
species_linked
,
NCBI_species
,
NCBI_taxid
,
downg
.
download_from_refseq
(
species_linked
,
NCBI_species
,
NCBI_taxid
,
levels
,
outdir
,
threads
)
# Check path to uncompressed files does not exist
...
...
@@ -311,8 +314,9 @@ def test_download_diffSpeTaxID(caplog):
NCBI_taxid
=
"
104099
"
outdir
=
os
.
path
.
join
(
DATA_TEST_DIR
,
"
test_download_refseq_wrongTaxID
"
)
threads
=
1
levels
=
""
with
pytest
.
raises
(
SystemExit
):
downg
.
download_from_refseq
(
species_linked
,
NCBI_species
,
NCBI_taxid
,
downg
.
download_from_refseq
(
species_linked
,
NCBI_species
,
NCBI_taxid
,
levels
,
outdir
,
threads
)
# Check path to uncompressed files does not exist
...
...
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