-
Notifications
You must be signed in to change notification settings - Fork 130
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 #1746 from nextstrain/fix-metadata-index-dtype
io/read_metadata: Fix dtype for the index column
- Loading branch information
Showing
4 changed files
with
158 additions
and
1 deletion.
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
34 changes: 34 additions & 0 deletions
34
tests/functional/export_v2/cram/metadata-with-float-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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Setup | ||
|
||
$ source "$TESTDIR"/_setup.sh | ||
|
||
Create files for testing. | ||
|
||
$ cat >metadata.tsv <<~~ | ||
> strain field_A field_B | ||
> 1.00 AA AAA | ||
> 2.00 BB BBB | ||
> 3.00 CC CCC | ||
> 4.00 DD DDD | ||
> 5.00 EE EEE | ||
> 6.00 FF FFF | ||
> ~~ | ||
|
||
$ cat >tree.nwk <<~~ | ||
> (1.00:1,(2.00:1,3.00:1)internalBC:2,(4.00:3,5.00:4,6.00:1)internalDEF:5)ROOT:0; | ||
> ~~ | ||
|
||
Run export with tree and metadata with additional columns. | ||
The metadata should match with the tree even though the names are floats | ||
because we force the index column to be strings. | ||
|
||
$ ${AUGUR} export v2 \ | ||
> --tree tree.nwk \ | ||
> --metadata metadata.tsv \ | ||
> --metadata-columns "field_A" "field_B" \ | ||
> --maintainers "Nextstrain Team" \ | ||
> --output dataset.json > /dev/null | ||
|
||
$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/dataset-with-float-strains.json" dataset.json \ | ||
> --exclude-paths "root['meta']['updated']" "root['meta']['maintainers']" | ||
{} |
121 changes: 121 additions & 0 deletions
121
tests/functional/export_v2/data/dataset-with-float-strains.json
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,121 @@ | ||
{ | ||
"version": "v2", | ||
"meta": { | ||
"updated": "2025-02-06", | ||
"maintainers": [ | ||
{ | ||
"name": "Nextstrain Team" | ||
} | ||
], | ||
"colorings": [], | ||
"filters": [], | ||
"panels": [ | ||
"tree" | ||
] | ||
}, | ||
"tree": { | ||
"name": "ROOT", | ||
"node_attrs": { | ||
"div": 0 | ||
}, | ||
"branch_attrs": {}, | ||
"children": [ | ||
{ | ||
"name": "1.00", | ||
"node_attrs": { | ||
"div": 1.0, | ||
"field_A": { | ||
"value": "AA" | ||
}, | ||
"field_B": { | ||
"value": "AAA" | ||
} | ||
}, | ||
"branch_attrs": {} | ||
}, | ||
{ | ||
"name": "internalBC", | ||
"node_attrs": { | ||
"div": 2.0 | ||
}, | ||
"branch_attrs": {}, | ||
"children": [ | ||
{ | ||
"name": "2.00", | ||
"node_attrs": { | ||
"div": 3.0, | ||
"field_A": { | ||
"value": "BB" | ||
}, | ||
"field_B": { | ||
"value": "BBB" | ||
} | ||
}, | ||
"branch_attrs": {} | ||
}, | ||
{ | ||
"name": "3.00", | ||
"node_attrs": { | ||
"div": 3.0, | ||
"field_A": { | ||
"value": "CC" | ||
}, | ||
"field_B": { | ||
"value": "CCC" | ||
} | ||
}, | ||
"branch_attrs": {} | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "internalDEF", | ||
"node_attrs": { | ||
"div": 5.0 | ||
}, | ||
"branch_attrs": {}, | ||
"children": [ | ||
{ | ||
"name": "4.00", | ||
"node_attrs": { | ||
"div": 8.0, | ||
"field_A": { | ||
"value": "DD" | ||
}, | ||
"field_B": { | ||
"value": "DDD" | ||
} | ||
}, | ||
"branch_attrs": {} | ||
}, | ||
{ | ||
"name": "5.00", | ||
"node_attrs": { | ||
"div": 9.0, | ||
"field_A": { | ||
"value": "EE" | ||
}, | ||
"field_B": { | ||
"value": "EEE" | ||
} | ||
}, | ||
"branch_attrs": {} | ||
}, | ||
{ | ||
"name": "6.00", | ||
"node_attrs": { | ||
"div": 6.0, | ||
"field_A": { | ||
"value": "FF" | ||
}, | ||
"field_B": { | ||
"value": "FFF" | ||
} | ||
}, | ||
"branch_attrs": {} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |