import os
import json

file_list = os.listdir("/home/yuz/Public_html/tao/GSE222984")
file_list1 = [each for each in file_list if each.endswith("gz")]
#file_list2 = [each for each in file_list if each.endswith("bigWig")]
summary = []

for each in file_list1:
    each_dict = {}
    each_dict["type"] = "bedgraph"
    each_dict["url"] = "https://regmedsrv1.wustl.edu/Public_SPACE/yuz/Public_html/tao/GSE222984/" + each
    each_dict["name"] = each.split("Star_")[1].split('_1.U')[0]
    each_dict["options"] = {"color": "blue", "background":"#C0E3CC"}
    summary.append(each_dict)
"""
for each in file_list2:
    each_dict = {}
    each_dict["type"] = "bigwig"
    each_dict["url"] = "http://regmedsrv1.wustl.edu/Public_SPACE/yuz/Public_html/chen/cutrun_2023/" + each
    each_dict["name"] = each.split(".")[1][11:]
    each_dict["options"] = {"color": "blue", "background":"#C0E3CC"}
    summary.append(each_dict)
"""
summary = sorted(summary,key=lambda x: x['name'])
with open("GSE222984_rnaseq.json", "w") as write_file:
    json.dump(summary, write_file, indent=6) 
