-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1175 from nextstrain/filter-empty-results
filter: Add --empty-results-reporting={error,warn,skip} option
- Loading branch information
Showing
6 changed files
with
119 additions
and
15 deletions.
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
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
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
46 changes: 46 additions & 0 deletions
46
tests/functional/filter/cram/filter-empty-output-reporting.t
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Setup | ||
|
||
$ source "$TESTDIR"/_setup.sh | ||
|
||
Filter using `--exclude-all` to easily get an empty result. | ||
|
||
Test the default behavior for empty results is an error. | ||
|
||
$ ${AUGUR} filter \ | ||
> --metadata "$TESTDIR/../data/metadata.tsv" \ | ||
> --exclude-all \ | ||
> --output-strains filtered_strains.txt > /dev/null | ||
ERROR: All samples have been dropped! Check filter rules and metadata file format. | ||
[2] | ||
$ wc -l filtered_strains.txt | ||
\s*0 .* (re) | ||
|
||
Repeat with the --empty-output-reporting=warn option. | ||
This whould output a warning message but no error. | ||
|
||
$ ${AUGUR} filter \ | ||
> --metadata "$TESTDIR/../data/metadata.tsv" \ | ||
> --exclude-all \ | ||
> --output-strains filtered_strains.txt \ | ||
> --empty-output-reporting warn > /dev/null | ||
WARNING: All samples have been dropped! Check filter rules and metadata file format. | ||
$ wc -l filtered_strains.txt | ||
\s*0 .* (re) | ||
|
||
Ignore empty results with the --empty-output-reporting=silent option. | ||
Make sure all 3 output types are empty, except the metadata output should still include the header. | ||
This should not output any messages to stderr. | ||
|
||
$ ${AUGUR} filter \ | ||
> --metadata "$TESTDIR/../data/metadata.tsv" \ | ||
> --sequences "$TESTDIR/../data/sequences.fasta" \ | ||
> --exclude-all \ | ||
> --output-sequences filtered_seqs.fasta \ | ||
> --output-metadata filtered_metadata.tsv \ | ||
> --output-strains filtered_strains.txt \ | ||
> --empty-output-reporting silent > /dev/null | ||
$ wc -l filtered_seqs.fasta | ||
\s*0 .* (re) | ||
$ diff <(head -n 1 filtered_metadata.tsv) <(head -n 1 "$TESTDIR/../data/metadata.tsv") | ||
$ wc -l filtered_strains.txt | ||
\s*0 .* (re) |
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