-
Notifications
You must be signed in to change notification settings - Fork 2
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,13 @@ jobs: | |
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
python-version: 3.7 | ||
python-version: "3.8" | ||
- os: ubuntu-latest | ||
python-version: 3.8 | ||
python-version: "3.9" | ||
- os: ubuntu-latest | ||
python-version: 3.9 | ||
- os: macos-latest | ||
python-version: 3.8 | ||
python-version: "3.10" | ||
# - os: macos-latest | ||
# python-version: "3.9" | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: conda-incubator/setup-miniconda@v2 | ||
|
@@ -36,7 +36,7 @@ jobs: | |
run: | | ||
mkdir ~/.taxonkit | ||
pushd ~/.taxonkit | ||
curl -L -O ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz | ||
curl -L -O https://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The MacOS build kept on failing, unable to download the taxonomy DB. This was an attempt at troubleshooting. |
||
tar -xzf taxdump.tar.gz | ||
popd | ||
- name: Install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,10 +339,10 @@ def lineage( | |
>>> result.columns | ||
Index(['TaxID', 'Code', 'Name', 'Lineage', 'LineageTaxIDs', 'Rank', 'FullLineage', 'FullLineageTaxIDs', 'FullLineageRanks'], dtype='object') | ||
>>> result[["TaxID", "Lineage", "LineageTaxIDs"]] | ||
TaxID Lineage LineageTaxIDs | ||
0 1325911 Eukaryota;Arthropoda;Insecta;Hymenoptera;Eucharitidae;Pogonocharis; 2759;6656;50557;7399;216140;1325911; | ||
1 1649473 Bacteria;Bacteroidota;Cytophagia;Cytophagales;Spirosomaceae;Nibrella; 2;976;768503;768507;2896860;1649473; | ||
2 1401311 Eukaryota;Arthropoda;Insecta;Coleoptera;Staphylinidae;Styngetus; 2759;6656;50557;7041;29026;1401311; | ||
TaxID Lineage LineageTaxIDs | ||
0 1325911 Eukaryota;Arthropoda;Insecta;Hymenoptera;Eucharitidae;Pogonocharis; 2759;6656;50557;7399;216140;1325911; | ||
1 1649473 Bacteria;Bacteroidota;Cytophagia;Cytophagales;Spirosomataceae;Nibrella; 2;976;768503;768507;2896860;1649473; | ||
2 1401311 Eukaryota;Arthropoda;Insecta;Coleoptera;Staphylinidae;Styngetus; 2759;6656;50557;7041;29026;1401311; | ||
Comment on lines
-342
to
+345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better update your taxonomy DB 🙃 |
||
>>> result = pytaxonkit.lineage(["1382510", "929505", "390333"], formatstr="{f};{g};{s};{S}") | ||
>>> result[["TaxID", "Lineage", "LineageTaxIDs"]] | ||
TaxID Lineage LineageTaxIDs | ||
|
@@ -1046,6 +1046,7 @@ def lca( | |
multi=False, | ||
skip_deleted=False, | ||
skip_unfound=False, | ||
keep_invalid=False, | ||
threads=None, | ||
data_dir=None, | ||
debug=False, | ||
|
@@ -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 | ||
|
@@ -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: | ||
|
@@ -1134,6 +1139,36 @@ def test_lca_unfound(capsys): | |
assert "taxonkit lca --skip-unfound" in terminal.err | ||
|
||
|
||
def test_lca_keep_invalid_single(capsys): | ||
assert lca([11111111], skip_deleted=True, skip_unfound=True) is None | ||
assert lca([22222222], skip_deleted=True, skip_unfound=True) is None | ||
assert lca([11111111], skip_deleted=True, skip_unfound=True, keep_invalid=True) == 0 | ||
result = lca( | ||
[11111111, 22222222], | ||
skip_deleted=True, | ||
skip_unfound=True, | ||
keep_invalid=True, | ||
debug=True, | ||
) | ||
assert result == 0 | ||
terminal = capsys.readouterr() | ||
assert "taxonkit lca --skip-deleted --skip-unfound --keep-invalid" in terminal.err | ||
|
||
|
||
def test_lca_keep_invalid_multi(): | ||
query = [ | ||
[743375], | ||
[123456789], | ||
[987654321], | ||
[743375, 123456789], | ||
[743375, 987654321], | ||
[123456789, 987654321], | ||
] | ||
observed = lca(query, skip_deleted=True, skip_unfound=True, keep_invalid=True, multi=True) | ||
expected = [743375, 0, 0, 743375, 743375, 0] | ||
assert expected == observed | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"domulti, ids,result", | ||
[ | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ended up dropping the MacOS build. 🙁