-
Notifications
You must be signed in to change notification settings - Fork 0
SQ-837: Refine the sample metadata TSV handling and write user guides #67
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
Merged
Merged
Changes from 114 commits
Commits
Show all changes
126 commits
Select commit
Hold shift + click to select a range
4b9f83b
Add option to show unique samples dimensions CLI
brinkdp a62d232
Add CLI to create metadata TSV from dimensions
brinkdp fc8a8b4
Update user guides with metadata template info
brinkdp db50f85
Enable range filtering for numerical TSV columns
brinkdp b36d09a
Enable inequality filtering on numberical columns
brinkdp be16423
Enable OR filtering for numerical metadata
brinkdp d9b3341
Merge remote-tracking branch 'origin/main' into sample-metadata-funct…
brinkdp 4c5f15d
Propagate metadata query warnings to terminal
brinkdp 678977e
Improve formatting of metadata query warnings
brinkdp f1e798f
Support semicolon-separated values in TSV columns
brinkdp c5b5a1c
Add text on TSV format requirements to user guide
brinkdp 227d4c4
Add text on TSV query syntax
brinkdp cef5a38
Add unit tests for numerical filtering
brinkdp ffbbf56
Handle semicolon-separated numeric values
brinkdp b64ebdb
Add test to assert that mixed-type error is raised
brinkdp 963acdd
Ensure that mixed-type error is propagated to user
brinkdp e58486c
Add tests for string value filters
brinkdp 70ea81d
Add fixture column that only has single values
brinkdp 2719611
Update fixture with SingleString and adapt tests
brinkdp 3730a5c
Add edge-case fixture and tests
brinkdp 628dea6
Drop support of commaa in TSV values
brinkdp 88fdc26
Refactor run_query() into helper methods
brinkdp 15e3205
Allow hyphens in str but not numeric TSV values
brinkdp 746a3b4
Support NOT filters with !
brinkdp aaffc1f
Strip leading/trailing spaces when loading TSV
brinkdp a0ab837
Update metadata user guide after refactoring
brinkdp 7bca287
Update fixture to use other floats than just X.0
brinkdp f3fddaf
Merge remote-tracking branch 'origin/use-typer-recommended-cli-config…
brinkdp 94c223b
Update test assertions for sample metadata queries
brinkdp bc39329
Update metadata template CLI to use pathlib
brinkdp cc74df6
Allow custom name for sample metadata templates
brinkdp 8d648ff
Add draft sample metadata validator command
brinkdp 1cd9d66
Add fixture TSV with incorrect formatting
brinkdp a9bfa9f
Collect all mixed-type cols for a single error
brinkdp 9d9848e
Add unit tests for the TSV validator
brinkdp 6090e97
Add more tests to validator to cover more cases
brinkdp 6b2b6cd
Add section on TSV validator to quick start guide
brinkdp d6795c3
Add section on validator to sidecar metadata docs
brinkdp 82b8d21
Use classmethod in MetadataTSVValidator
brinkdp 3e26c25
Add mkdocs autogen docs for dimensions CLI command
brinkdp 1ba014b
Add text to migration dev docs on branch switching
brinkdp 9c3c4da
Add Sample_ID exceptions in SidecarQueryManager
brinkdp 7aeda1b
Add unit tests for the Sample_ID exceptions
brinkdp 8b2a1e9
Update error/warning handling in validator
brinkdp 8e9d29b
Support negative numbers
brinkdp 6d45005
Update unit tests with negative number cases
brinkdp 058aedc
Add intro to sidecar metadata user guide
brinkdp ea2bcc3
Move dimensions user guide up in the query tree
brinkdp 9c7baec
Add CRUD, pydantic model, route for unique samples
brinkdp ae8928c
Update template and validator command for new CRUD
brinkdp cd09ec7
Use the samples endpoint in dimensions show CLI
brinkdp 74c3aef
Drop duplicate sorting step, already done in CRUD
brinkdp d366456
Add separate endpoint also for --unique-scaffolds
brinkdp b3b9f5c
Clarify difference between API and worker crud
brinkdp e80f5b8
Fix mistake where property call was dropped
brinkdp f9f1269
Add e2e tests for updated dimensions CLI commands
brinkdp 66ea161
Refactor query logic to relax constraints
brinkdp b86d73f
Update e2e and validator unit tests after refactor
brinkdp acfffd8
Update unit tests for SidecarQueryManager
brinkdp f82a6cc
Handle the case of filters like Area:>North
brinkdp b827b81
Print None instead in CLI of [] when no result
brinkdp 57b82d8
Update metadata user guide after refactoring
brinkdp 7c588c6
Ensure all errors from Celery task are propagaged
brinkdp 667c56d
Add e2e test to assert latest errors in terminal
brinkdp a3c31e3
Add e2e tests for other metadata task exceptions
brinkdp cea2778
Harmonize test docstrings
brinkdp 75d03ab
Revert dev doc comment on migrations
brinkdp f20fc43
Fix test assertions sensitive to linebreaks
brinkdp 574d459
Refactor dimensions-bucket check to be more strict
brinkdp eb86f5e
Ensure DivBase results VCF not in updated check
brinkdp 4775237
Have helper also consider VCF file version
brinkdp 9304664
Update tests after helper refactoring
brinkdp 77bfd33
Add test for VCF in bucket not index in dimensions
brinkdp 6c2118d
Allow commas, but send warnings to user
brinkdp 27769f0
Update user guide with info on special characters
brinkdp d76fc31
Add text to some TODOs in the metadata user guide
brinkdp 98f9015
Polish the metadata user guide
brinkdp 8c14483
Apply suggestions from code review
brinkdp b48d25f
Fix additional typos found by copilot review
brinkdp 6fdd4a5
Fix verb conjugation in variable name
brinkdp 562da4d
Prune validator clafication message
brinkdp bd78a05
Update test after updating validator warning msg
brinkdp 2be7adf
Update metadata user guide with results example
brinkdp 0104e57
Ensure same handling of # in validator and queries
brinkdp e21e90f
Refactor TSV validator to a shared logic
brinkdp ce5e27f
Update query overview with sample metadata text
brinkdp d35419e
Add script to print df from TSV using shared logic
brinkdp 3097371
Add checks and warnings for array notation in TSV
brinkdp b97dc21
Add text on bracket array warning to user guide
brinkdp 8452994
Move shared unit test TSV fixtures to conftest.py
brinkdp 7b95999
Add unit test for TSV->df->TSV validation
brinkdp 17268d8
Update mock VCF and metadata scripts
brinkdp 5693686
Merge branch 'pr70' into sample-metadata-functionalities
brinkdp 5816ca5
Update test to not rely on \t in stout
brinkdp 35f73d1
Merge remote-tracking branch 'origin/main' into sample-metadata-funct…
brinkdp 59cfe7b
WIP: refactor shared metadata validator for lists
brinkdp 847c7f9
WIP:make validation results more robust for worker
brinkdp 4468f5e
WIP: refactor query engine for updated validator
brinkdp f2e19d8
Update tests to match refactoring
brinkdp cc40504
Update user guide for sidecar metadata
brinkdp df0caed
Update mkdocs CLI autogen docs on dimensions
brinkdp 801676c
Limit number of samples validator prints to user
brinkdp 467b38c
Make MetadataTSVValidator instance-based instead
brinkdp bf9ff81
Rename class to ClientSideMetadataTSVValidator
brinkdp b05b714
Collate cell values in warnings and errors
brinkdp b65a989
Move validation stats to shared validator
brinkdp 2de17b6
Drop superfluous ClienSideMetadataValidator
brinkdp f43491f
Rename CLI option to --untruncated
brinkdp c1ab0d7
Fix bug that resulted in no stats returned
brinkdp 2d74605
Add dev docs on the metadata query functionalities
brinkdp f6bc9f5
Update mock metadata gen. to use bracket arrarys
brinkdp 3dcc803
Add a few more test cases
brinkdp cb082ec
Update docstrings
brinkdp d41c424
Make an additional docstring update
brinkdp bd8a1b3
Apply suggestions from code review
brinkdp ad79f8b
Merge remote-tracking branch 'origin/main' into sample-metadata-funct…
brinkdp cce66c4
Update CLI autogen docs for dimensions command
brinkdp 237fe38
Update packages/divbase-cli/src/divbase_cli/cli_commands/query_cli.py
brinkdp cb613f1
Update packages/divbase-lib/src/divbase_lib/metadata_validator.py
brinkdp 5e26169
Update types in tsv_to_dataframe script
brinkdp 0aee19e
Make pre-commit happy
brinkdp d8126f3
Update user-facing docstring for dimensions CLI
brinkdp ea2ff33
Use typer Path validations for dimensions commands
brinkdp b3fffdf
Drop the auto-gen dimensions CLI docs
brinkdp eb84afc
Raise errors on filter string on non-existent cols
brinkdp 6c305db
Skip results VCF files by prefix
brinkdp 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Sidecar sample metadata TSV queries | ||
|
|
||
| The query engine for filtering on user-defined sidecar TSVs is centralised around the class `SharedMetadataValidator` in the `divbase-lib` package. This class validated that a sidecar TSV is compatible with DivBase, and is called by the client-side validator and by the server-side query engine (`SidecarQueryManager`). Important to understand is that the `SharedMetadataValidator` was designed to not raise errors or reports warnings: it only collects them. Then the CLI and query engine each acts on the information. | ||
|
|
||
| The client side uses the results from `SharedMetadataValidator` to print stats, errors, and warnings in the user's terminal. | ||
|
|
||
| The server side uses Enums in the `SharedMetadataValidator` results to raise errors and report warnings to the user. This means that the `SidecarQueryManager` only need to be concerned about acting on the Enum and not the error/warning messages themselves, thus avoiding having to rely on (potentially fragile) string-matching. | ||
|
|
||
| The syntax for the TSV and the query fileters is described in the [Sidecar Metadata TSV files: creating and querying sample metadata files](../user-guides/sidecar-metadata.md). | ||
|
|
||
| ## Script to inspect the dataframe | ||
|
|
||
| Despite all the tests, there might be cases where the Pandas dataframe does not look like you'd think after ingesting the TSV. Such issues can be difficult to debug. To help with that this script can be used to calls the `SharedMetadataValidator` dataframe logic for TSV ingestion and print the Pandas dataframe to terminal: | ||
|
|
||
| ```bash | ||
| python scripts/tsv_to_dataframe.py --tsv path/to/metadata.tsv | ||
|
|
||
| # Try it with example fixture | ||
| python scripts/tsv_to_dataframe.py --tsv tests/fixtures/sample_metadata.tsv | ||
| ``` |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| # DivBase Query Syntax for VCF data | ||
|
|
||
| TODO | ||
|
|
||
| ## combined sample metadata and VCF queries | ||
|
|
||
| TODO - there is a link to here from the sample metadata guide, so the combined queries should be described in detail here | ||
|
|
||
| It is also possible to run a sidecar sample metadata query as part of a VCF query by adding the query as a sting to the flag `--tsv-filter`: | ||
|
|
||
| ```bash | ||
| divbase-cli query bcftools-pipe --tsv-filter "Area:North" --command "view -s SAMPLES" | ||
| ``` |
This file contains hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.