def test_transform(): model = MarkovStateModel() model.fit([['a', 'a', 'b', 'b', 'c', 'c', 'a', 'a']]) assert model.mapping_ == {'a': 0, 'b': 1, 'c': 2} v = model.transform([['a', 'b', 'c']]) assert isinstance(v, list) assert len(v) == 1 assert v[0].dtype == np.int np.testing.assert_array_equal(v[0], [0, 1, 2]) v = model.transform([['a', 'b', 'c', 'd']], 'clip') assert isinstance(v, list) assert len(v) == 1 assert v[0].dtype == np.int np.testing.assert_array_equal(v[0], [0, 1, 2]) v = model.transform([['a', 'b', 'c', 'd']], 'fill') assert isinstance(v, list) assert len(v) == 1 assert v[0].dtype == np.float np.testing.assert_array_equal(v[0], [0, 1, 2, np.nan]) v = model.transform([['a', 'a', 'SPLIT', 'b', 'b', 'b']], 'clip') assert isinstance(v, list) assert len(v) == 2 assert v[0].dtype == np.int assert v[1].dtype == np.int np.testing.assert_array_equal(v[0], [0, 0]) np.testing.assert_array_equal(v[1], [1, 1, 1])
def test_transform(): model = MarkovStateModel() model.fit([['a', 'a', 'b', 'b', 'c', 'c', 'a', 'a']]) assert model.mapping_ == {'a': 0, 'b': 1, 'c': 2} v = model.transform([['a', 'b', 'c']]) assert isinstance(v, list) assert len(v) == 1 assert v[0].dtype == np.int np.testing.assert_array_equal(v[0], [0, 1, 2]) v = model.transform([['a', 'b', 'c', 'd']], 'clip') assert isinstance(v, list) assert len(v) == 1 assert v[0].dtype == np.int np.testing.assert_array_equal(v[0], [0, 1, 2]) v = model.transform([['a', 'b', 'c', 'd']], 'fill') assert isinstance(v, list) assert len(v) == 1 assert v[0].dtype == np.float np.testing.assert_array_equal(v[0], [0, 1, 2, np.nan]) v = model.transform([['a', 'a', 'SPLIT', 'b', 'b', 'b']], 'clip') assert isinstance(v, list) assert len(v) == 2 assert v[0].dtype == np.int assert v[1].dtype == np.int np.testing.assert_array_equal(v[0], [0, 0]) np.testing.assert_array_equal(v[1], [1, 1, 1])
def fit_msms(yaml_file): mdl_params = yaml_file["mdl_params"] current_mdl_params={} for i in mdl_params.keys(): if i.startswith("msm__"): current_mdl_params[i.split("msm__")[1]] = mdl_params[i] for protein in yaml_file["protein_list"]: with enter_protein_mdl_dir(yaml_file, protein): print(protein) assignments = verboseload("assignments.pkl") msm_mdl = MarkovStateModel(**current_mdl_params).fit( [assignments[i] for i in assignments.keys()]) verbosedump(msm_mdl, "msm_mdl.pkl") fixed_assignments = {} for i in assignments.keys(): fixed_assignments[i] = msm_mdl.transform( assignments[i], mode='fill')[0] verbosedump(fixed_assignments, 'fixed_assignments.pkl') return
def fit_msms(yaml_file): mdl_params = yaml_file["mdl_params"] current_mdl_params={} for i in mdl_params.keys(): if i.startswith("msm__"): current_mdl_params[i.split("msm__")[1]] = mdl_params[i] for protein in yaml_file["protein_list"]: with enter_protein_mdl_dir(yaml_file, protein): print(protein) assignments = verboseload("assignments.pkl") msm_mdl = MarkovStateModel(**current_mdl_params).fit( [assignments[i] for i in assignments.keys()]) verbosedump(msm_mdl, "msm_mdl.pkl") fixed_assignments = {} for i in assignments.keys(): fixed_assignments[i] = msm_mdl.transform( assignments[i], mode='fill')[0] verbosedump(fixed_assignments, 'fixed_assignments.pkl') return