import os
import json

summary = []

files = [e for e in os.listdir('.') if e.endswith('bigWig') or e.endswith('gz')]
for each in files:
    each_dict = {}
    if 'bigWig' in each:
        each_dict["type"] = "bigwig"
        each_dict["name"] = each.split("10M_")[1][:-7]
    else:
        each_dict["type"] = "bed"
        each_dict["name"] = each.split("peakcall_")[1].split('.')[0]
    each_dict["url"] = "https://regmedsrv1.wustl.edu/Public_SPACE/yuz/Public_html/hg_heart/male_senior/" + each
    
    if 'left' in each:
        each_dict["options"] = {"color": "blue", "background":"#C0E3CC"}
    else:
        each_dict["options"] = {"color": "red", "background":"#C0E3CC"}
    summary.append(each_dict)
summary = sorted(summary,key=lambda x: x['name'])
with open("male_senior_left_right_ventricle.json", "w") as write_file:
    json.dump(summary, write_file, indent=6) 

