Author: bugman Date: Thu Jan 22 16:56:35 2015 New Revision: 27272 URL: http://svn.gna.org/viewcvs/relax?rev=27272&view=rev Log: Created the Test_needleman_wunsch.test_needleman_wunsch_align_NUC_4_4 unit test. This is in the unit test module _lib._sequence_alignment.test_needleman_wunsch. This tests the Needleman-Wunsch sequence alignment for two DNA sequences using the NUC 4.4 matrix. Modified: trunk/test_suite/unit_tests/_lib/_sequence_alignment/test_needleman_wunsch.py Modified: trunk/test_suite/unit_tests/_lib/_sequence_alignment/test_needleman_wunsch.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/_lib/_sequence_alignment/test_needleman_wunsch.py?rev=27272&r1=27271&r2=27272&view=diff ============================================================================== --- trunk/test_suite/unit_tests/_lib/_sequence_alignment/test_needleman_wunsch.py (original) +++ trunk/test_suite/unit_tests/_lib/_sequence_alignment/test_needleman_wunsch.py Thu Jan 22 16:56:35 2015 @@ -60,3 +60,43 @@ for i in range(2): for j in range(8): self.assertEqual(gaps[i, j], real_gaps[i][j]) + + + def test_needleman_wunsch_align_NUC_4_4(self): + """Test the Needleman-Wunsch sequence alignment for two DNA sequences using the NUC 4.4 matrix. + + From online servers, the results with a gap open penalty of 5 and gap extend of 1 should be:: + + https://www.ebi.ac.uk/Tools/psa/emboss_needle/ + EMBOSS_001 1 GAAAAAAT 8 + | ||| + EMBOSS_001 1 G----AAT 4 + """ + + # The sequences. + seq1 = 'GAAAAAAT' + seq2 = 'GAAT' + print("\nIn:") + print(seq1) + print(seq2) + + # Perform the alignment. + align1, align2, gaps = needleman_wunsch_align(seq1, seq2, sub_matrix=NUC_4_4, sub_seq=NUC_4_4_SEQ, gap_open_penalty=5, gap_extend_penalty=1) + print("\nOut:") + print(align1) + print(align2) + print(gaps) + print("\n") + + # Check the alignment. + self.assertEqual(align1, 'GAAAAAAT') + self.assertEqual(align2, 'G----AAT') + + # The gap matrix. + real_gaps = [ + [0, 0, 0, 0, 0, 0, 0, 0], + [0, 1, 1, 1, 1, 0, 0, 0] + ] + for i in range(2): + for j in range(8): + self.assertEqual(gaps[i, j], real_gaps[i][j])