Download model/datasets/mol2graph_rdmda_res.py from OneScience-Group/SurfDock: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/OneScience-Group/SurfDock/resolve/main/model/datasets/mol2graph_rdmda_res.py
- Command line
-
hf download hf://OneScience-Group/SurfDock/model/datasets/mol2graph_rdmda_res.py
-
curl -L -o mol2graph_rdmda_res.py https://huggingface.co/OneScience-Group/SurfDock/resolve/main/model/datasets/mol2graph_rdmda_res.py
2.27 kB
| import numpy as np | |
| from itertools import permutations | |
| import MDAnalysis as mda | |
| # from MDAnalysis.analysis import dihedrals | |
| from MDAnalysis.analysis import distances | |
| def obtain_self_dist(res): | |
| try: | |
| #xx = res.atoms.select_atoms("not name H*") | |
| xx = res.atoms | |
| dists = distances.self_distance_array(xx.positions) | |
| ca = xx.select_atoms("name CA") | |
| c = xx.select_atoms("name C") | |
| n = xx.select_atoms("name N") | |
| o = xx.select_atoms("name O") | |
| return [dists.max()*0.1, dists.min()*0.1, distances.dist(ca,o)[-1][0]*0.1, distances.dist(o,n)[-1][0]*0.1, distances.dist(n,c)[-1][0]*0.1] | |
| except: | |
| return [0, 0, 0, 0, 0] | |
| def obtain_dihediral_angles(res): | |
| try: | |
| if res.phi_selection() is not None: | |
| phi = res.phi_selection().dihedral.value() | |
| else: | |
| phi = 0 | |
| if res.psi_selection() is not None: | |
| psi = res.psi_selection().dihedral.value() | |
| else: | |
| psi = 0 | |
| if res.omega_selection() is not None: | |
| omega = res.omega_selection().dihedral.value() | |
| else: | |
| omega = 0 | |
| if res.chi1_selection() is not None: | |
| chi1 = res.chi1_selection().dihedral.value() | |
| else: | |
| chi1 = 0 | |
| return [phi*0.01, psi*0.01, omega*0.01, chi1*0.01] | |
| except: | |
| return [0, 0, 0, 0] | |
| ##'FE', 'SR', 'GA', 'IN', 'ZN', 'CU', 'MN', 'SR', 'K' ,'NI', 'NA', 'CD' 'MG','CO','HG', 'CS', 'CA', | |
| def obatin_edge(u, cutoff=10.0): | |
| edgeids = [] | |
| dismin = [] | |
| dismax = [] | |
| for res1, res2 in permutations(u.residues, 2): | |
| dist = calc_dist(res1, res2) | |
| if dist.min() <= cutoff: | |
| edgeids.append([res1.ix, res2.ix]) | |
| dismin.append(dist.min()*0.1) | |
| dismax.append(dist.max()*0.1) | |
| return edgeids, np.array([dismin, dismax]).T | |
| def check_connect(u, i, j): | |
| if abs(i-j) != 1: | |
| return 0 | |
| else: | |
| if i > j: | |
| i = j | |
| nb1 = len(u.residues[i].get_connections("bonds")) | |
| nb2 = len(u.residues[i+1].get_connections("bonds")) | |
| nb3 = len(u.residues[i:i+2].get_connections("bonds")) | |
| if nb1 + nb2 == nb3 + 1: | |
| return 1 | |
| else: | |
| return 0 | |
| def calc_dist(res1, res2): | |
| #xx1 = res1.atoms.select_atoms('not name H*') | |
| #xx2 = res2.atoms.select_atoms('not name H*') | |
| #dist_array = distances.distance_array(xx1.positions,xx2.positions) | |
| dist_array = distances.distance_array(res1.atoms.positions,res2.atoms.positions) | |
| return dist_array | |
| #return dist_array.max()*0.1, dist_array.min()*0.1 | |