Beispiel #1
0
def test_harder_hubscore():
    # depends on tpt.committors and tpt.conditional_committors

    assignments = np.random.randint(10, size=(10, 1000))
    msm = MarkovStateModel(lag_time=1)
    msm.fit(assignments)

    hub_scores = tpt.hub_scores(msm)

    ref_hub_scores = np.zeros(10)
    for A in range(10):
        for B in range(10):
            committors = tpt.committors(A, B, msm)
            denom = msm.transmat_[A, :].dot(committors)
            for C in range(10):
                if A == B or A == C or B == C:
                    continue
                cond_committors = tpt.conditional_committors(A, B, C, msm)

                temp = 0.0
                for i in range(10):
                    if i in [A, B]:
                        continue
                    temp += cond_committors[i] * msm.transmat_[A, i]
                temp /= denom

                ref_hub_scores[C] += temp

    ref_hub_scores /= (9 * 8)

    npt.assert_array_almost_equal(ref_hub_scores, hub_scores)
Beispiel #2
0
def test_harder_hubscore():
    # depends on tpt.committors and tpt.conditional_committors

    assignments = np.random.randint(10, size=(10, 1000))
    msm = MarkovStateModel(lag_time=1)
    msm.fit(assignments)

    hub_scores = tpt.hub_scores(msm)

    ref_hub_scores = np.zeros(10)
    for A in xrange(10):
        for B in xrange(10):
            committors = tpt.committors(A, B, msm)
            denom = msm.transmat_[A, :].dot(committors)  #+ msm.transmat_[A, B]
            for C in xrange(10):
                if A == B or A == C or B == C:
                    continue
                cond_committors = tpt.conditional_committors(A, B, C, msm)

                temp = 0.0
                for i in xrange(10):
                    if i in [A, B]:
                        continue
                    temp += cond_committors[i] * msm.transmat_[A, i]
                temp /= denom

                ref_hub_scores[C] += temp

    ref_hub_scores /= (9 * 8)

    #print(ref_hub_scores, hub_scores)

    npt.assert_array_almost_equal(ref_hub_scores, hub_scores)
Beispiel #3
0
    def generate_next_inpcrds(self, msm, clusters):
        """
        Writes the input coordinate files for the next generation.
        Each file is in its own numbered directory and called just "inpcrd"
        """
        # Check if inpcrds are already made
        sysdir = os.path.join(self.dir, "systems", str(self.generation + 1))
        if len(glob(os.path.join(sysdir, "*.inpcrd"))) == self.nreps:
            print("   Already have samplers... skipping inpcrd_generation")
            return

        # Make directory to contain topologies and inpcrds
        if not os.path.isdir(os.path.join(self.dir, "systems")):
            os.mkdir(os.path.join(self.dir, "systems"))
        gendir = os.path.join(self.dir, "systems", str(self.generation + 1))
        if not os.path.isdir(gendir):
            os.mkdir(gendir)

        scores = hub_scores(msm)
        utils.dump(scores, "mmsm_scores.pkl")
        gen = InpcrdGenerator(prodfiles=self.prodfiles,
                              clusters=clusters,
                              msm=msm,
                              scores=scores,
                              config=self.config,
                              criteria=self.config.get("model",
                                                       "criteria",
                                                       fallback="hub_scores"))
        gen.run()
Beispiel #4
0
def test_hubscore():
    #Make an actual hub!

    tprob = np.array([[0.8, 0.0, 0.2, 0.0, 0.0], [0.0, 0.8, 0.2, 0.0, 0.0],
                      [0.1, 0.1, 0.6, 0.1, 0.1], [0.0, 0.0, 0.2, 0.8, 0.0],
                      [0.0, 0.0, 0.2, 0.0, 0.8]])

    msm = MarkovStateModel(lag_time=1)
    msm.transmat_ = tprob
    msm.n_states_ = 5

    score = tpt.hub_scores(msm, 2)[0]

    assert score == 1.0
Beispiel #5
0
def test_hubscore():
    # Make an actual hub!

    tprob = np.array([[0.8, 0.0, 0.2, 0.0, 0.0],
                      [0.0, 0.8, 0.2, 0.0, 0.0],
                      [0.1, 0.1, 0.6, 0.1, 0.1],
                      [0.0, 0.0, 0.2, 0.8, 0.0],
                      [0.0, 0.0, 0.2, 0.0, 0.8]])

    msm = MarkovStateModel(lag_time=1)
    msm.transmat_ = tprob
    msm.n_states_ = 5

    score = tpt.hub_scores(msm, 2)[0]

    assert score == 1.0