Skip to content

Commit

Permalink
Merge pull request #669 from nextstrain/fix-numeric-names
Browse files Browse the repository at this point in the history
ensure columns strain and name in metadata are parsed as string
  • Loading branch information
huddlej authored Feb 12, 2021
2 parents b2a313c + f266805 commit fa5fa43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions augur/util_support/metadata_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ def parse_file(self):
sep=None, # csv.Sniffer will automatically detect sep
engine="python",
skipinitialspace=True,
dtype={"strain":"string", "name":"string"}
).fillna("")
12 changes: 12 additions & 0 deletions tests/util_support/test_metadata_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,15 @@ def test_metadata_delimiter_autodetect(self, tmpdir, prepare_file):
"strainB": {"strain": "strainB", "location": "nevada", "quality": "good"},
}
assert list(columns) == ["strain", "location", "quality"]

def test_metadata_strain_type(self, tmpdir, prepare_file):
prepare_file(
"""
strain\tlocation
1\tWashington
2\tOregon
"""
)

records, columns = MetadataFile(f"{tmpdir}/metadata.txt").read()
assert "1" in records

0 comments on commit fa5fa43

Please sign in to comment.