From 276ec39314d10a1c4f82947c9b0c59292e568bab Mon Sep 17 00:00:00 2001 From: Philip Tzou Date: Sun, 1 May 2022 13:44:48 -0700 Subject: [PATCH] Fix field types --- Makefile | 7 ++++++- scripts/csv2json.py | 12 +++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index fbf7866..7ed856a 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,27 @@ +data/drms_*.json: scripts/drms_csv2json.py data/drms_%.json: data/drms_%.csv @pipenv run python scripts/drms_csv2json.py $< +data/mutation-type-pairs_*.json: scripts/csv2json.py data/mutation-type-pairs_%.json: data/mutation-type-pairs_%.csv @pipenv run python scripts/csv2json.py $< +data/apobec*/apobecs.json: scripts/csv2json.py data/apobec%/apobecs.json: data/apobec%/apobecs.csv @pipenv run python scripts/csv2json.py $< +data/apobec*/apobec_drms.json: scripts/csv2json.py data/apobec%/apobec_drms.json: data/apobec%/apobec_drms.csv @pipenv run python scripts/csv2json.py $< +data/aapcnt/rx-all_subtype-*.json: scripts/csv2json.py data/aapcnt/rx-all_subtype-%.json: data/aapcnt/rx-all_subtype-%.csv @pipenv run python scripts/csv2json.py $< data/%.json: data/%.yml @pipenv run python scripts/yaml2json.py $< -data: data/*.json data/apobecs/*.json data/apobecs-hiv2/*.json +data: data/*.json data/apobecs/*.json data/apobecs-hiv2/*.json data/aapcnt/*.json refresh-yamls: @pipenv run python scripts/yaml2json.py diff --git a/scripts/csv2json.py b/scripts/csv2json.py index be6ae74..53a4592 100644 --- a/scripts/csv2json.py +++ b/scripts/csv2json.py @@ -17,15 +17,13 @@ def main(): for row in rows: if 'position' in row: row['position'] = int(row['position']) - elif 'percent' in row: - row['percent'] = float(row['float']) - elif 'count' in row: + if 'percent' in row: + row['percent'] = float(row['percent']) + if 'count' in row: row['count'] = int(row['count']) - elif 'total' in row: + if 'total' in row: row['total'] = int(row['total']) - elif 'isUnusual' in row: - row['isUnusual'] = row['isUnusual'].lower() == 'true' - elif 'isUnusual' in row: + if 'isUnusual' in row: row['isUnusual'] = row['isUnusual'].lower() == 'true' json.dump(rows, out, indent=2) print('Write to', out.name)