Пример #1
0
    def setUp(self):
        database1 = DictDatabase()
        database1.set_reaction('rxn_1', parse_reaction('|A| => |B|'))
        database1.set_reaction('rxn_2', parse_reaction('|B| => |C| + |D|'))
        database1.set_reaction('rxn_3', parse_reaction('|D| <=> |E|'))
        database1.set_reaction('rxn_4', parse_reaction('|F| => |G|'))

        database2 = DictDatabase()
        database2.set_reaction('rxn_2', parse_reaction('|B| => |C|'))
        database2.set_reaction('rxn_3', parse_reaction('|C| => |D|'))
        database2.set_reaction('rxn_4', parse_reaction('|F| <=> |G|'))
        database2.set_reaction('rxn_5', parse_reaction('|G| + |I| <=> |H|'))

        self.database = ChainedDatabase(database2, database1)
Пример #2
0
class TestChainedDatabase(unittest.TestCase):
    def setUp(self):
        database1 = DictDatabase()
        database1.set_reaction('rxn_1', parse_reaction('|A| => |B|'))
        database1.set_reaction('rxn_2', parse_reaction('|B| => |C| + |D|'))
        database1.set_reaction('rxn_3', parse_reaction('|D| <=> |E|'))
        database1.set_reaction('rxn_4', parse_reaction('|F| => |G|'))

        database2 = DictDatabase()
        database2.set_reaction('rxn_2', parse_reaction('|B| => |C|'))
        database2.set_reaction('rxn_3', parse_reaction('|C| => |D|'))
        database2.set_reaction('rxn_4', parse_reaction('|F| <=> |G|'))
        database2.set_reaction('rxn_5', parse_reaction('|G| + |I| <=> |H|'))

        self.database = ChainedDatabase(database2, database1)

    def test_has_reaction_in_lower_database(self):
        self.assertTrue(self.database.has_reaction('rxn_1'))

    def test_has_reaction_in_upper_new(self):
        self.assertTrue(self.database.has_reaction('rxn_5'))

    def test_has_reaction_in_upper_shadowing(self):
        self.assertTrue(self.database.has_reaction('rxn_3'))

    def test_is_reversible_in_lower_database(self):
        self.assertFalse(self.database.is_reversible('rxn_1'))

    def test_is_reversible_in_upper_new(self):
        self.assertTrue(self.database.is_reversible('rxn_5'))

    def test_is_reversible_in_upper_shadowing(self):
        self.assertFalse(self.database.is_reversible('rxn_3'))

    def test_get_compound_reactions_in_upper(self):
        reactions = set(self.database.get_compound_reactions(Compound('H')))
        self.assertEqual(reactions, {'rxn_5'})

    def test_get_compound_reactions_in_lower(self):
        reactions = set(self.database.get_compound_reactions(Compound('A')))
        self.assertEqual(reactions, {'rxn_1'})

    def test_get_compound_reactions_in_both(self):
        reactions = set(self.database.get_compound_reactions(Compound('B')))
        self.assertEqual(reactions, {'rxn_1', 'rxn_2'})

    def test_get_compound_reactions_in_both_and_shadowed(self):
        reactions = set(self.database.get_compound_reactions(Compound('D')))
        self.assertEqual(reactions, {'rxn_3'})
Пример #3
0
class TestChainedDatabase(unittest.TestCase):
    def setUp(self):
        database1 = DictDatabase()
        database1.set_reaction('rxn_1', parse_reaction('|A| => |B|'))
        database1.set_reaction('rxn_2', parse_reaction('|B| => |C| + |D|'))
        database1.set_reaction('rxn_3', parse_reaction('|D| <=> |E|'))
        database1.set_reaction('rxn_4', parse_reaction('|F| => |G|'))

        database2 = DictDatabase()
        database2.set_reaction('rxn_2', parse_reaction('|B| => |C|'))
        database2.set_reaction('rxn_3', parse_reaction('|C| => |D|'))
        database2.set_reaction('rxn_4', parse_reaction('|F| <=> |G|'))
        database2.set_reaction('rxn_5', parse_reaction('|G| + |I| <=> |H|'))

        self.database = ChainedDatabase(database2, database1)

    def test_has_reaction_in_lower_database(self):
        self.assertTrue(self.database.has_reaction('rxn_1'))

    def test_has_reaction_in_upper_new(self):
        self.assertTrue(self.database.has_reaction('rxn_5'))

    def test_has_reaction_in_upper_shadowing(self):
        self.assertTrue(self.database.has_reaction('rxn_3'))

    def test_is_reversible_in_lower_database(self):
        self.assertFalse(self.database.is_reversible('rxn_1'))

    def test_is_reversible_in_upper_new(self):
        self.assertTrue(self.database.is_reversible('rxn_5'))

    def test_is_reversible_in_upper_shadowing(self):
        self.assertFalse(self.database.is_reversible('rxn_3'))

    def test_get_compound_reactions_in_upper(self):
        reactions = set(self.database.get_compound_reactions(Compound('H')))
        self.assertEqual(reactions, { 'rxn_5' })

    def test_get_compound_reactions_in_lower(self):
        reactions = set(self.database.get_compound_reactions(Compound('A')))
        self.assertEqual(reactions, { 'rxn_1' })

    def test_get_compound_reactions_in_both(self):
        reactions = set(self.database.get_compound_reactions(Compound('B')))
        self.assertEqual(reactions, { 'rxn_1', 'rxn_2' })

    def test_get_compound_reactions_in_both_and_shadowed(self):
        reactions = set(self.database.get_compound_reactions(Compound('D')))
        self.assertEqual(reactions, { 'rxn_3' })
Пример #4
0
    def setUp(self):
        database1 = DictDatabase()
        database1.set_reaction('rxn_1', parse_reaction('|A| => |B|'))
        database1.set_reaction('rxn_2', parse_reaction('|B| => |C| + |D|'))
        database1.set_reaction('rxn_3', parse_reaction('|D| <=> |E|'))
        database1.set_reaction('rxn_4', parse_reaction('|F| => |G|'))

        database2 = DictDatabase()
        database2.set_reaction('rxn_2', parse_reaction('|B| => |C|'))
        database2.set_reaction('rxn_3', parse_reaction('|C| => |D|'))
        database2.set_reaction('rxn_4', parse_reaction('|F| <=> |G|'))
        database2.set_reaction('rxn_5', parse_reaction('|G| + |I| <=> |H|'))

        self.database = ChainedDatabase(database2, database1)