Did I find the right examples for you? yes no

All Samples(16)  |  Call(14)  |  Derive(0)  |  Import(2)

src/c/o/cogent-1.5.3/tests/test_core/test_alphabet.py   cogent(Download)
Note: individual Alphabets are typically in MolType and are tested there.
"""
from cogent.core.alphabet import Enumeration, get_array_type, \
    uint8, uint16, uint32, array, JointEnumeration, CharAlphabet, \
    _make_translation_tables, _make_complement_array
    def test_init(self):
        """JointEnumeration init should work as expected"""
        #should work for alphabet object
        a = JointEnumeration([DnaBases, RnaBases])
        self.assertEqual(len(a), 16)
 
        #should work for arbitrary sequences
        a = JointEnumeration(['TCAG', 'UCAG'])
        self.assertEqual(len(a), 16)
        self.assertEqual(a[0], ('T','U'))
        self.assertEqual(a[-1], ('G','G'))
        self.assertEqual(a._sub_enum_factors, array([[4],[1]]))
 
        #should work for different length sequences
        a = JointEnumeration(['TCA', 'UCAG'])
    def test_toIndices(self):
        """JointEnumeration toIndices should convert tuples correctly"""
        a = JointEnumeration(['TCAG','UCAG'])
        i = a.toIndices([('T','U'),('G','G'),('G','G')])
        self.assertEqual(i, [0, 15, 15])

src/p/y/pycogent-HEAD/tests/test_core/test_alphabet.py   pycogent(Download)
Note: individual Alphabets are typically in MolType and are tested there.
"""
from cogent.core.alphabet import Enumeration, get_array_type, \
    uint8, uint16, uint32, array, JointEnumeration, CharAlphabet, \
    _make_translation_tables, _make_complement_array
    def test_init(self):
        """JointEnumeration init should work as expected"""
        #should work for alphabet object
        a = JointEnumeration([DnaBases, RnaBases])
        self.assertEqual(len(a), 16)
 
        #should work for arbitrary sequences
        a = JointEnumeration(['TCAG', 'UCAG'])
        self.assertEqual(len(a), 16)
        self.assertEqual(a[0], ('T','U'))
        self.assertEqual(a[-1], ('G','G'))
        self.assertEqual(a._sub_enum_factors, array([[4],[1]]))
 
        #should work for different length sequences
        a = JointEnumeration(['TCA', 'UCAG'])
    def test_toIndices(self):
        """JointEnumeration toIndices should convert tuples correctly"""
        a = JointEnumeration(['TCAG','UCAG'])
        i = a.toIndices([('T','U'),('G','G'),('G','G')])
        self.assertEqual(i, [0, 15, 15])