Skip to content

Commit

Permalink
rna_tools/rna_tools_lib.py: connectivity score explore
Browse files Browse the repository at this point in the history
  • Loading branch information
mmagnus committed Nov 22, 2024
1 parent 58a9b20 commit ee3e316
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions rna_tools/rna_tools_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ def check_geometry(self, verbose=False):
mean = 1.599316
import numpy as np

dist_o3pp= []
for s in struc:
for c in s:
# for new chain reset resi_prev
Expand All @@ -410,6 +411,8 @@ def check_geometry(self, verbose=False):

v = resi_prev["O3'"] - r['P']
op.append(v)
import math
dist_o3pp.append(abs(1.6 - v))
x = mean - 6 * sigma
y = mean + 6 * sigma

Expand All @@ -418,7 +421,8 @@ def check_geometry(self, verbose=False):
po.append(v2)

if not (x <= v <= y):
print(f' ! lack of connectivity between {r}, {resi_prev}, distance between residues: {v:.2f}')
#print(f' ! lack of connectivity between {r}, {resi_prev}, distance between residues: {v:.2f}')
pass

# angle
pc3p = resi_prev["O3'"].get_vector()
Expand Down Expand Up @@ -452,18 +456,29 @@ def check_geometry(self, verbose=False):
angles2.append(angle2)

resi_prev = r

#ic(dist_o3pp, len(dist_o3pp), np.mean(dist_o3pp))
# Colors
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
BLUE = "\033[34m"
RESET = "\033[0m"

print(f'Connectivity Score; {GREEN} {sum(dist_o3pp) } {RESET}')
print('Connectivity Score; ', sum(dist_o3pp) / len(dist_o3pp))
p_ps = np.array(p_ps)
#np.set_printoptions(threshold=np.inf)
ic.disable()
# ic.disable()
ic(p_ps)
ic(p_ps.mean(), p_ps.std())
if False:

plots = False
if plots:
import matplotlib.pyplot as plt
plt.hist(p_ps, bins='auto')
plt.hist(f'{self.name} p_ps', bins='auto')
plt.title("p-ps")
plt.show()

plt.savefig("histogram.png") # Save the figure as a PNG file
op = np.array(op)
ic(op.mean(), op.std())

Expand All @@ -473,7 +488,7 @@ def check_geometry(self, verbose=False):
angles = np.array(angles)
ic(angles)
ic(angles.mean(), angles.std())
if False:
if plots:
import matplotlib.pyplot as plt
plt.hist(angles, bins='auto')
plt.title("Histogram of angles o3'-p-o5'")
Expand All @@ -484,13 +499,13 @@ def check_geometry(self, verbose=False):
ic(angles2)
ic(angles2.mean(), angles2.std())

if False:
if plots:
import matplotlib.pyplot as plt
plt.hist(angles2, bins='auto')
plt.title("Histogram of angles c3'-o3'-p")
plt.xlim(0, 360)
plt.show()
ic.enable()
#ic.enable()

def get_text(self, add_end=True):
"""works on self.lines."""
Expand Down

0 comments on commit ee3e316

Please sign in to comment.