Repository navigation
Expand file tree
/
Copy pathutility.py
More file actions
93 lines (57 loc) · 2.24 KB
/
Copy pathutility.py
File metadata and controls
93 lines (57 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
import numpy as np
import os
from biopandas.pdb import PandasPdb
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import Bio
from Bio.PDB import PDBParser
from scipy.spatial.distance import euclidean
import itertools
# In[ ]:
# Calculates Rotation Matrix given euler angles.
def RotationMatrix(theta) :
R_x = np.array([[1, 0, 0 ],
[0, np.cos(theta[0]), -np.sin(theta[0]) ],
[0, np.sin(theta[0]), np.cos(theta[0]) ]
])
R_y = np.array([[np.cos(theta[1]), 0, np.sin(theta[1]) ],
[0, 1, 0 ],
[-np.sin(theta[1]), 0, np.cos(theta[1]) ]
])
R_z = np.array([[np.cos(theta[2]), -np.sin(theta[2]), 0],
[np.sin(theta[2]), np.cos(theta[2]), 0],
[0, 0, 1]
])
R = np.dot(R_z, np.dot( R_y, R_x ))
return R
# In[ ]:
# protein radius based on distance matrix
def approx_radius(coord):
dist = np.zeros((len(coord), len(coord)))
for i in range(len(coord)):
for j in range(0,len(coord)):
dist[i][j]=np.double(euclidean(coord[i],coord[j]))
approx_radius = np.argmax(dist)/2
return approx_radius
# In[ ]:
def new_coord_moving(coordi, trans, theta, mean_move):
coordi_o = coordi - mean_move # move the moving protein to the origin
R = RotationMatrix(theta)
coordi_r = []
for ii in range(len(coordi)):
coordi_r.append(np.dot(R, coordi_o[ii])) # rotate
coordi_t = coordi_r + mean_move + trans
# coordi_t = coordi_r + trans # starting point: 2*(r1+r2) + trans
return coordi_t
# In[ ]:
def new_dist(coord1, coord2):
new_dist = np.zeros((len(coord1), len(coord2)))
for ii in range(len(coord1)):
for jj in range(len(coord2)):
new_dist[ii][jj] = np.double(euclidean(coord1[ii], coord2[jj]))
return new_dist
# In[ ]: