Package obitools :: Package distances
[hide private]
[frames] | no frames]

Source Code for Package obitools.distances

1 -class DistanceMatrix(object):
2
3 - def __init__(self,alignment):
4 ''' 5 DistanceMatrix constructor. 6 7 @param alignment: aligment used to compute distance matrix 8 @type alignment: obitools.align.Alignment 9 ''' 10 self.aligment = alignment 11 self.matrix = [[None] * (x+1) for x in xrange(len(alignment))]
12
13 - def evaluateDist(self,x,y):
14 raise NotImplementedError
15
16 - def __getitem__(self,key):
17 assert isinstance(key,(tuple,list)) and len(key)==2, \ 18 'key must be a tuple or a list of two integers' 19 x,y = key 20 if y < x: 21 z=x 22 x=y 23 y=z 24 rep = self.matrix[y][x] 25 if rep is None: 26 rep = self.evaluateDist(x,y) 27 self.matrix[y][x] = rep 28 29 return rep
30