Skip to content

Commit

Permalink
Fix field types
Browse files Browse the repository at this point in the history
  • Loading branch information
philiptzou committed Jun 16, 2022
1 parent 391f051 commit 276ec39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 5 additions & 7 deletions scripts/csv2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 276ec39

Please sign in to comment.