Skip to content

Commit 4d0acf8

Browse files
committed
adding a skipping function to the createdb for empty lineages
1 parent 2a6bd91 commit 4d0acf8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/sourmash_plugin_pangenomics.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ def __init__(self, subparser):
9292
action="store_true",
9393
help="Enable abundance tracking of hashes across rank selection.",
9494
)
95+
p.add_argument(
96+
"--skip-missing-lineages",
97+
action="store_true",
98+
help="Skip empty lineages to write the DB without them"
99+
)
95100
sourmash_utils.add_standard_minhash_args(p)
96101

97102
def main(self, args):
@@ -239,11 +244,14 @@ def pangenome_createdb_main(args):
239244
break
240245

241246
if lineage_tup is None:
242-
print(f"cannot find ident {ident} in the provided taxonomy ifle.")
247+
print(f"cannot find ident {ident} in the provided taxonomy file.")
243248
print(f"The three closest matches to {ident} are:")
244249
for k in get_close_matches(ident, taxdb):
245250
print(f"* '{k}'")
246-
sys.exit(-1)
251+
if not getattr(args, "skip_missing_lineages", False):
252+
sys.exit(-1)
253+
else:
254+
continue
247255

248256
lineage_tup = tax_utils.RankLineageInfo(lineage=lineage_tup)
249257
lineage_pair = lineage_tup.lineage_at_rank(args.rank)

0 commit comments

Comments
 (0)