-
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.
filter: Update working directory of cram tests
$TMP is the test runner's temp directory, which is shared across all individual tests¹. This means files must be removed before running the next test to ensure a clean slate. On the other hand, the initial working directory of each test² is a directory within $TMP which is truly temporary per test file. I updated all tests to use this initial working directory as a temporary directory. A summary of the changes: 1. Change the working directory from "$TESTDIR/../../" (tests/functional/) to the default initial working directory. 2. Update references to files in tests/functional/filter/data, since those had relied on the parent folder as the working directory. 3. Remove directory changes in the "setup" section, simplifying that to one command creating the AUGUR alias relative to $TESTDIR. 4. Remove rm commands used to clean up output files, since the working directory is a per-test temporary directory. 5. filter-metadata-sequence-strains-mismatch.t: Update the diff check to a direct check of file contents, since the resolved $TESTDIR must be matched by regex. ¹ https://github.com/brodie/cram/blob/61212ab78a88ce4a18eee4e26c89bfe086b28e78/cram/_main.py#L185 ² https://github.com/brodie/cram/blob/61212ab78a88ce4a18eee4e26c89bfe086b28e78/cram/_run.py#L67-L70
- Loading branch information
Showing
34 changed files
with
250 additions
and
300 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,17 +1,15 @@ | ||
Setup | ||
|
||
$ pushd "$TESTDIR" > /dev/null | ||
$ source _setup.sh | ||
$ export AUGUR="$TESTDIR/../../../../bin/augur" | ||
|
||
Filter with exclude query for two regions that comprise all but one strain. | ||
This filter should leave a single record from Oceania. | ||
Force include one South American record by country to get two total records. | ||
|
||
$ ${AUGUR} filter \ | ||
> --metadata filter/data/metadata.tsv \ | ||
> --metadata "$TESTDIR/../data/metadata.tsv" \ | ||
> --exclude-where "region=South America" "region=North America" "region=Southeast Asia" \ | ||
> --include-where "country=Ecuador" \ | ||
> --output-strains "$TMP/filtered_strains.txt" > /dev/null | ||
$ wc -l "$TMP/filtered_strains.txt" | ||
> --output-strains filtered_strains.txt > /dev/null | ||
$ wc -l filtered_strains.txt | ||
\s*2 .* (re) | ||
$ rm -f "$TMP/filtered_strains.txt" |
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
5 changes: 2 additions & 3 deletions
5
tests/functional/filter/cram/filter-metadata-not-found-error.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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
Setup | ||
|
||
$ pushd "$TESTDIR" > /dev/null | ||
$ source _setup.sh | ||
$ export AUGUR="$TESTDIR/../../../../bin/augur" | ||
|
||
Try to filter on an metadata file that does not exist. | ||
|
||
$ ${AUGUR} filter \ | ||
> --metadata file-does-not-exist.tsv \ | ||
> --group-by year month \ | ||
> --sequences-per-group 1 \ | ||
> --output-strains "$TMP/filtered_strains.txt" > /dev/null | ||
> --output-strains filtered_strains.txt > /dev/null | ||
ERROR: No such file or directory: 'file-does-not-exist.tsv' | ||
[2] |
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 |
---|---|---|
@@ -1,13 +1,11 @@ | ||
Setup | ||
|
||
$ pushd "$TESTDIR" > /dev/null | ||
$ source _setup.sh | ||
$ export AUGUR="$TESTDIR/../../../../bin/augur" | ||
|
||
Filter using only metadata without a sequence index. | ||
This should work because the requested filters don't rely on sequence information. | ||
|
||
$ ${AUGUR} filter \ | ||
> --metadata filter/data/metadata.tsv \ | ||
> --metadata "$TESTDIR/../data/metadata.tsv" \ | ||
> --min-date 2012 \ | ||
> --output-strains "$TMP/filtered_strains.txt" > /dev/null | ||
$ rm -f "$TMP/filtered_strains.txt" | ||
> --output-strains filtered_strains.txt > /dev/null |
7 changes: 3 additions & 4 deletions
7
tests/functional/filter/cram/filter-min-length-no-sequence-index-error.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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
Setup | ||
|
||
$ pushd "$TESTDIR" > /dev/null | ||
$ source _setup.sh | ||
$ export AUGUR="$TESTDIR/../../../../bin/augur" | ||
|
||
Try to filter using only metadata without a sequence index. | ||
This should fail because the requested filters rely on sequence information. | ||
|
||
$ ${AUGUR} filter \ | ||
> --metadata filter/data/metadata.tsv \ | ||
> --metadata "$TESTDIR/../data/metadata.tsv" \ | ||
> --min-length 10000 \ | ||
> --output-strains "$TMP/filtered_strains.txt" > /dev/null | ||
> --output-strains filtered_strains.txt > /dev/null | ||
ERROR: You need to provide a sequence index or sequences to filter on sequence-specific information. | ||
[2] |
13 changes: 6 additions & 7 deletions
13
tests/functional/filter/cram/filter-min-length-output-metadata.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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
Setup | ||
|
||
$ pushd "$TESTDIR" > /dev/null | ||
$ source _setup.sh | ||
$ export AUGUR="$TESTDIR/../../../../bin/augur" | ||
|
||
Filter using only metadata without sequence input or output and save results as filtered metadata. | ||
|
||
$ ${AUGUR} filter \ | ||
> --sequence-index filter/data/sequence_index.tsv \ | ||
> --metadata filter/data/metadata.tsv \ | ||
> --sequence-index "$TESTDIR/../data/sequence_index.tsv" \ | ||
> --metadata "$TESTDIR/../data/metadata.tsv" \ | ||
> --min-date 2012 \ | ||
> --min-length 10500 \ | ||
> --output-metadata "$TMP/filtered_metadata.tsv" > /dev/null | ||
> --output-metadata filtered_metadata.tsv > /dev/null | ||
|
||
Output should include the 8 sequences matching the filters and a header line. | ||
|
||
$ wc -l "$TMP/filtered_metadata.tsv" | ||
$ wc -l filtered_metadata.tsv | ||
\s*9 .* (re) | ||
$ rm -f "$TMP/filtered_metadata.tsv" | ||
$ rm -f filtered_metadata.tsv |
12 changes: 5 additions & 7 deletions
12
tests/functional/filter/cram/filter-min-length-output-strains.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 |
---|---|---|
@@ -1,19 +1,17 @@ | ||
Setup | ||
|
||
$ pushd "$TESTDIR" > /dev/null | ||
$ source _setup.sh | ||
$ export AUGUR="$TESTDIR/../../../../bin/augur" | ||
|
||
Filter using only metadata and save results as a list of filtered strains. | ||
|
||
$ ${AUGUR} filter \ | ||
> --sequence-index filter/data/sequence_index.tsv \ | ||
> --metadata filter/data/metadata.tsv \ | ||
> --sequence-index "$TESTDIR/../data/sequence_index.tsv" \ | ||
> --metadata "$TESTDIR/../data/metadata.tsv" \ | ||
> --min-date 2012 \ | ||
> --min-length 10500 \ | ||
> --output-strains "$TMP/filtered_strains.txt" > /dev/null | ||
> --output-strains filtered_strains.txt > /dev/null | ||
|
||
Output should include only the 8 sequences matching the filters (without a header line). | ||
|
||
$ wc -l "$TMP/filtered_strains.txt" | ||
$ wc -l filtered_strains.txt | ||
\s*8 .* (re) | ||
$ rm -f "$TMP/filtered_strains.txt" |
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
Oops, something went wrong.