Skip to content

Commit

Permalink
Merge pull request #22 from metagenlab/dev
Browse files Browse the repository at this point in the history
Release 0.7.7
  • Loading branch information
farchaab authored Aug 28, 2024
2 parents 9178550 + 952987f commit 529ae94
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
matrix:
python-version: ["3.12"]
fail-fast: false
name: Linux Python ${{ matrix.python-version }}
name: Linux
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
python-version: ["3.12"]
architecture: ["x64"]
fail-fast: false
name: OSX Python ${{ matrix.python-version }}
name: OSX
steps:
- uses: actions/checkout@v4
with:
Expand Down
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ LABEL org.opencontainers.image.source=https://github.com/metagenlab/assembly_fin
LABEL org.opencontainers.image.description="Snakemake-powered cli to download genomes with NCBI datasets"
LABEL org.opencontainers.image.licenses=MIT
ENV LANG=C.UTF-8
ENV SHELL=/bin/bash
ENV SHELL=/bin/bash

USER root
ENV APT_PKGS="curl rsync p7zip-full procps"
RUN apt-get update \
&& apt-get install -y --no-install-recommends ${APT_PKGS} \
&& apt-get clean \
&& rm -rf /var/lib/apt /var/lib/dpkg /var/lib/cache /var/lib/log
USER $MAMBA_USER

COPY --chown=$MAMBA_USER:$MAMBA_USER . /pkg
RUN micromamba config set extract_threads 1 && \
Expand Down
2 changes: 1 addition & 1 deletion assembly_finder/assembly_finder.VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.6
0.7.7
1 change: 1 addition & 0 deletions assembly_finder/workflow/rules/download.smk
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ rule filter_genome_summaries:
params:
rank=RANK,
nrank=NRANK,
taxon=TAXON,
script:
os.path.join(dir.scripts, "select_assemblies.py")

Expand Down
29 changes: 17 additions & 12 deletions assembly_finder/workflow/rules/functions.smk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def convert_query(wildcards):
("GCF" not in wildcards.query) and ("GCA" not in wildcards.query)
):
return wildcards.query.replace("_", " ")
else:
return wildcards.query


def get_limit(wildcards, nbs, dic):
Expand All @@ -44,18 +46,21 @@ KEY = ""
if API_KEY:
KEY += f"--api-key {API_KEY} "
ARGS = ""
if ANNOTATED:
ARGS += "--annotated "
if ASM_LVL:
ARGS += f"--assembly-level {ASM_LVL} "
if SOURCE:
ARGS += f"--assembly-source {SOURCE} "
if ATYPICAL:
ARGS += "--exclude-atypical "
if MAG:
ARGS += f"--mag {MAG} "
if REFERENCE:
ARGS += "--reference "
if not TAXON:
ARGS = ""
else:
if ANNOTATED:
ARGS += "--annotated "
if ASM_LVL:
ARGS += f"--assembly-level {ASM_LVL} "
if SOURCE:
ARGS += f"--assembly-source {SOURCE} "
if ATYPICAL:
ARGS += "--exclude-atypical "
if MAG:
ARGS += f"--mag {MAG} "
if REFERENCE:
ARGS += "--reference "
GZIP = ""
if COMPRESSED:
GZIP = "--gzip"
Expand Down
4 changes: 4 additions & 0 deletions assembly_finder/workflow/scripts/select_assemblies.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def read_json(file):
# Params
rank = snakemake.params.rank
nrank = snakemake.params.nrank
taxon = snakemake.params.taxon

# format summary column names
summary_df.columns = (
Expand Down Expand Up @@ -73,6 +74,9 @@ def read_json(file):
"species",
]

if taxon:
tax_cols.insert(0, "taxon")

df[tax_cols].to_csv(snakemake.output.tax, sep="\t", index=None)
df[summary_df.columns].to_csv(snakemake.output.gen, sep="\t", index=None)
df[["accession"]].drop_duplicates().to_csv(
Expand Down
3 changes: 0 additions & 3 deletions env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ dependencies:
- ncbi-datasets-cli =16.26.2
- taxonkit =0.17.0
- csvtk =0.30.0
- rsync =3.3.0
- curl =8.7.1
- p7zip =16.02
- python =3.12
- pip
- snakemake-minimal =8.18.1
Expand Down
24 changes: 20 additions & 4 deletions tests/test_assembly_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,31 @@ def test_cli():
exec_command("assembly_finder -v")


def test_taxons():
"""download genomes from taxons"""
def test_taxon_string():
"""download genomes from string input"""
exec_command(
f"assembly_finder --threads {threads} -i bacteria -nb 1 --output {outdir}"
)
remove_directory(outdir)


def test_accession_string():
"""download genomes from string input"""
exec_command(
f"assembly_finder --threads {threads} -i GCF_000418345.1 --accession --output {outdir}"
)
remove_directory(outdir)


def test_taxons_file():
"""download genomes from taxons file"""
input = os.path.join(test_data_path, "taxons.tsv")
exec_command(f"assembly_finder --threads {threads} -i {input} --output {outdir}")
remove_directory(outdir)


def test_accessions():
"""download genomes from accessions"""
def test_accessions_file():
"""download genomes from accessions file"""
input = os.path.join(test_data_path, "accessions.txt")
exec_command(
f"assembly_finder --threads {threads} -i {input} --accession --output {outdir}"
Expand Down

0 comments on commit 529ae94

Please sign in to comment.