Example #1
0
    def __init__(self, mathType=float):
        ConfigFactory.__init__(self)
        self.mathType = mathType
        for obj in [
            HMM,
            State,
            GeneralizedHMM,
            GeneralizedState,
            GeneralizedPairHMM,
            GeneralizedPairState,
            PairRepeatState,
            HighOrderState,
            HighOrderRepeatState,
            RepeatLengthDistribution,
            SimpleMatchState,
            SimpleIndelState,
            LogNum,
        ]:

            self.addFunction(obj.__name__, getInitializerObject(obj, mathType))

        for (name, function) in [
            ("JukesCantorGenerator", JukesCantorGenerator),
            ("backgroundprob", BackgroundProbabilityGenerator),
        ]:
            self.addFunction(name, getInitializerFunction(function, mathType))

        for (name, constant) in [
            # STUB
        ]:
            self.addConstant(name, constant)
Example #2
0
 def test_configLoadingAndSaving(self):
     input_file = "data/test_data/ConfigFactoryTestData.js"
     a = ConfigFactory()
     a.addObject(ConfigObject)
     X = a.load(input_file)
     self.assertEqual(type(X[1]), type(ConfigObject()), 
                      "objectHook does not work")
     X[1] = X[1].toJSON()
     Y = [{'1': 2, 'lol': 1.4}, 
          {'__name__': 'ConfigObject'}, 
          [1, 2, 3, 4, {'1': 2}]]
     self.assertEqual(X[0], Y[0], "loading of json does not work")
     self.assertEqual(X[2], Y[2], "loading of json does not work")
     self.assertEqual(X[1], Y[1], "saving to \"json\" is not working: " + \
                                  str(X) + " != " + str(Y))
     self.assertEqual(X, Y, "this should not happened")
Example #3
0
 def test_configLoadingAndSaving(self):
     input_file = "data/test_data/ConfigFactoryTestData.js"
     a = ConfigFactory()
     a.addObject(ConfigObject)
     X = a.load(input_file)
     self.assertEqual(type(X[1]), type(ConfigObject()),
                      "objectHook does not work")
     X[1] = X[1].toJSON()
     Y = [{
         '1': 2,
         'lol': 1.4
     }, {
         '__name__': 'ConfigObject'
     }, [1, 2, 3, 4, {
         '1': 2
     }]]
     self.assertEqual(X[0], Y[0], "loading of json does not work")
     self.assertEqual(X[2], Y[2], "loading of json does not work")
     self.assertEqual(X[1], Y[1], "saving to \"json\" is not working: " + \
                                  str(X) + " != " + str(Y))
     self.assertEqual(X, Y, "this should not happened")