Louis BECQUEY

Fix: JSON merging when not using --hrna

...@@ -10,6 +10,7 @@ Contents: ...@@ -10,6 +10,7 @@ Contents:
10 * [Database tables documentation](doc/Database.md) 10 * [Database tables documentation](doc/Database.md)
11 * [FAQ](doc/FAQ.md) 11 * [FAQ](doc/FAQ.md)
12 * [Troubleshooting](#troubleshooting) 12 * [Troubleshooting](#troubleshooting)
13 +* [Known Issues and Feature Requests](doc/KnownIssues.md)
13 * [Contact](#contact) 14 * [Contact](#contact)
14 15
15 ## Cite us 16 ## Cite us
......
...@@ -1730,7 +1730,7 @@ def gmm_hrna_basepair_type(type_LW, ntpair, data, scan): ...@@ -1730,7 +1730,7 @@ def gmm_hrna_basepair_type(type_LW, ntpair, data, scan):
1730 setproctitle(f"GMM (HiRE-RNA {type_LW} {ntpair} basepairs) finished") 1730 setproctitle(f"GMM (HiRE-RNA {type_LW} {ntpair} basepairs) finished")
1731 1731
1732 @trace_unhandled_exceptions 1732 @trace_unhandled_exceptions
1733 -def merge_jsons(): 1733 +def merge_jsons(do_hrna):
1734 """ 1734 """
1735 Reads the tons of JSON files produced by the geometric analyses, and compiles them into fewer files. 1735 Reads the tons of JSON files produced by the geometric analyses, and compiles them into fewer files.
1736 It is simple concatenation of the JSONs. 1736 It is simple concatenation of the JSONs.
...@@ -1744,12 +1744,19 @@ def merge_jsons(): ...@@ -1744,12 +1744,19 @@ def merge_jsons():
1744 bonds = [ runDir + "/results/geometry/json/" + x + ".json" for x in bonds ] 1744 bonds = [ runDir + "/results/geometry/json/" + x + ".json" for x in bonds ]
1745 concat_jsons(bonds, runDir + "/results/geometry/json/all_atom_distances.json") 1745 concat_jsons(bonds, runDir + "/results/geometry/json/all_atom_distances.json")
1746 1746
1747 -
1748 # All atom torsions 1747 # All atom torsions
1749 torsions = ["Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Xhi", "Zeta"] 1748 torsions = ["Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Xhi", "Zeta"]
1750 torsions = [ runDir + "/results/geometry/json/" + x + ".json" for x in torsions ] 1749 torsions = [ runDir + "/results/geometry/json/" + x + ".json" for x in torsions ]
1751 concat_jsons(torsions, runDir + "/results/geometry/json/all_atom_torsions.json") 1750 concat_jsons(torsions, runDir + "/results/geometry/json/all_atom_torsions.json")
1752 1751
1752 + # Delete previous files
1753 + for f in bonds + torsions:
1754 + try:
1755 + os.remove(f)
1756 + except FileNotFoundError:
1757 + pass
1758 +
1759 + if do_hrna:
1753 # HiRE-RNA distances 1760 # HiRE-RNA distances
1754 hrnabonds = [r"P-O5'", r"O5'-C5'", r"C5'-C4'", r"C4'-C1'", r"C1'-B1", r"B1-B2", r"C4'-P"] 1761 hrnabonds = [r"P-O5'", r"O5'-C5'", r"C5'-C4'", r"C4'-C1'", r"C1'-B1", r"B1-B2", r"C4'-P"]
1755 hrnabonds = [ runDir + "/results/geometry/json/" + x + ".json" for x in hrnabonds ] 1762 hrnabonds = [ runDir + "/results/geometry/json/" + x + ".json" for x in hrnabonds ]
...@@ -1772,7 +1779,7 @@ def merge_jsons(): ...@@ -1772,7 +1779,7 @@ def merge_jsons():
1772 concat_jsons(bps, runDir + f"/results/geometry/json/hirerna_{nt1}{nt2}_basepairs.json") 1779 concat_jsons(bps, runDir + f"/results/geometry/json/hirerna_{nt1}{nt2}_basepairs.json")
1773 1780
1774 # Delete previous files 1781 # Delete previous files
1775 - for f in bonds + torsions + hrnabonds + hrnaangles + hrnators: 1782 + for f in hrnabonds + hrnaangles + hrnators:
1776 try: 1783 try:
1777 os.remove(f) 1784 os.remove(f)
1778 except FileNotFoundError: 1785 except FileNotFoundError:
...@@ -1876,8 +1883,9 @@ def concat_jsons(flist, outfilename): ...@@ -1876,8 +1883,9 @@ def concat_jsons(flist, outfilename):
1876 1883
1877 result = [] 1884 result = []
1878 for f in flist: 1885 for f in flist:
1879 - # if not os.path.isfile(f): 1886 + if not os.path.isfile(f):
1880 - # continue: 1887 + warn("Unable to find "+f)
1888 + continue
1881 with open(f, "rb") as infile: 1889 with open(f, "rb") as infile:
1882 result.append(json.load(infile)) 1890 result.append(json.load(infile))
1883 1891
......
...@@ -1536,6 +1536,6 @@ if __name__ == "__main__": ...@@ -1536,6 +1536,6 @@ if __name__ == "__main__":
1536 if DO_WADLEY_ANALYSIS: 1536 if DO_WADLEY_ANALYSIS:
1537 joblist.append(Job(function=gmm_pyle, args=(RESCAN_GMM_COMP_NUM, res_thr))) 1537 joblist.append(Job(function=gmm_pyle, args=(RESCAN_GMM_COMP_NUM, res_thr)))
1538 process_jobs(joblist) 1538 process_jobs(joblist)
1539 - merge_jsons() 1539 + merge_jsons(DO_HIRE_RNA_MEASURES)
1540 1540
1541 1541
......