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

[MRG] fix tax argument parsing #2218

Merged
merged 15 commits into from
Aug 29, 2022
Merged

[MRG] fix tax argument parsing #2218

merged 15 commits into from
Aug 29, 2022

Conversation

bluegenes
Copy link
Contributor

@bluegenes bluegenes commented Aug 16, 2022

Most of the tax subcommands take multiple inputs via -g/--gather-csv and -t/--taxonomy-csv, but currently the later inputs override earlier inputs, e.g. -g gather1.csv -g gather2.csv will result in just gather2.csv being loaded. This PR fixes that by using argparse extend appropriately, and adds tests throughout.

This PR also fixes the --force argument so that it is properly passed into MultiLineageDB.load for taxonomy loading, and also properly used in gather loading.

Fixes #2213

Notes from testing

Testing the argparse action='extend' stuff systematically was tricky and annoying. I ended up adding a bunch of tests where I relied on two pieces of behavior -

So I would call something like sourmash tax prepare ... -t good_tax -t empty_tax --force.

If argparse was set up correctly, good_tax would be loaded, and empty_tax would be ignored.

If argparse was set up incorrectly, good_tax would be ignored, and only empty_tax would be received, but because it was empty, a later check (for non-empty taxonomies) would fail. Voila!

Finally, I verified that if I removed action='extend' from argparse options for the -g and -t arguments, at least one test failed. 🎉

TODO

  • add action= 'extend' to appropriate args
  • test annotate
  • test prepare
  • test grep
  • test genome
  • test metagenome

@codecov
Copy link

codecov bot commented Aug 16, 2022

Codecov Report

Merging #2218 (92226e7) into latest (bc5ae03) will increase coverage by 7.31%.
The diff coverage is 90.00%.

@@            Coverage Diff             @@
##           latest    #2218      +/-   ##
==========================================
+ Coverage   84.76%   92.08%   +7.31%     
==========================================
  Files         131      100      -31     
  Lines       15619    11350    -4269     
  Branches     2236     2240       +4     
==========================================
- Hits        13240    10452    -2788     
+ Misses       2085      608    -1477     
+ Partials      294      290       -4     
Flag Coverage Δ
python 92.08% <90.00%> (-0.03%) ⬇️
rust ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/sourmash/cli/tax/annotate.py 100.00% <ø> (ø)
src/sourmash/cli/tax/grep.py 100.00% <ø> (ø)
src/sourmash/cli/tax/prepare.py 100.00% <ø> (ø)
src/sourmash/tax/__main__.py 92.63% <ø> (+2.32%) ⬆️
src/sourmash/tax/tax_utils.py 98.46% <83.33%> (+0.16%) ⬆️
src/sourmash/cli/tax/genome.py 90.90% <100.00%> (+0.58%) ⬆️
src/sourmash/cli/tax/metagenome.py 90.00% <100.00%> (+0.71%) ⬆️
src/sourmash/sbt_storage.py 85.76% <0.00%> (-3.39%) ⬇️
src/core/src/index/sbt/mhbt.rs
src/core/tests/test.rs
... and 31 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ctb
Copy link
Contributor

ctb commented Aug 25, 2022

7a655cd implemented --force in taxonomy loading.

gotta add a few more tests and this will be fully baked.

@ctb ctb changed the title [WIP] fix tax argument parsing [MRG] fix tax argument parsing Aug 29, 2022
@ctb
Copy link
Contributor

ctb commented Aug 29, 2022

This should be ready for review @bluegenes!

Note, I took it over from you so github won't care if you approve it, but that's ok, once you like it I'll merge it with admin superpower.

Copy link
Contributor Author

@bluegenes bluegenes left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for taking over @ctb!

(gh won't let me approve, but ...I approve :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

specifying multiple lineages for sourmash tax commands
2 participants