-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b294360
commit bbaf1ba
Showing
2 changed files
with
37 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import json | ||
from os.path import join, dirname | ||
|
||
|
||
RAW_GDC_PATH = join(dirname(__file__), "./gdc_schema.json") | ||
FORMATTED_GDC_PATH = join(dirname(__file__), "../bdikit/resource/gdc_data.json") | ||
|
||
metadata = {} | ||
|
||
|
||
with open(RAW_GDC_PATH) as json_file: | ||
gdc_schema = json.load(json_file) | ||
|
||
for attrib_data in gdc_schema.values(): | ||
for attrib_name, attrib_properties in attrib_data["properties"].items(): | ||
metadata[attrib_name] = {} | ||
attrib_description = attrib_properties.get("description", "") | ||
metadata[attrib_name]["column_description"] = attrib_description | ||
|
||
value_names = attrib_properties.get("enum", []) | ||
# metadata[attrib_name]["value_names"] = value_names | ||
|
||
descriptions = attrib_properties.get("enumDef", {}) | ||
value_descriptions = [] | ||
for value_name in value_names: | ||
description = "" | ||
if value_name in descriptions: | ||
description = descriptions[value_name].get("description", "") | ||
value_descriptions.append(description) | ||
|
||
metadata[attrib_name]["value_data"] = dict(zip(value_names, value_descriptions)) | ||
|
||
with open(FORMATTED_GDC_PATH, "w") as f: | ||
json.dump(metadata, f, indent=4) | ||
|
||
print("GDC schema formatted successfully.") |
Large diffs are not rendered by default.
Oops, something went wrong.