File: test_pamlmatrix.py

package info (click to toggle)
python-cogent 2024.5.7a1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 74,600 kB
  • sloc: python: 92,479; makefile: 117; sh: 16
file content (53 lines) | stat: -rw-r--r-- 2,150 bytes parent folder | download
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
from io import StringIO
from unittest import TestCase

from numpy.testing import assert_equal

from cogent3.evolve.models import DSO78_freqs, DSO78_matrix
from cogent3.parse.paml_matrix import PamlMatrixParser


data = """
       27									    
       98  32									    
      120   0 905								    
       36  23   0   0								    
       89 246 103 134   0							    
      198   1 148 1153  0 716							    
      240   9 139 125  11  28  81						    
       23 240 535  86  28 606  43  10						    
       65  64  77  24  44  18  61   0   7					    
       41  15  34   0   0  73  11   7  44 257					    
       26 464 318  71   0 153  83  27  26  46  18				    
       72  90   1   0   0 114  30  17   0 336 527 243				    
       18  14  14   0   0   0   0  15  48 196 157   0  92			    
      250 103  42  13  19 153  51  34  94  12  32  33  17  11			    
      409 154 495  95 161  56  79 234  35  24  17  96  62  46 245		    
      371  26 229  66  16  53  34  30  22 192  33 136 104  13  78 550		    
        0 201  23   0   0   0   0   0  27   0  46   0   0  76   0  75   0	    
       24   8  95   0  96   0  22   0 127  37  28  13   0 698   0  34  42  61	    
      208  24  15  18  49  35  37  54  44 889 175  10 258  12  48  30 157   0  28 

      0.087127 0.040904 0.040432 0.046872 0.033474 0.038255 0.049530
      0.088612 0.033618 0.036886 0.085357 0.080482 0.014753 0.039772
      0.050680 0.069577 0.058542 0.010494 0.029916 0.064718

      Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val

      S_ij = S_ji and PI_i for the Dayhoff model, with the rate Q_ij=S_ij*PI_j
      The rest of the file is not used.
      Prepared by Z. Yang, March 1995.


      See the following reference for notation used here:

      Yang, Z., R. Nielsen and M. Hasegawa. 1998. Models of amino acid substitution and
      applications to mitochondrial protein evolution. Mol. Biol. Evol. 15:1600-1611.
"""


class TestParsePamlMatrix(TestCase):
    def test_parse(self):
        matrix, freqs = PamlMatrixParser(StringIO(data))
        assert_equal(DSO78_matrix, matrix)
        assert_equal(DSO78_freqs, freqs)