def test_recode_dense_alignment_to_orig(self):
     """recode_dense_alignment: recode aln to orig returns original aln
     """
     # provided with alphabet_id
     self.assertEqual(recode_dense_alignment(self.aln, alphabet_id="orig"), self.aln)
     # provided with alphabet_def
     self.assertEqual(recode_dense_alignment(self.aln, alphabet_def=self.orig), self.aln)
Esempio n. 2
0
 def test_recode_dense_alignment_leaves_original_alignment_intact(self):
     """recode_dense_alignment: leaves input alignment intact
     """
     # provided with alphabet_id
     actual = recode_dense_alignment(self.aln, alphabet_id='charge_2')
     self.assertNotEqual(actual,self.aln)
     # provided with alphabet_def
     actual = recode_dense_alignment(self.aln, alphabet_def=self.charge_2)
     self.assertNotEqual(actual,self.aln)
 def test_recode_dense_alignment_to_orig(self):
     """recode_dense_alignment: recode aln to orig returns original aln
     """
     # provided with alphabet_id
     self.assertEqual(recode_dense_alignment(\
      self.aln, alphabet_id='orig'), self.aln)
     # provided with alphabet_def
     self.assertEqual(recode_dense_alignment(\
      self.aln, alphabet_def=self.orig), self.aln)
 def test_recode_dense_alignment_leaves_original_alignment_intact(self):
     """recode_dense_alignment: leaves input alignment intact
     """
     # provided with alphabet_id
     actual = recode_dense_alignment(self.aln, alphabet_id='charge_2')
     self.assertNotEqual(actual, self.aln)
     # provided with alphabet_def
     actual = recode_dense_alignment(self.aln, alphabet_def=self.charge_2)
     self.assertNotEqual(actual, self.aln)
Esempio n. 5
0
 def test_recode_dense_alignment_handles_all_ids_and_defs_wo_error(self):
     """recode_dense_alignment: handles pre-defined alphabets w/o error"""
     for alphabet_id, alphabet_def in alphabets.items():
         try:
             recode_dense_alignment(self.aln,alphabet_id=alphabet_id)
         except ValueError:
             raise AssertionError, "Failed on id: %s" % alphabet_id
         try:
             recode_dense_alignment(self.aln,alphabet_def=alphabet_def)
         except ValueError:
             raise AssertionError, "Failed on def: %s" % str(alphabet_def)
 def test_recode_dense_alignment_handles_all_ids_and_defs_wo_error(self):
     """recode_dense_alignment: handles pre-defined alphabets w/o error"""
     for alphabet_id, alphabet_def in list(alphabets.items()):
         try:
             recode_dense_alignment(self.aln, alphabet_id=alphabet_id)
         except ValueError:
             raise AssertionError("Failed on id: %s" % alphabet_id)
         try:
             recode_dense_alignment(self.aln, alphabet_def=alphabet_def)
         except ValueError:
             raise AssertionError("Failed on def: %s" % str(alphabet_def))
    def test_recode_dense_alignment(self):
        """recode_dense_alignment: recode alignment to charge_2 alpha works
        """
        expected_c2 = DenseAlignment(data={"1": "AKKAKAK", "2": "AKK-KAK", "3": "AAAAAA-"})
        expected_h3 = DenseAlignment(data={"1": "PRRPRPR", "2": "PRR-RPR", "3": "PPPPYY-"})
        expected_aa = DenseAlignment(data={"1": "AAAAAAA", "2": "AAA-AAA", "3": "AAAAAA-"})

        # provided with alphabet_id
        actual = recode_dense_alignment(self.aln, alphabet_id="charge_2")
        self.assertEqual(actual, expected_c2)
        # provided with alphabet_def
        actual = recode_dense_alignment(self.aln, alphabet_def=self.charge_2)
        self.assertEqual(actual, expected_c2)

        # different alphabet
        actual = recode_dense_alignment(self.aln, alphabet_id="hydropathy_3")
        self.assertEqual(actual, expected_h3)
        actual = recode_dense_alignment(self.aln, alphabet_def=self.hydropathy_3)
        self.assertEqual(actual, expected_h3)

        # different alphabet
        actual = recode_dense_alignment(self.aln, alphabet_def=self.all_to_a)
        self.assertEqual(actual, expected_aa)

        # original charactars which aren't remapped are let in original state
        actual = recode_dense_alignment(self.aln, alphabet_def=[("a", "b")])
        self.assertEqual(actual, self.aln)

        # non-alphabetic character mapped same as alphabetic characters
        actual = recode_dense_alignment(self.aln, alphabet_def=[(".", "-")])
        expected = DenseAlignment(data={"1": "CDDFBXZ", "2": "CDD.BXZ", "3": "AAAASS."})
        self.assertEqual(actual, expected)
