Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to prepare data using RNA graphs generated by RNAglib #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/RNAmigos.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added data/all_ligs_maccs.p
Binary file not shown.
4 changes: 2 additions & 2 deletions data_processor/binding_pocket_analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
def ligand_center(residue):
return np.mean(np.array([atom.coord for atom in residue.get_atoms()]), axis=0)

def _is_valid_ligand(ligand_residue):
def is_valid_ligand(ligand_residue):
#no ions
invalids = ['HOH', 'NCO', 'SO4', 'EPE', 'OHX', 'MPD']
if ligand_residue.resname in invalids or len(ligand_residue.resname) != 3:
return False
return True

def is_valid_ligand(ligand_residue):
def _is_valid_ligand(ligand_residue):
#no ions
return ligand_residue.resname.strip() == 'MG'

Expand Down
4 changes: 2 additions & 2 deletions data_processor/build_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from tqdm import tqdm

from tools.drawing import rna_draw
from data_processor.pocket_grid import sample_non_binding_sites
#from data_processor.pocket_grid import sample_non_binding_sites
from data_processor.rna_classes import *
from data_processor.graph_process import *
from data_processor.marker_file import *
#from data_processor.marker_file import *

faces = ['W', 'S', 'H']
orientations = ['C', 'T']
Expand Down
16 changes: 8 additions & 8 deletions data_processor/graph_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ def to_orig(G):
# remove_non_standard_edges(G)
H = nx.Graph()
for n1, n2, d in G.edges(data=True):
label = symmetric(d['label'])
if label in valid_edges:
H.add_edge(n1, n2, label=label)
label = symmetric(d['LW'])
if label.upper() in valid_edges:
H.add_edge(n1, n2, label=label.upper())

#add pdb position and nt to node data
d_orig = {n:d['nucleotide'].pdb_pos for n,d in G.nodes(data=True)}
d_orig = {n: d['nt_resnum'] for n, d in G.nodes(data=True)}
nx.set_node_attributes(H, {n:d_orig[n] for n in H.nodes()}, 'pdb_pos')
d_orig = {n:d['nucleotide'].nt for n,d in G.nodes(data=True)}
d_orig = {n: d['nt_code'] for n, d in G.nodes(data=True)}
nx.set_node_attributes(H, {n:d_orig[n] for n in H.nodes()}, 'nt')
d_orig = {n:n[0] for n,d in G.nodes(data=True)}
d_orig = {n: n.split('.')[1] for n, d in G.nodes(data=True)}
nx.set_node_attributes(H, {n:d_orig[n] for n in H.nodes()}, 'chain')
return H

Expand Down Expand Up @@ -123,7 +123,7 @@ def graph_ablations(G, mode):

def find_node(graph, chain, pos):
for n,d in graph.nodes(data=True):
if (n[0] == chain) and (d['nucleotide'].pdb_pos == str(pos)):
if (n.split('.')[1] == chain) and (str(d['nt_resnum']) == str(pos)):
return n
return None

Expand Down Expand Up @@ -167,7 +167,7 @@ def dangle_trim(G):
"""
Recursively remove dangling nodes from graph.
"""
is_backbone = lambda n,G: sum([G[n][nei]['label'] != 'B53' for nei in G.neighbors(n)]) == 0
is_backbone = lambda n, G: sum([G[n][nei]['LW'] != 'B53' for nei in G.neighbors(n)]) == 0
degree = lambda i, G, nodelist: np.sum(nx.to_numpy_matrix(G, nodelist=nodelist)[i])
cur_G = G.copy()
while True:
Expand Down