1 """
2 This module provides code for various distance measures.
3
4 Functions:
5 euclidean Euclidean distance between two points
6 euclidean_py Pure Python implementation of euclidean.
7
8 """
9
10
11 import warnings
12 warnings.warn("Bio.distance is deprecated. If you use this module, please notify the Biopython developers at biopython-dev@biopython.org", DeprecationWarning)
13
14 from numpy import *
15
17 """euclidean(x, y) -> euclidean distance between x and y"""
18 if len(x) != len(y):
19 raise ValueError("vectors must be same length")
20
21
22 d = x-y
23 return sqrt(dot(d, d))
24
26 """euclidean_py(x, y) -> euclidean distance between x and y"""
27
28
29
30 if len(x) != len(y):
31 raise ValueError("vectors must be same length")
32 sum = 0
33 for i in range(len(x)):
34 sum += (x[i]-y[i])**2
35 return sqrt(sum)
36