Beispiel #1
0
    def test_update_species(self):
        species = Species(name='H2O')
        mixture = Mixture(species=[species])

        self.assertTrue(species in mixture.update_species())

        dna = DNA(name='test_DNA')
        mixture.add_components(dna)

        crn_list = mixture.update_species()

        for s_dna in dna.update_species():
            self.assertTrue(s_dna in crn_list)
Beispiel #2
0
    def test_update_species(self):
        from biocrnpyler import Mixture
        from biocrnpyler import Species
        from biocrnpyler import DNA
        # from biocrnpyler import Dilution

        species = Species(name='H2O')
        mixture = Mixture(species=[species])

        self.assertTrue(species in mixture.update_species())

        dna = DNA(name='test_DNA')
        mixture.add_components(dna)

        crn_list = mixture.update_species()

        for s_dna in dna.update_species():
            self.assertTrue(s_dna in crn_list)
Beispiel #3
0
    def test_update_reactions(self):
        mixture = Mixture()
        with self.assertRaisesRegexp(AttributeError, 'Mixture.crn_species not defined.'):
            mixture.update_reactions()

        component = Component(name='test_component')

        # creating a mock update function to decouple the update process from the rest of the code
        def mock_update_reactions():
            rxn = Reaction(inputs=[], outputs=[], k=0.1)
            return [rxn]

        component.update_reactions = mock_update_reactions

        mixture.add_components(component)
        mixture.update_species()
        crn_rxn = mixture.update_reactions()
        crn_rxn_mock = mock_update_reactions()
        self.assertEqual(crn_rxn, crn_rxn_mock)
Beispiel #4
0
    def test_update_reactions(self):
        from biocrnpyler import Mixture
        from biocrnpyler import Reaction
        from biocrnpyler import Component

        mixture = Mixture()
        with self.assertRaises(AttributeError):
            mixture.update_reactions()

        component = Component(name='test_component')

        def mock_update_reactions():
            rxn = Reaction(inputs=[], outputs=[], k=0.1)
            return [rxn]

        component.update_reactions = mock_update_reactions

        mixture.add_components(component)
        mixture.update_species()
        crn_rxn = mixture.update_reactions()
        crn_rxn_mock = mock_update_reactions()
        self.assertEqual(crn_rxn, crn_rxn_mock)