Ejemplo n.º 1
0
    def setUpClass(cls):
        path = pkg_resources.resource_filename(__name__, 'data') + os.path.sep
        cls.pdb_file = os.path.join(path, 'bpti_ca.pdb')
        cls.feat = MDFeaturizer(cls.pdb_file)
        cls.feat.add_all()
        cls.traj_files = [
            os.path.join(path, 'bpti_001-033.xtc'),
            os.path.join(path, 'bpti_067-100.xtc')
        ]

        # generate HMM with two gaussians
        p = np.array([[0.99, 0.01], [0.01, 0.99]])
        t = 10000
        means = [np.array([-1, 1]), np.array([1, -1])]
        widths = [np.array([0.3, 2]), np.array([0.3, 2])]
        # continuous trajectory
        x = np.zeros((t, 2))
        # hidden trajectory
        dtraj = MarkovStateModel(p).simulate(t)
        for t in range(t):
            s = dtraj[t]
            x[t, 0] = widths[s][0] * np.random.randn() + means[s][0]
            x[t, 1] = widths[s][1] * np.random.randn() + means[s][1]
        cls.generated_data = x
        cls.generated_lag = 10
Ejemplo n.º 2
0
    def setUpClass(cls):
        path = os.path.join(os.path.split(__file__)[0], 'data')
        cls.pdb_file = os.path.join(path, 'bpti_ca.pdb')
        cls.feat = MDFeaturizer(cls.pdb_file)
        cls.feat.add_all()
        cls.traj_files = [
            os.path.join(path, 'bpti_001-033.xtc'),
            os.path.join(path, 'bpti_067-100.xtc')
        ]

        # generate HMM with two gaussians
        p = np.array([[0.99, 0.01], [0.01, 0.99]])
        t = 10000
        means = [np.array([-1, 1]), np.array([1, -1])]
        widths = [np.array([0.3, 2]), np.array([0.3, 2])]
        # continuous trajectory
        x = np.zeros((t, 2))
        # hidden trajectory
        dtraj = msmgen.generate_traj(p, t)
        for t in range(t):
            s = dtraj[t]
            x[t, 0] = widths[s][0] * np.random.randn() + means[s][0]
            x[t, 1] = widths[s][1] * np.random.randn() + means[s][1]
        cls.generated_data = x
        cls.generated_lag = 10
Ejemplo n.º 3
0
 def test_read_single_file_featurizer(self):
     featurizer = MDFeaturizer(self.pdb_file)
     reader = api.source(self.traj_files[0], features=featurizer)
     self.assertIsNotNone(reader, "The reader should not be none.")
     self.assertEqual(reader.topfile, self.pdb_file, "Reader topology file and input topology file should coincide.")
     self.assertListEqual(reader.trajfiles, [self.traj_files[0]], "Reader trajectories and input"
                                                                  " trajectories should coincide.")
     self.assertEqual(reader.featurizer.topologyfile, self.pdb_file, "Featurizers topology file and input "
                                                                     "topology file should coincide.")
Ejemplo n.º 4
0
 def test_invalid_input(self):
     # neither featurizer nor topology file given
     self.assertRaises(ValueError, api.source, self.traj_files, None, None)
     # no input files but a topology file
     self.assertRaises(ValueError, api.source, None, None, self.pdb_file)
     featurizer = MDFeaturizer(self.pdb_file)
     # no input files but a featurizer
     self.assertRaises(ValueError, api.source, None, featurizer, None)
     # empty list of input files
     self.assertRaises(ValueError, api.source, [], None, self.pdb_file)
     # empty tuple of input files
     self.assertRaises(ValueError, api.source, (), None, self.pdb_file)