Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/sourmash_plugin_pangenomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def __init__(self, subparser):
action="store_true",
help="Enable abundance tracking of hashes across rank selection.",
)
p.add_argument(
"--skip-missing-lineages",
action="store_true",
help="Skip empty lineages to write the DB without them"
)
sourmash_utils.add_standard_minhash_args(p)

def main(self, args):
Expand Down Expand Up @@ -239,11 +244,14 @@ def pangenome_createdb_main(args):
break

if lineage_tup is None:
print(f"cannot find ident {ident} in the provided taxonomy ifle.")
print(f"cannot find ident {ident} in the provided taxonomy file.")
print(f"The three closest matches to {ident} are:")
for k in get_close_matches(ident, taxdb):
print(f"* '{k}'")
sys.exit(-1)
if not getattr(args, "skip_missing_lineages", False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you could if not args.skip_missing_lineages - no need to use getattr, since with argparse it will always create the attribute on the args object.

Suggest printing something out for continuing vs failing (i.e. "continuing past error because --skip-missing-lineages is set" or "error exiting!"). Helps people debug!

sys.exit(-1)
else:
continue

lineage_tup = tax_utils.RankLineageInfo(lineage=lineage_tup)
lineage_pair = lineage_tup.lineage_at_rank(args.rank)
Expand Down
Loading