Louis BECQUEY

Fix: JSON merging when not using --hrna

......@@ -10,6 +10,7 @@ Contents:
* [Database tables documentation](doc/Database.md)
* [FAQ](doc/FAQ.md)
* [Troubleshooting](#troubleshooting)
* [Known Issues and Feature Requests](doc/KnownIssues.md)
* [Contact](#contact)
## Cite us
......
......@@ -1730,7 +1730,7 @@ def gmm_hrna_basepair_type(type_LW, ntpair, data, scan):
setproctitle(f"GMM (HiRE-RNA {type_LW} {ntpair} basepairs) finished")
@trace_unhandled_exceptions
def merge_jsons():
def merge_jsons(do_hrna):
"""
Reads the tons of JSON files produced by the geometric analyses, and compiles them into fewer files.
It is simple concatenation of the JSONs.
......@@ -1744,12 +1744,19 @@ def merge_jsons():
bonds = [ runDir + "/results/geometry/json/" + x + ".json" for x in bonds ]
concat_jsons(bonds, runDir + "/results/geometry/json/all_atom_distances.json")
# All atom torsions
torsions = ["Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Xhi", "Zeta"]
torsions = [ runDir + "/results/geometry/json/" + x + ".json" for x in torsions ]
concat_jsons(torsions, runDir + "/results/geometry/json/all_atom_torsions.json")
# Delete previous files
for f in bonds + torsions:
try:
os.remove(f)
except FileNotFoundError:
pass
if do_hrna:
# HiRE-RNA distances
hrnabonds = [r"P-O5'", r"O5'-C5'", r"C5'-C4'", r"C4'-C1'", r"C1'-B1", r"B1-B2", r"C4'-P"]
hrnabonds = [ runDir + "/results/geometry/json/" + x + ".json" for x in hrnabonds ]
......@@ -1772,7 +1779,7 @@ def merge_jsons():
concat_jsons(bps, runDir + f"/results/geometry/json/hirerna_{nt1}{nt2}_basepairs.json")
# Delete previous files
for f in bonds + torsions + hrnabonds + hrnaangles + hrnators:
for f in hrnabonds + hrnaangles + hrnators:
try:
os.remove(f)
except FileNotFoundError:
......@@ -1876,8 +1883,9 @@ def concat_jsons(flist, outfilename):
result = []
for f in flist:
# if not os.path.isfile(f):
# continue:
if not os.path.isfile(f):
warn("Unable to find "+f)
continue
with open(f, "rb") as infile:
result.append(json.load(infile))
......
......@@ -1536,6 +1536,6 @@ if __name__ == "__main__":
if DO_WADLEY_ANALYSIS:
joblist.append(Job(function=gmm_pyle, args=(RESCAN_GMM_COMP_NUM, res_thr)))
process_jobs(joblist)
merge_jsons()
merge_jsons(DO_HIRE_RNA_MEASURES)
......