def test_that_all_featurizers_run(): dataset = fetch_alanine_dipeptide() trajectories = dataset["trajectories"] trj0 = trajectories[0][0] atom_indices, pair_indices = subset_featurizer.get_atompair_indices(trj0) featurizer = msmbuilder.featurizer.AtomPairsFeaturizer(pair_indices) X_all = featurizer.transform(trajectories) featurizer = msmbuilder.featurizer.SuperposeFeaturizer(np.arange(15), trj0) X_all = featurizer.transform(trajectories) featurizer = msmbuilder.featurizer.DihedralFeaturizer(["phi" ,"psi"]) X_all = featurizer.transform(trajectories) #featurizer = msmbuilder.featurizer.ContactFeaturizer() # Doesn't work on ALA dipeptide #X_all = featurizer.transform(trajectories) featurizer = msmbuilder.featurizer.RMSDFeaturizer(trj0) X_all = featurizer.transform(trajectories) atom_featurizer0 = subset_featurizer.SubsetAtomPairs(pair_indices, trj0, exponent=-1.0) cosphi = subset_featurizer.SubsetCosPhiFeaturizer(trj0) sinphi = subset_featurizer.SubsetSinPhiFeaturizer(trj0) cospsi = subset_featurizer.SubsetCosPsiFeaturizer(trj0) sinpsi = subset_featurizer.SubsetSinPsiFeaturizer(trj0) featurizer = subset_featurizer.SubsetFeatureUnion([("pairs", atom_featurizer0), ("cosphi", cosphi), ("sinphi", sinphi), ("cospsi", cospsi), ("sinpsi", sinpsi)]) featurizer.subsets = [np.arange(1) for i in range(featurizer.n_featurizers)] X_all = featurizer.transform(trajectories) eq(X_all[0].shape[1], 1 * featurizer.n_featurizers)
def test_SubsetAtomPairs2(): dataset = fetch_alanine_dipeptide() trajectories = dataset["trajectories"] trj0 = trajectories[0][0] atom_indices, pair_indices = subset_featurizer.get_atompair_indices(trj0) featurizer = msmbuilder.featurizer.AtomPairsFeaturizer(pair_indices) X_all0 = featurizer.transform(trajectories) featurizer = subset_featurizer.SubsetAtomPairs(pair_indices, trj0, subset=np.array([0, 1])) X_all = featurizer.transform(trajectories) any([eq(x, x0) for (x, x0) in zip(X_all, X_all0)])
def test_SubsetAtomPairs0(): dataset = fetch_alanine_dipeptide() trajectories = dataset["trajectories"] trj0 = trajectories[0][0] atom_indices, pair_indices = subset_featurizer.get_atompair_indices(trj0) featurizer = msmbuilder.featurizer.AtomPairsFeaturizer(pair_indices) X_all0 = featurizer.transform(trajectories) featurizer = subset_featurizer.SubsetAtomPairs(pair_indices, trj0) featurizer.subset = np.arange(len(pair_indices)) X_all = featurizer.transform(trajectories) any([eq(x, x0) for (x, x0) in zip(X_all, X_all0)])
def test_alanine_dipeptide(): # will produce 0 features because not enough peptides trajectories = AlanineDipeptide().get_cached().trajectories featurizer = msmbuilder.featurizer.AlphaAngleFeaturizer() nothing = featurizer.transform(trajectories) assert (nothing[0].shape[1] == 0)
def test_fs_peptide_nosincos(): # will produce 18 features trajectories = MinimalFsPeptide().get_cached().trajectories featurizer = msmbuilder.featurizer.AlphaAngleFeaturizer(sincos=False) alphas = featurizer.transform(trajectories) assert (alphas[0].shape[1] == 18)
def test_alanine_dipeptide(): # will produce 0 features because not enough peptides dataset = fetch_alanine_dipeptide() trajectories = dataset["trajectories"] featurizer = msmbuilder.featurizer.AlphaAngleFeaturizer() nothing = featurizer.transform(trajectories) assert(nothing[0].shape[1] == 0)
def test_fs_peptide_nosincos(): # will produce 18 features dataset = fetch_fs_peptide() trajectories = dataset["trajectories"] featurizer = msmbuilder.featurizer.AlphaAngleFeaturizer(sincos=False) alphas = featurizer.transform(trajectories) assert(alphas[0].shape[1] == 18)
def test_fs_peptide(): # will produce 36 features dataset = fetch_fs_peptide() trajectories = dataset["trajectories"] featurizer = msmbuilder.featurizer.AlphaAngleFeaturizer() alphas = featurizer.transform(trajectories) assert(alphas[0].shape[1] == 36)
def test_alanine_dipeptide(): # will produce 0 features because not enough peptides dataset = fetch_alanine_dipeptide() trajectories = dataset["trajectories"] featurizer = msmbuilder.featurizer.AlphaAngleFeaturizer() nothing = featurizer.transform(trajectories) assert (nothing[0].shape[1] == 0)
def test_fs_peptide_nosincos(): # will produce 18 features dataset = fetch_fs_peptide() trajectories = dataset["trajectories"] featurizer = msmbuilder.featurizer.AlphaAngleFeaturizer(sincos=False) alphas = featurizer.transform(trajectories) assert (alphas[0].shape[1] == 18)
def test_fs_peptide(): # will produce 36 features dataset = fetch_fs_peptide() trajectories = dataset["trajectories"] featurizer = msmbuilder.featurizer.AlphaAngleFeaturizer() alphas = featurizer.transform(trajectories) assert (alphas[0].shape[1] == 36)
def test_that_all_featurizers_run(): dataset = fetch_alanine_dipeptide() trajectories = dataset["trajectories"] trj0 = trajectories[0][0] atom_indices, pair_indices = subset_featurizer.get_atompair_indices(trj0) featurizer = msmbuilder.featurizer.AtomPairsFeaturizer(pair_indices) X_all = featurizer.transform(trajectories) featurizer = msmbuilder.featurizer.SuperposeFeaturizer(np.arange(15), trj0) X_all = featurizer.transform(trajectories) featurizer = msmbuilder.featurizer.DihedralFeaturizer(["phi", "psi"]) X_all = featurizer.transform(trajectories) #featurizer = msmbuilder.featurizer.ContactFeaturizer() # Doesn't work on ALA dipeptide #X_all = featurizer.transform(trajectories) featurizer = msmbuilder.featurizer.RMSDFeaturizer(trj0) X_all = featurizer.transform(trajectories) atom_featurizer0 = subset_featurizer.SubsetAtomPairs(pair_indices, trj0, exponent=-1.0) cosphi = subset_featurizer.SubsetCosPhiFeaturizer(trj0) sinphi = subset_featurizer.SubsetSinPhiFeaturizer(trj0) cospsi = subset_featurizer.SubsetCosPsiFeaturizer(trj0) sinpsi = subset_featurizer.SubsetSinPsiFeaturizer(trj0) featurizer = subset_featurizer.SubsetFeatureUnion([("pairs", atom_featurizer0), ("cosphi", cosphi), ("sinphi", sinphi), ("cospsi", cospsi), ("sinpsi", sinpsi)]) featurizer.subsets = [ np.arange(1) for i in range(featurizer.n_featurizers) ] X_all = featurizer.transform(trajectories) eq(X_all[0].shape[1], 1 * featurizer.n_featurizers)
def test_alanine_dipeptide(): # This test takes the rmsd of the 0th set of alanine dipeptide # trajectories relative to the 0th frame of the dataset. # The test asserts that the first rmsd calculated will be zero. dataset = fetch_alanine_dipeptide() trajectories = dataset["trajectories"] featurizer = msmbuilder.featurizer.StrucRMSDFeaturizer( trajectories[0], trajectories[0][0], range(trajectories[0].n_atoms)) data = featurizer.transform(trajectories[0]) assert(data[0] < 1e-3)
def test_two_refs(): # This test uses the 0th and 1st frames of the 0th set of # adp trajectories as the two reference trajectories and # ensures that the rmsd of the 0th frame of the dataset with # the 0th reference are identical and the 1st frame of the # dataset with the 1st reference are identical. dataset = fetch_alanine_dipeptide() trajectories = dataset["trajectories"] featurizer = msmbuilder.featurizer.StrucRMSDFeaturizer( trajectories[0], trajectories[0][0:2], range(trajectories[0].n_atoms)) data = featurizer.transform(trajectories[0]) # TODO: Figure out why arrays are 3D assert(data[0][0][0] - data[1][0][1] < 1e-3) assert(data[1][0][0] - data[0][0][1] < 1e-3)