Skip to content

Commit 1094b8e

Browse files
Mike LeeMike Lee
authored andcommitted
fixing ncbi download commands
1 parent 9330cb5 commit 1094b8e

File tree

9 files changed

+41
-166
lines changed

9 files changed

+41
-166
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
1414
-->
1515

16-
## v1.13.10 (27-Feb-2026)
1716

17+
## v1.13.11 (NOT RELEASED YET)
18+
19+
### Changed
20+
- `bit-update-ncbi-taxonomy` replaced with `get-ncbi-tax-data` (prior still retained for now)
21+
22+
23+
## v1.13.10 (27-Feb-2026)
1824

1925
### Changed
2026
- `bit-get-cov-stats`
@@ -29,7 +35,6 @@
2935
- `bit-filter-seqs-by-length` renamed to `bit-filter-fasta-by-length` to be more specific (prior retained for now)
3036

3137

32-
3338
---
3439

3540
## v1.13.9 (25-Feb-2026)

bit/modules/dl_ncbi_assemblies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from bit.modules.general import (color_text, check_files_are_found,
88
attempt_to_make_dir, report_message)
99
from bit.modules.ncbi.parse_assembly_summary import parse_assembly_summary
10-
from bit.modules.ncbi.get_ncbi_assembly_tables import get_ncbi_assembly_data
10+
from bit.modules.ncbi.get_ncbi_assembly_data import get_ncbi_assembly_data
1111

1212

1313
def dl_ncbi_assemblies(args):
@@ -32,7 +32,7 @@ def preflight_checks(args):
3232
if args.output_dir and not os.path.exists(args.output_dir):
3333
attempt_to_make_dir(args.output_dir)
3434

35-
get_ncbi_assembly_data()
35+
get_ncbi_assembly_data(quiet=True)
3636

3737

3838
def setup(args):

bit/modules/ncbi/get_ncbi_assembly_tables.py renamed to bit/modules/ncbi/get_ncbi_assembly_data.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
import argparse
1111
from datetime import date
12-
from bit.cli.common import CustomRichHelpFormatter
12+
from bit.cli.common import CustomRichHelpFormatter, add_help
1313
from bit.modules.general import (wprint, color_text,
1414
report_message, notify_premature_exit,
1515
download_with_tqdm)
@@ -23,14 +23,18 @@ def main():
2323
parser = argparse.ArgumentParser(
2424
description="This is a bit helper program to download NCBI assembly-summary tables.",
2525
epilog="Ex. usage: `get-ncbi-assembly-tables`",
26-
formatter_class=CustomRichHelpFormatter
26+
formatter_class=CustomRichHelpFormatter,
27+
add_help=False
2728
)
2829

30+
parser.add_argument("-q", "--quiet", help="Exit silently if assembly data already present", action = "store_true")
2931
parser.add_argument("-f", "--force-update", help='Update the stored NCBI assembly tables', action = "store_true")
3032

33+
add_help(parser)
34+
3135
args = parser.parse_args()
3236

33-
get_ncbi_assembly_data(force_update = args.force_update)
37+
get_ncbi_assembly_data(force_update=args.force_update, quiet=args.quiet)
3438

3539
################################################################################
3640

@@ -106,12 +110,17 @@ def download_ncbi_assembly_summary_data(location):
106110
with open(date_retrieved_path, "w") as outfile:
107111
outfile.write(date_retrieved + "\n")
108112

109-
def get_ncbi_assembly_data(force_update=False):
113+
def get_ncbi_assembly_data(force_update=False, quiet=False):
110114

111115
ncbi_dir = check_ncbi_assembly_info_location_var_is_set()
112116
data_present = check_if_data_present(ncbi_dir)
113117

114118
if data_present and not force_update:
119+
if not quiet:
120+
report_message(f"Assembly data already present.")
121+
report_message(f"Check it with `bit-data-locations`, or add `-f` to this program-call to force updating it.")
122+
print()
123+
return
115124
return
116125
else:
117126
download_ncbi_assembly_summary_data(ncbi_dir)

bit/modules/ncbi/get_ncbi_tax_data.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
import argparse
1111
import tarfile
12-
from bit.cli.common import CustomRichHelpFormatter
12+
from bit.cli.common import CustomRichHelpFormatter, add_help
1313
from bit.modules.general import (wprint, color_text, report_message,
1414
notify_premature_exit, download_with_tqdm)
1515

