Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --keep-invalid Flag for LCA #35

Merged
merged 7 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ dependencies:
- pytest>=5.4
- pytest-cov>=2.8
- pytest-xdist>=1.31
- taxonkit>=0.8
- taxonkit>=0.16.0
- wget>=1.20
14 changes: 14 additions & 0 deletions pytaxonkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@ def lca(
multi=False,
skip_deleted=False,
skip_unfound=False,
keep_invalid=False,
threads=None,
data_dir=None,
debug=False,
Expand All @@ -1063,6 +1064,8 @@ def lca(
Ignore deleted taxids and compute LCA with the remaining taxa
skip_unfound : bool, default False
Ignore taxids not found in the taxonomy database and compute LCA with the remaining taxa
keep_invalid: bool, default False
Returns 0 when all taxids have been skipped from `skip_deleted` or `skip_unfound`
threads : int
Override the default taxonkit threads setting
data_dir : str, default None
Expand Down Expand Up @@ -1096,6 +1099,8 @@ def lca(
arglist.append("--skip-deleted")
if skip_unfound:
arglist.append("--skip-unfound")
if keep_invalid:
arglist.append("--keep-invalid")
if threads:
arglist.extend(("--threads", validate_threads(threads)))
if data_dir:
Expand Down Expand Up @@ -1134,6 +1139,15 @@ def test_lca_unfound(capsys):
assert "taxonkit lca --skip-unfound" in terminal.err


def test_lca_keep_invalid(capsys):
assert lca([11111111], skip_deleted=True, skip_unfound=True) == None
assert lca([22222222], skip_deleted=True, skip_unfound=True) == None
Copy link
Member

Choose a reason for hiding this comment

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

Minor quibble: is None instead of == None.

assert lca([11111111], skip_deleted=True, skip_unfound=True, keep_invalid=True) == 0
assert lca([11111111, 22222222], skip_deleted=True, skip_unfound=True, keep_invalid=True, debug=True) == 0
terminal = capsys.readouterr()
assert "taxonkit lca --skip-deleted --skip-unfound --keep-invalid" in terminal.err


@pytest.mark.parametrize(
"domulti, ids,result",
[
Expand Down