该数学函数的目的是使用二面角计算两个(或更多)蛋白质结构之间的距离:
例如,它在结构生物学中非常有用.我已经使用numpy在python中编写了这个函数,但目标是实现更快.作为计算时间参考,我使用scikit-learn包中提供的欧几里德距离函数.
这是我目前的代码:
import numpy as np
import numexpr as ne
from sklearn.metrics.pairwise import euclidean_distances
# We have 10000 structures with 100 dihedral angles
n = 10000
m = 100
# Generate some random data
c = np.random.rand(n,m)
# Generate random int number
x = np.random.randint(c.shape[0])
print c.shape, x
# First version with numpy of the dihedral_distances function
def dihedral_distances(a, b):
l = 1./a.shape[0]
return np.sqrt(l* np.sum((0.5)*(1. - np.cos(a-b)), axis=1))
# Accelerated version with numexpr
def dihedral_distances_ne(a, b):
l = …Run Code Online (Sandbox Code Playgroud)