Esempio n. 8
0
    def test_recode_dense_alignment(self):
        """recode_dense_alignment: recode alignment to charge_2 alpha works
        """
        expected_c2 = DenseAlignment(data=\
            {'1':'AKKAKAK','2':'AKK-KAK','3':'AAAAAA-'})
        expected_h3 = DenseAlignment(data=\
            {'1':'PRRPRPR','2':'PRR-RPR','3':'PPPPYY-'})
        expected_aa = DenseAlignment(data=\
            {'1':'AAAAAAA','2':'AAA-AAA','3':'AAAAAA-'})

        # provided with alphabet_id
        actual = recode_dense_alignment(self.aln, alphabet_id='charge_2')
        self.assertEqual(actual,expected_c2)
        # provided with alphabet_def
        actual = recode_dense_alignment(self.aln, alphabet_def=self.charge_2)
        self.assertEqual(actual,expected_c2)

        # different alphabet
        actual = recode_dense_alignment(self.aln, alphabet_id='hydropathy_3')
        self.assertEqual(actual,expected_h3)
        actual = recode_dense_alignment(self.aln,\
          alphabet_def=self.hydropathy_3)
        self.assertEqual(actual,expected_h3)
        
        # different alphabet
        actual = recode_dense_alignment(self.aln, alphabet_def=self.all_to_a)
        self.assertEqual(actual,expected_aa)

        # original charactars which aren't remapped are let in original state
        actual = recode_dense_alignment(self.aln, alphabet_def=[('a','b')])
        self.assertEqual(actual,self.aln)
        
        # non-alphabetic character mapped same as alphabetic characters
        actual = recode_dense_alignment(self.aln, alphabet_def=[('.','-')])
        expected = DenseAlignment(\
         data={'1':'CDDFBXZ', '2':'CDD.BXZ', '3':'AAAASS.'})
        self.assertEqual(actual,expected)
    def test_recode_dense_alignment(self):
        """recode_dense_alignment: recode alignment to charge_2 alpha works
        """
        expected_c2 = DenseAlignment(data=\
            {'1':'AKKAKAK','2':'AKK-KAK','3':'AAAAAA-'})
        expected_h3 = DenseAlignment(data=\
            {'1':'PRRPRPR','2':'PRR-RPR','3':'PPPPYY-'})
        expected_aa = DenseAlignment(data=\
            {'1':'AAAAAAA','2':'AAA-AAA','3':'AAAAAA-'})

        # provided with alphabet_id
        actual = recode_dense_alignment(self.aln, alphabet_id='charge_2')
        self.assertEqual(actual, expected_c2)
        # provided with alphabet_def
        actual = recode_dense_alignment(self.aln, alphabet_def=self.charge_2)
        self.assertEqual(actual, expected_c2)

        # different alphabet
        actual = recode_dense_alignment(self.aln, alphabet_id='hydropathy_3')
        self.assertEqual(actual, expected_h3)
        actual = recode_dense_alignment(self.aln,\
          alphabet_def=self.hydropathy_3)
        self.assertEqual(actual, expected_h3)

        # different alphabet
        actual = recode_dense_alignment(self.aln, alphabet_def=self.all_to_a)
        self.assertEqual(actual, expected_aa)

        # original charactars which aren't remapped are let in original state
        actual = recode_dense_alignment(self.aln, alphabet_def=[('a', 'b')])
        self.assertEqual(actual, self.aln)

        # non-alphabetic character mapped same as alphabetic characters
        actual = recode_dense_alignment(self.aln, alphabet_def=[('.', '-')])
        expected = DenseAlignment(\
         data={'1':'CDDFBXZ', '2':'CDD.BXZ', '3':'AAAASS.'})
        self.assertEqual(actual, expected)