def validate_sensor_make_cases(): # [ Recog, Stem1, Stem2, binding_ratio, maxunknownpercent, numfoldrange, maxenergy, expected ] tests = [ ["ATTA", "CGA", "TCC", (0.9, 1.1), 0.2, (2, 4), -1.3, False], ["ATTA", "CCC", "CGC", (0.9, 1.1), 0.2, (2, 4), -10, False], ["ATTA", "CCC", "CGC", (0.6, 0.7), 0.2, (2, 4), None, True], ["ATTA", "GCG", "CCC", (0.9, 1.1), 0.2, None, None, False], ["ATTA", "TCA", "CC", (0.2, 0.8), 0.2, None, 0, True], ["ATTAGC", "TCCA", "CCCC", (0.9, 1.1), 0.2, None, None, False], ] for test in tests: sensor = util.Sensor(test[0]) sensor.SetStem1(test[1]) sensor.SetStem2(test[2]) test_file = test_dir + "validate_sensor/" + str(sensor) tosave = open(test_file, "w") folds = unafold.parse_ct(unafold.run_hybrid_ss_min(sensor)) scores = unafold.score_sensor(sensor, folds) pickle.dump((sensor, scores, folds, test[3], test[4], test[5], test[6], test[7]), tosave) print ("validate_sensor_make_cases(): storing folds and scores for %s" % str(sensor)) tosave.close()
def score_sensor_make_case(sensor): folds = unafold.parse_ct(unafold.run_hybrid_ss_min(sensor, True)) scores = unafold.score_sensor(sensor, folds) tosave_filename = test_dir + "score_sensor/" + str(sensor) tosave = open(tosave_filename, "w") pickle.dump((sensor, folds, scores), tosave) print ("score_sensor_make_case(%s): pickling %s" % (sensor, (folds, scores))) tosave.close()
def _run_score_sensor(sensor, folds, expected_scores): scores = unafold.score_sensor(sensor, folds) print ("_score_sensor_test(%s): expected %s, got %s" % (sensor, expected_scores, scores)) assert scores == expected_scores