Package test_suite :: Package unit_tests :: Package _lib :: Package _sequence_alignment :: Module test_msa
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._lib._sequence_alignment.test_msa

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2015 Edward d'Auvergne                                        # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Python module imports. 
 23  from numpy import int16, zeros 
 24  from unittest import TestCase 
 25   
 26  # relax module imports. 
 27  from lib.sequence_alignment.msa import central_star 
 28   
 29   
30 -class Test_msa(TestCase):
31 """Unit tests for the lib.sequence_alignment.msa relax module.""" 32
33 - def test_central_star(self):
34 """Test the central star multiple sequence alignment function lib.sequence_alignment.msa.central_star(). 35 36 This uses the sequences: 37 38 - 'TEEQVDADGGT', 39 - 'ADQLTEEQVDADGNGTIDFPEFLTMMARKM', 40 - 'LTEEQMINEVDAGNGTIDFPEFLTMMAR'. 41 42 The result should be:: 43 44 Pairwise protein alignment. 45 Substitution matrix: BLOSUM62 46 Gap opening penalty: 5.0 47 Gap extend penalty: 1.0 48 49 Input sequence 1: TEEQVDADGGT 50 Input sequence 2: ADQLTEEQVDADGNGTIDFPEFLTMMARKM 51 52 Aligned sequence 1: ----TEEQVDADG-GT-------------- 53 Aligned sequence 2: ADQLTEEQVDADGNGTIDFPEFLTMMARKM 54 ********* ** 55 56 57 Pairwise protein alignment. 58 Substitution matrix: BLOSUM62 59 Gap opening penalty: 5.0 60 Gap extend penalty: 1.0 61 62 Input sequence 1: TEEQVDADGGT 63 Input sequence 2: LTEEQMINEVDAGNGTIDFPEFLTMMAR 64 65 Aligned sequence 1: -TEEQ----VDADGGT------------ 66 Aligned sequence 2: LTEEQMINEVDAGNGTIDFPEFLTMMAR 67 **** *** ** 68 69 ----TEEQ----VDADG-GT-------------- 70 ADQLTEEQ----VDADGNGTIDFPEFLTMMARKM 71 ---LTEEQMINEVDA-GNGTIDFPEFLTMMAR-- 72 """ 73 74 # The sequences. 75 seq1 = 'TEEQVDADGGT' 76 seq2 = 'ADQLTEEQVDADGNGTIDFPEFLTMMARKM' 77 seq3 = 'LTEEQMINEVDAGNGTIDFPEFLTMMAR' 78 79 # Perform the alignment. 80 strings, gaps = central_star([seq1, seq2, seq3], matrix='BLOSUM62', gap_open_penalty=5.0, gap_extend_penalty=1.0) 81 print(strings[0]) 82 print(strings[1]) 83 print(strings[2]) 84 print(gaps) 85 86 # Check the alignment. 87 self.assertEqual(strings[0], '----TEEQ----VDADG-GT--------------') 88 self.assertEqual(strings[1], 'ADQLTEEQ----VDADGNGTIDFPEFLTMMARKM') 89 self.assertEqual(strings[2], '---LTEEQMINEVDA-GNGTIDFPEFLTMMAR--') 90 91 # The gap matrix. 92 real_gaps = zeros((3, 34), int16) 93 for i in (list(range(4)) + list(range(8, 12)) + [17] + list(range(20, 34))): 94 real_gaps[0, i] = 1 95 for i in range(8, 12): 96 real_gaps[1, i] = 1 97 for i in (list(range(3)) + [15, 32, 33]): 98 real_gaps[2, i] = 1 99 for i in range(3): 100 for j in range(34): 101 self.assertEqual(gaps[i, j], real_gaps[i][j])
102