Skip to content

Commit

Permalink
new script to diff json reports
Browse files Browse the repository at this point in the history
generate diffs between json reports for curator testing
  • Loading branch information
valearna committed Jul 16, 2018
1 parent ee2b21a commit 0b1c9a8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions diff_json_reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3

import argparse
import json


def main():
parser = argparse.ArgumentParser(description="Create diff file between reports in json format")
parser.add_argument('reports', metavar='report_file', type=str, nargs=2, help='report file to diff')

args = parser.parse_args()

old_report = args.reports[0]
new_report = args.reports[1]

old_gene_descs = {}
diff_descs = []

with open(old_report, 'r') as f:
old_report_data = json.load(f)["data"]
for genedesc in old_report_data:
old_gene_descs[genedesc["gene_id"]] = genedesc

with open(new_report, 'r') as f:
new_report_data = json.load(f)["data"]

for genedesc in new_report_data:
if genedesc["description"] != old_gene_descs[genedesc["gene_id"]]["description"]:
diff_descs.append(genedesc)

print(json.dumps(diff_descs, indent=True))


if __name__ == '__main__':
main()

0 comments on commit 0b1c9a8

Please sign in to comment.