def test_translate_seqcoll(self): """correctly translate a sequence collection""" seqs = dict(a="ATGAGG", b="ATGTAA") seqs = make_unaligned_seqs(seqs) # trim terminal stops translater = translate_seqs() aa = translater(seqs) self.assertEqual(aa.to_dict(), dict(a="MR", b="M")) self.assertEqual(aa.moltype.label, "protein") # don't trim terminal stops, returns NotCompleted translater = translate_seqs(trim_terminal_stop=False) aa = translater(seqs) self.assertIsInstance(aa, NotCompleted)
def test_translate_aln(self): """correctly translates alignments""" data = dict(a="ATGAGGCCC", b="ATGTTT---") # an array alignment aln = make_aligned_seqs(data) translater = translate_seqs() aa = translater(aln) self.assertEqual(aa.to_dict(), dict(a="MRP", b="MF-")) self.assertEqual(aa.moltype.label, "protein") self.assertIsInstance(aa, type(aln)) # Alignment aln = aln.to_type(array_align=True) aa = translater(aln) self.assertEqual(aa.to_dict(), dict(a="MRP", b="MF-")) self.assertEqual(aa.moltype.label, "protein") self.assertIsInstance(aa, type(aln))