예제 #1
0
 def testFrcStates(self):
     # Test that the sum of all states results in the Receptor conc
     func = (lambda l, p, r, m: True)
     receptor = ReceptorStates(self.model.getResult())
     total = receptor.frcStates(func)
     b = all([abs(1 - x) < 0.01 for x in total])
     self.assertTrue(b)
예제 #2
0
 def testSumStates(self):
     # Test that the sum of all states results in the Receptor conc
     func = (lambda l, p, r, m: True)
     receptor = ReceptorStates(self.model.getResult())
     total = receptor.sumStates(func)
     T = float(T2_CONC)
     b = all([abs(T - x) / T < 0.01 for x in total])
     self.assertTrue(b)
예제 #3
0
 def testBasic(self):
     receptor = ReceptorStates(self.model.getResult())
     self.assertEqual(len(receptor._states), NUM_STATES)
     # Select a state that should have no occupancy
     state = [
         s for s in receptor._states
         if s.is_boundL and (s.methylation == 2) and s.is_phosphorylated
     ][0]
     b = all([x < 0.01 for x in state.getNominalData()])
     self.assertTrue(b)
예제 #4
0
class TestStateAggregationFactory(unittest.TestCase):
    def setUp(self):
        self.model = ChemotaxisModel()
        self.model.initialize()
        self.model.run(start=0, end=10)
        self.receptor = ReceptorStates(self.model.getResult())
        self.factory = StateAggregationFactory(self.receptor)

    def testGetFunc(self):
        func = self.factory._getFunc("_", 0, lambda x: True)
        self.assertTrue(func(True))
        func = self.factory._getFunc("T", 0, lambda x: x in ["T", "F"])
        self.assertTrue(func(True))
        self.assertFalse(func(False))
        with self.assertRaises(ValueError):
            self.factory._getFunc("T", 0, lambda x: x in ["F"])
        func = self.factory._getFunc("2", 0, lambda x: int(x) < 5)
        self.assertTrue(func(2))
        self.assertFalse(func(3))

    def testV(self):
        value = self.factory.v("t____")
        expected = self.receptor.sumStates(lambda l, p, r, m: True)
        pairs = zip(value, expected)
        b = all([abs(x - y) < abs(y) * 0.001 for x, y in pairs])
        self.assertTrue(b)
        count = len(expected)
        names = ["_T_3", "T__3", "TT__", "T___", "_T__", "___3", "____"]
        for name in names:
            try:
                variable = "f%s" % name
                value = self.factory.v(variable)
                self.assertEqual(len(value), count)
                variable = "t%s" % name
                value = self.factory.v(variable)
                self.assertEqual(len(value), count)
            except Exception as e:
                import pdb
                pdb.set_trace()
                pass
예제 #5
0
 def setUp(self):
     self.model = ChemotaxisModel()
     self.model.initialize()
     self.model.run(start=0, end=10)
     self.receptor = ReceptorStates(self.model.getResult())
예제 #6
0
 def setUp(self):
     self.model = ChemotaxisModel()
     self.model.initialize()
     self.model.run(start=0, end=10)
     self.receptor = ReceptorStates(self.model.getResult())
     self.factory = StateAggregationFactory(self.receptor)
예제 #7
0
 def _testSelectStates(self, func, expected):
     receptor = ReceptorStates(self.model.getResult())
     states = receptor.selectStates(func)
     self.assertEqual(len(states), expected)