def test_unaligned_muscle(self): if not functions.which('muscle'): _LOG.warning('muscle not found... skipping tests.') return seq1 = SeqRecord(Seq('AC--GTNAC-TYATR'), id='1') seq2 = SeqRecord(Seq('ACN-GTAAC--CATT'), id='2') # 'ACGTNACTYATR' # 'ACNGTAACCATT' diffs, l = seqstats.get_differences(seq1, seq2, aligned = False, ignore_gaps = False, aligner_tools = ['muscle']) e = {11: ('R', 'T'), 3: ('T', 'G'), 6: ('C', 'A'), 7: ('T', 'C')} self.assertEqual(diffs, e) self.assertEqual(l, 12) seq1 = SeqRecord(Seq('ATCCGT'), id='1') seq2 = SeqRecord(Seq('ACCGT'), id='2') diffs, l = seqstats.get_differences(seq1, seq2, aligned = False, ignore_gaps = True, aligner_tools = ['muscle']) self.assertEqual(diffs, {}) self.assertEqual(l, 5) diffs, l = seqstats.get_differences(seq1, seq2, aligned = False, ignore_gaps = False, aligner_tools = ['muscle']) self.assertEqual(diffs, {1: ('T', '-')}) self.assertEqual(l, 6)
def test_unaligned_mafft_aa(self): seq1 = SeqRecord(Seq('AC--DEFGI-LBATR'), id='1') seq2 = SeqRecord(Seq('ACN-DEFGI--DATT'), id='2') # 'AC-DEFGILBATR' # 'ACNDEFGIDATT-' e = {2: ('-', 'N'), 8: ('L', 'D'), 9: ('B', 'A'), 10: ('A', 'T'), 12: ('R', '-'), } diffs, l = seqstats.get_differences(seq1, seq2, aligned = False, alphabet = alphabets.ProteinAlphabet(), ignore_gaps = False, aligner_tools = ['mafft']) self.assertEqual(diffs, e) self.assertEqual(l, 13) diffs, l = seqstats.get_differences(seq1, seq2, aligned = False, alphabet = alphabets.ProteinAlphabet(), ignore_gaps = True, aligner_tools = ['mafft']) e = {8: ('L', 'D'), 9: ('B', 'A'), 10: ('A', 'T'), } self.assertEqual(diffs, e) self.assertEqual(l, 11)
def test_align_error(self): seq1 = SeqRecord(Seq('ACGT'), id='1') seq2 = SeqRecord(Seq('TACGT'), id='2') self.assertRaises(seqstats.AlignmentError, seqstats.get_differences, seq1, seq2, True) diffs, l = seqstats.get_differences(seq1, seq2) self.assertEqual(diffs, {}) self.assertEqual(l, 4) expected = {0: ('-', 'T')} diffs, l = seqstats.get_differences(seq1, seq2, ignore_gaps = False) self.assertEqual(diffs, expected) self.assertEqual(l, 5)
def test_aligned(self): seq1 = SeqRecord(Seq('AC--GTNAC-TYATR'), id='1') seq2 = SeqRecord(Seq('ACN-GTAAC--CATT'), id='2') e = {14:('R', 'T')} diffs, l = seqstats.get_differences(seq1, seq2, aligned = True) self.assertEqual(diffs, e) self.assertEqual(l, 11) diffs, l = seqstats.get_differences(seq1, seq2, aligned = True, ignore_gaps = False) e = {14: ('R', 'T'), 2: ('-', 'N'), 10: ('T', '-')} self.assertEqual(diffs, e) self.assertEqual(l, 15)
def test_aligned_aa(self): seq1 = SeqRecord(Seq('AC--DEFGI-LBATR'), id='1') seq2 = SeqRecord(Seq('ACN-DEFGI--DATT'), id='2') e = {14:('R', 'T')} diffs, l = seqstats.get_differences(seq1, seq2, aligned = True, alphabet = alphabets.ProteinAlphabet()) self.assertEqual(diffs, e) self.assertEqual(l, 11) diffs, l = seqstats.get_differences(seq1, seq2, aligned = True, alphabet = alphabets.ProteinAlphabet(), ignore_gaps = False) e = {14: ('R', 'T'), 2: ('-', 'N'), 10: ('L', '-')} self.assertEqual(diffs, e) self.assertEqual(l, 15)
def test_unaligned(self): seq1 = SeqRecord(Seq('AC--GTNAC-TYATR'), id='1') seq2 = SeqRecord(Seq('ACN-GTAAC--CATT'), id='2') diffs, l = seqstats.get_differences(seq1, seq2, aligned = False, ignore_gaps = False, aligner_tools = None) e = {12: ('R', 'T'), 2: ('-', 'N'), 8: ('T', '-')} self.assertEqual(diffs, e) self.assertEqual(l, 13) seq1 = SeqRecord(Seq('ATCCGT'), id='1') seq2 = SeqRecord(Seq('ACCGT'), id='2') diffs, l = seqstats.get_differences(seq1, seq2, aligned = False, ignore_gaps = True, aligner_tools = None) self.assertEqual(diffs, {}) self.assertEqual(l, 5) diffs, l = seqstats.get_differences(seq1, seq2, aligned = False, ignore_gaps = False, aligner_tools = None) self.assertEqual(diffs, {1: ('T', '-')}) self.assertEqual(l, 6)