1 '''
2 Module dedicated to compute observed divergeances from
3 an alignment. No distance correction is applied at all
4 '''
5
6 from itertools import imap
7
8 from obitools.distances import DistanceMatrix
9
11 '''
12 Observed divergeance matrix from an alignment.
13 Gap are removed from the alignemt on a pairewise
14 sequence base
15 '''
16
18 '''
19 Compute the observed divergeance from two sequences
20 of an aligment.
21
22 @attention For performance purpose this method should
23 be directly used. use instead the __getitem__
24 method from DistanceMatrix.
25
26 @see __getitem__
27
28 @param x number of the fisrt sequence in the aligment
29 @type x int
30 @param y umber of the second sequence in the aligment
31 @type y int
32
33
34 '''
35
36 seq1 = self.aligment[x]
37 seq2 = self.aligment[y]
38
39 diff,tot = reduce(lambda x,y: (x[0]+y,x[1]+1),
40 (z[0]!=z[1] for z in imap(None,seq1,seq2)
41 if '-' not in z),(0,0))
42 return float(diff)/tot
43