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,55 +1744,62 @@ def merge_jsons(): ...@@ -1744,55 +1744,62 @@ 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
1753 - # 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"]
1755 - hrnabonds = [ runDir + "/results/geometry/json/" + x + ".json" for x in hrnabonds ]
1756 - concat_jsons(hrnabonds, runDir + "/results/geometry/json/hirerna_distances.json")
1757 -
1758 - # HiRE-RNA angles
1759 - hrnaangles = [r"P-O5'-C5'", r"O5'-C5'-C4'", r"C5'-C4'-C1'", r"C4'-C1'-B1", r"C1'-B1-B2", r"C4'-P-O5'", r"C5'-C4'-P", r"C1'-C4'-P"]
1760 - hrnaangles = [ runDir + "/results/geometry/json/" + x + ".json" for x in hrnaangles ]
1761 - concat_jsons(hrnaangles, runDir + "/results/geometry/json/hirerna_angles.json")
1762 -
1763 - # HiRE-RNA torsions
1764 - hrnators = [r"P-O5'-C5'-C4'", r"O5'-C5'-C4'-C1'", r"C5'-C4'-C1'-B1", r"C4'-C1'-B1-B2", r"C4'-P°-O5'°-C5'°", r"C5'-C4'-P°-O5'°", r"C1'-C4'-P°-O5'°", r"O5'-C5'-C4'-P°"]
1765 - hrnators = [ runDir + "/results/geometry/json/" + x + ".json" for x in hrnators ]
1766 - concat_jsons(hrnators, runDir + "/results/geometry/json/hirerna_torsions.json")
1767 -
1768 - # HiRE-RNA basepairs
1769 - for nt1 in ['A', 'C', 'G', 'U']:
1770 - for nt2 in ['A', 'C', 'G', 'U']:
1771 - bps = glob.glob(runDir + f"/results/geometry/json/*{nt1}{nt2}*.json")
1772 - concat_jsons(bps, runDir + f"/results/geometry/json/hirerna_{nt1}{nt2}_basepairs.json")
1773 -
1774 # Delete previous files 1752 # Delete previous files
1775 - for f in bonds + torsions + hrnabonds + hrnaangles + hrnators: 1753 + for f in bonds + torsions:
1776 - try:
1777 - os.remove(f)
1778 - except FileNotFoundError:
1779 - pass
1780 - for f in glob.glob(runDir + "/results/geometry/json/t*.json"):
1781 - try:
1782 - os.remove(f)
1783 - except FileNotFoundError:
1784 - pass
1785 - for f in glob.glob(runDir + "/results/geometry/json/c*.json"):
1786 - try:
1787 - os.remove(f)
1788 - except FileNotFoundError:
1789 - pass
1790 - for f in glob.glob(runDir + "/results/geometry/json/*tips_distance.json"):
1791 try: 1754 try:
1792 os.remove(f) 1755 os.remove(f)
1793 except FileNotFoundError: 1756 except FileNotFoundError:
1794 pass 1757 pass
1795 1758
1759 + if do_hrna:
1760 + # HiRE-RNA distances
1761 + hrnabonds = [r"P-O5'", r"O5'-C5'", r"C5'-C4'", r"C4'-C1'", r"C1'-B1", r"B1-B2", r"C4'-P"]
1762 + hrnabonds = [ runDir + "/results/geometry/json/" + x + ".json" for x in hrnabonds ]
1763 + concat_jsons(hrnabonds, runDir + "/results/geometry/json/hirerna_distances.json")
1764 +
1765 + # HiRE-RNA angles
1766 + hrnaangles = [r"P-O5'-C5'", r"O5'-C5'-C4'", r"C5'-C4'-C1'", r"C4'-C1'-B1", r"C1'-B1-B2", r"C4'-P-O5'", r"C5'-C4'-P", r"C1'-C4'-P"]
1767 + hrnaangles = [ runDir + "/results/geometry/json/" + x + ".json" for x in hrnaangles ]
1768 + concat_jsons(hrnaangles, runDir + "/results/geometry/json/hirerna_angles.json")
1769 +
1770 + # HiRE-RNA torsions
1771 + hrnators = [r"P-O5'-C5'-C4'", r"O5'-C5'-C4'-C1'", r"C5'-C4'-C1'-B1", r"C4'-C1'-B1-B2", r"C4'-P°-O5'°-C5'°", r"C5'-C4'-P°-O5'°", r"C1'-C4'-P°-O5'°", r"O5'-C5'-C4'-P°"]
1772 + hrnators = [ runDir + "/results/geometry/json/" + x + ".json" for x in hrnators ]
1773 + concat_jsons(hrnators, runDir + "/results/geometry/json/hirerna_torsions.json")
1774 +
1775 + # HiRE-RNA basepairs
1776 + for nt1 in ['A', 'C', 'G', 'U']:
1777 + for nt2 in ['A', 'C', 'G', 'U']:
1778 + bps = glob.glob(runDir + f"/results/geometry/json/*{nt1}{nt2}*.json")
1779 + concat_jsons(bps, runDir + f"/results/geometry/json/hirerna_{nt1}{nt2}_basepairs.json")
1780 +
1781 + # Delete previous files
1782 + for f in hrnabonds + hrnaangles + hrnators:
1783 + try:
1784 + os.remove(f)
1785 + except FileNotFoundError:
1786 + pass
1787 + for f in glob.glob(runDir + "/results/geometry/json/t*.json"):
1788 + try:
1789 + os.remove(f)
1790 + except FileNotFoundError:
1791 + pass
1792 + for f in glob.glob(runDir + "/results/geometry/json/c*.json"):
1793 + try:
1794 + os.remove(f)
1795 + except FileNotFoundError:
1796 + pass
1797 + for f in glob.glob(runDir + "/results/geometry/json/*tips_distance.json"):
1798 + try:
1799 + os.remove(f)
1800 + except FileNotFoundError:
1801 + pass
1802 +
1796 @trace_unhandled_exceptions 1803 @trace_unhandled_exceptions
1797 def concat_worker(bunch): 1804 def concat_worker(bunch):
1798 """ 1805 """
...@@ -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
......