Exemplo n.º 1
0
    def test_from_dict_to_dict_roundtrip(self):
        d = {}
        self.assertEqual(TabularMSA.from_dict(d).to_dict(), d)

        # can roundtrip even with mixed key types
        d1 = {'a': DNA('CAT'), 42: DNA('TAG')}
        d2 = TabularMSA.from_dict(d1).to_dict()
        self.assertEqual(d2, d1)
        self.assertIs(d1['a'], d2['a'])
        self.assertIs(d1[42], d2[42])
Exemplo n.º 2
0
    def test_from_dict_to_dict_roundtrip(self):
        d = {}
        self.assertEqual(TabularMSA.from_dict(d).to_dict(), d)

        # can roundtrip even with mixed key types
        d1 = {'a': DNA('CAT'), 42: DNA('TAG')}
        d2 = TabularMSA.from_dict(d1).to_dict()
        self.assertEqual(d2, d1)
        self.assertIs(d1['a'], d2['a'])
        self.assertIs(d1[42], d2[42])
Exemplo n.º 3
0
 def test_from_dict_multiple_sequences(self):
     msa = TabularMSA.from_dict(
         {1: DNA('ACG'), 2: DNA('GGG'), 3: DNA('TAG')})
     # Sort because order is arbitrary.
     msa.sort()
     self.assertEqual(
         msa,
         TabularMSA([DNA('ACG'), DNA('GGG'), DNA('TAG')], keys=[1, 2, 3]))
Exemplo n.º 4
0
 def test_from_dict_multiple_sequences(self):
     msa = TabularMSA.from_dict({
         1: DNA('ACG'),
         2: DNA('GGG'),
         3: DNA('TAG')
     })
     # Sort because order is arbitrary.
     msa.sort()
     self.assertEqual(
         msa,
         TabularMSA(
             [DNA('ACG'), DNA('GGG'), DNA('TAG')], keys=[1, 2, 3]))
Exemplo n.º 5
0
 def test_from_dict_invalid_input(self):
     # Basic test to make sure error-checking in the TabularMSA constructor
     # is being invoked.
     with six.assertRaisesRegex(self, ValueError, 'same length'):
         TabularMSA.from_dict({'a': DNA('ACG'), 'b': DNA('ACGT')})
Exemplo n.º 6
0
 def test_from_dict_single_sequence(self):
     self.assertEqual(TabularMSA.from_dict({'foo': DNA('ACGT')}),
                      TabularMSA([DNA('ACGT')], keys=['foo']))
Exemplo n.º 7
0
 def test_from_dict_empty(self):
     self.assertEqual(TabularMSA.from_dict({}), TabularMSA([], keys=[]))
Exemplo n.º 8
0
 def test_from_dict_invalid_input(self):
     # Basic test to make sure error-checking in the TabularMSA constructor
     # is being invoked.
     with six.assertRaisesRegex(self, ValueError, 'same length'):
         TabularMSA.from_dict({'a': DNA('ACG'), 'b': DNA('ACGT')})
Exemplo n.º 9
0
 def test_from_dict_single_sequence(self):
     self.assertEqual(TabularMSA.from_dict({'foo': DNA('ACGT')}),
                      TabularMSA([DNA('ACGT')], keys=['foo']))
Exemplo n.º 10
0
 def test_from_dict_empty(self):
     self.assertEqual(TabularMSA.from_dict({}), TabularMSA([], keys=[]))