Author: bugman Date: Thu Jan 22 17:00:03 2015 New Revision: 27273 URL: http://svn.gna.org/viewcvs/relax?rev=27273&view=rev Log: Created a unit test for demonstrating a failure in the Needleman-Wunsch sequence alignment algorithm. The test is Test_needleman_wunsch.test_needleman_wunsch_align_NUC_4_4b from the _lib._sequence_alignment.test_needleman_wunsch module. The problem is that the start of the alignment is truncated if any gaps are present. 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=27273&r1=27272&r2=27273&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 17:00:03 2015 @@ -100,3 +100,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_4b(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 GACAGAAT- 8 + |||| + EMBOSS_001 1 ----GAATA 5 + """ + + # The sequences. + seq1 = 'GACAGAAT' + seq2 = 'GAATA' + 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, 'GACAGAAT-') + self.assertEqual(align2, '----GAATA') + + # The gap matrix. + real_gaps = [ + [0, 0, 0, 0, 0, 0, 0, 0, 1], + [1, 1, 1, 1, 0, 0, 0, 0, 0] + ] + for i in range(2): + for j in range(8): + self.assertEqual(gaps[i, j], real_gaps[i][j])