@@ -19,15 +19,19 @@ def main():
1919

2020
parser = argparse.ArgumentParser(
2121
description="This is a bit helper program to download NCBI taxonomy data.",
22-
epilog="Example usage: get-ncbi-tax-data",
23-
formatter_class=CustomRichHelpFormatter
22+
epilog="Example usage: `get-ncbi-tax-data`",
23+
formatter_class=CustomRichHelpFormatter,
24+
add_help=False
2425
)
2526

27+
parser.add_argument("-q", "--quiet", help="Exit silently if tax data already present", action = "store_true")
2628
parser.add_argument("-f", "--force-update", help='Update the stored NCBI taxonomy data', action = "store_true")
2729

30+
add_help(parser)
31+
2832
args = parser.parse_args()
2933

30-
get_ncbi_tax_data(force_update=args.force_update)
34+
get_ncbi_tax_data(force_update=args.force_update, quiet=args.quiet)
3135

3236
################################################################################
3337

@@ -82,12 +86,17 @@ def download_ncbi_tax_data(location):
8286
os.remove(taxdump_path)
8387

8488

85-
def get_ncbi_tax_data(force_update=False):
89+
def get_ncbi_tax_data(force_update=False, quiet = False):
8690

8791
ncbi_data_dir = check_tax_location_var_is_set()
8892
data_present = check_if_data_present(ncbi_data_dir)
8993

9094
if data_present and not force_update:
95+
if not quiet:
96+
report_message(f"Tax data already present.")
97+
report_message(f"Check it with `bit-data-locations`, or add `-f` to this program-call to force updating it.")
98+
print()
99+
return
91100
return
92101
else:
93102
download_ncbi_tax_data(ncbi_data_dir)

bit/scripts/bit-get-lineage-from-taxids

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fi
4747

4848

4949
### checking that ncbi tax data is present already, and downloading if it isn't
50-
helper-bit-get-ncbi-tax-data
50+
get-ncbi-tax-data --quiet
5151

5252
if [ "${include_strain}" = true ]; then
5353
taxonkit_reformat_pattern='{domain|superkingdom}\t{phylum}\t{class}\t{order}\t{family}\t{genus}\t{species}\t{strain|subspecies|no rank}'

bit/scripts/bit-update-ncbi-taxonomy

Lines changed: 0 additions & 25 deletions
This file was deleted.

bit/scripts/helper-bit-get-ncbi-tax-data

Lines changed: 0 additions & 124 deletions
This file was deleted.

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "bit"
7-
version = "1.13.10"
7+
version = "1.13.11"
88
description = "A set of bioinformatics scripts and workflows"
99
readme = "README.md"
1010
license = { text = "GPLv3" }
@@ -24,8 +24,9 @@ bit-version = "bit.modules.general:report_version"
2424

2525
## ncbi-related ##
2626
bit-dl-ncbi-assemblies = "bit.cli.dl_ncbi_assemblies:main"
27-
get-ncbi-assembly-tables = "bit.modules.ncbi.get_ncbi_assembly_tables:main"
27+
get-ncbi-assembly-data = "bit.modules.ncbi.get_ncbi_assembly_data:main"
2828
get-ncbi-tax-data = "bit.modules.ncbi.get_ncbi_tax_data:main"
29+
bit-update-ncbi-taxonomy = "bit.modules.ncbi.get_ncbi_tax_data:main"
2930

3031

3132
## gtdb-related ##

update-conda-package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fi
4545

4646
## getting current version from setup.py (now pyproject.toml)
4747
# version=$(grep "version" setup.py | cut -f 2 -d '=' | tr -d '",')
48-
version=$(grep "version" pyproject.toml | cut -f 2 -d '=' | tr -d '" ')
48+
version=$(grep -w "^version" pyproject.toml | cut -f 2 -d '=' | tr -d '" ')
4949
## getting current build from meta.yaml
5050
build=$(grep -A 1 ^build ${recipe_dir}/meta.yaml | grep number | cut -f 2 -d ":" | tr -s " " "\t" | cut -f 2)
5151

0 commit comments

Comments
 (0)