Exemple #1
0
    def test_param_from_db(self):
        """ Tests parameterizing from database """
        param = CharmmParameterSet(get_fn('par_all36_cgenff.prm'),
                                   get_fn('top_all36_cgenff.rtf'))
        torsion = ('CG331', 'CG321', 'CG321', 'CG331')
        db = sqlite_plus.load(get_fn('butane.db'))
        par.add_missing(torsion, param, sample_n5=True)
        self.assertEqual(param.dihedral_types[torsion][0].phi_k, 0.03819)
        self.assertEqual(param.dihedral_types[torsion][1].phi_k, 0.03178)
        self.assertEqual(param.dihedral_types[torsion][2].phi_k, 0.0)
        self.assertEqual(param.dihedral_types[torsion][3].phi_k, 0.0)
        self.assertEqual(param.dihedral_types[torsion][4].phi_k, 0.0)
        self.assertEqual(param.dihedral_types[torsion][5].phi_k, 0.0)

        par.update_param_from_sample(param_list=torsion,
                                     param=param,
                                     db=db,
                                     rj=False,
                                     model_type='openmm')
        self.assertEqual(param.dihedral_types[torsion][0].phi_k, 0.086424)
        self.assertEqual(param.dihedral_types[torsion][1].phi_k, 0.019074)
        self.assertEqual(param.dihedral_types[torsion][2].phi_k, 0.0)
        self.assertEqual(param.dihedral_types[torsion][3].phi_k, -1.834546)
        self.assertEqual(param.dihedral_types[torsion][4].phi_k, -1.86807)
        self.assertEqual(param.dihedral_types[torsion][5].phi_k, -2.860622)
Exemple #2
0
 def test_get_multiplicity_traces(self):
     """Tests turing multiplicity bitstring into multiplicity traces"""
     db = sqlite_plus.load(get_fun('butane.db'))
     param_list = db.get_sampled_torsions()
     mult = db.get_multiplicity_trace(param_list[0], n5=True)
     keys = ['1', '2', '3', '4', '5', '6']
     self.assertEqual(set(mult.keys()), set(keys))
Exemple #3
0
 def test_get_multiplicity_traces(self):
     """Tests turing multiplicity bitstring into multiplicity traces"""
     db = sqlite_plus.load(get_fn('butane.db'))
     param_list = db.get_sampled_torsions()
     mult = db.get_multiplicity_trace(param_list[0], n5=True)
     keys = ['1', '2', '3', '4', '5', '6']
     self.assertEqual(set(mult.keys()), set(keys))
Exemple #4
0
def get_models(directory, pattern):
    models = []
    for path, subdir, files in os.walk(directory):
        for name in files:
            if fnmatch(name, pattern):
                file = os.path.join(os.getcwd(), path, name)
                model = sqlite_plus.load(file)
                models.append(model)
    return models
Exemple #5
0
    def test_get_sampled_torsions(self):
        """ Tests get torsions sampled from db """

        param_to_opt=[('CG331', 'CG321', 'CG321', 'CG331'),
                      ('HGA3', 'CG331', 'CG321', 'HGA2'),
                      ('HGA3', 'CG331', 'CG321', 'CG321'),
                      ('HGA2', 'CG321', 'CG321', 'HGA2'),
                      ('CG331', 'CG321', 'CG321', 'HGA2')]
        db = sqlite_plus.load(get_fun('butane.db'))
        param_list = db.get_sampled_torsions()
        self.assertEqual(set(param_list), set(param_to_opt))
Exemple #6
0
    def test_get_sampled_torsions(self):
        """ Tests get torsions sampled from db """

        param_to_opt=[('CG331', 'CG321', 'CG321', 'CG331'),
                      ('HGA3', 'CG331', 'CG321', 'HGA2'),
                      ('HGA3', 'CG331', 'CG321', 'CG321'),
                      ('HGA2', 'CG321', 'CG321', 'HGA2'),
                      ('CG331', 'CG321', 'CG321', 'HGA2')]
        db = sqlite_plus.load(get_fn('butane.db'))
        param_list = db.get_sampled_torsions()
        self.assertEqual(set(param_list), set(param_to_opt))
    def test_residual_energy(self):
        """ Tests that total energy is resonable.
        """
        db = sqlite_plus.load(get_fun('butane_np.sqlite'))

        dih_list = [('CG331', 'CG321', 'CG321', 'CG331'),
                    ('HGA2', 'CG321', 'CG321', 'HGA2'),
                    ('CG331', 'CG321', 'CG321', 'HGA2')]

        par.add_missing(param_list=dih_list, param=param, sample_n5=True)
        par.update_param_from_sample(param_list=dih_list, param=param, db=db, n_5=True, rj=False, model_type='numpy')

        frag.compute_energy(param=param)

        self.assertTrue((frag.delta_energy._value > -0.5).all() and (frag.delta_energy._value < 0.5).all())
    def test_param_from_db(self):
        """ Tests parameterizing from database """
        param = CharmmParameterSet(get_fn('par_all36_cgenff.prm'), get_fn('top_all36_cgenff.rtf'))
        torsion = ('CG331', 'CG321', 'CG321', 'CG331')
        db = sqlite_plus.load(get_fn('butane.db'))
        par.add_missing(torsion, param, sample_n5=True)
        self.assertEqual(param.dihedral_types[torsion][0].phi_k, 0.03819)
        self.assertEqual(param.dihedral_types[torsion][1].phi_k, 0.03178)
        self.assertEqual(param.dihedral_types[torsion][2].phi_k, 0.0)
        self.assertEqual(param.dihedral_types[torsion][3].phi_k, 0.0)
        self.assertEqual(param.dihedral_types[torsion][4].phi_k, 0.0)
        self.assertEqual(param.dihedral_types[torsion][5].phi_k, 0.0)

        par.update_param_from_sample(param_list=torsion, param=param, db=db, rj=False, model_type='openmm')
        self.assertEqual(param.dihedral_types[torsion][0].phi_k, 0.086424)
        self.assertEqual(param.dihedral_types[torsion][1].phi_k, 0.019074)
        self.assertEqual(param.dihedral_types[torsion][2].phi_k, 0.0)
        self.assertEqual(param.dihedral_types[torsion][3].phi_k, -1.834546)
        self.assertEqual(param.dihedral_types[torsion][4].phi_k, -1.86807)
        self.assertEqual(param.dihedral_types[torsion][5].phi_k, -2.860622)
Exemple #9
0
    def test_residual_energy(self):
        """ Tests that total energy is resonable.
        """
        db = sqlite_plus.load(get_fn('butane_np.sqlite'))

        dih_list = [('CG331', 'CG321', 'CG321', 'CG331'),
                    ('HGA2', 'CG321', 'CG321', 'HGA2'),
                    ('CG331', 'CG321', 'CG321', 'HGA2')]

        par.add_missing(param_list=dih_list, param=param, sample_n5=True)
        par.update_param_from_sample(param_list=dih_list,
                                     param=param,
                                     db=db,
                                     n_5=True,
                                     rj=False,
                                     model_type='numpy')

        frag.compute_energy(param=param)

        self.assertTrue((frag.delta_energy._value > -0.5).all()
                        and (frag.delta_energy._value < 0.5).all())
    args = parser.parse_args()
    print(args)

    param_to_opt = [('CG331', 'CG321', 'CG321', 'CG331')]
    param = CharmmParameterSet(
        '../../../../../../data/charmm_ff/top_all36_cgenff.rtf',
        '../../../../../../data/charmm_ff/par_all36_cgenff.prm')
    structure = '../../../../../structure/butane.psf'
    scan = '../../../../../torsion_scans/MP2_torsion_scan/'

    # paramterize using end of non reversible jump
    # Start sampler with values from end of non-rj chain.
    path = '../../../n5/10000/random_{}_{}/random_{}_{}.sqlite'.format(
        args.iterations, args.repeats, args.iterations, args.repeats)
    print(path)
    db = sqlite_plus.load(path)
    par.add_missing(param_list=param_to_opt, param=param, sample_n5=True)
    par.set_phase_0(param_list=param_to_opt, param=param)
    par.update_param_from_sample(param_list=param_to_opt,
                                 param=param,
                                 db=db,
                                 i=-1,
                                 rj=False,
                                 n_5=True,
                                 phase=False)
    print(param.dihedral_types[param_to_opt[0]])

    butane_scan = ScanSet.parse_psi4_out(scan, structure)
    optimized = butane_scan.remove_nonoptimized()

    model = Model.TorsionFitModel(param=param,
from pymbar.timeseries import detectEquilibration
import tqdm
import numpy as np
from torsionfit.backends import sqlite_plus
from collections import OrderedDict

# load database
dbs = OrderedDict()
for i in range(1, 24):
    dbs['db_{}'.format(i)] = sqlite_plus.load(
        'random_100000_{}/random_100000_{}.sqlite'.format(i, i))

t_sigma = np.zeros((23, 3))
for i, db in tqdm.tqdm(enumerate(dbs)):
    [t, g, Neff] = detectEquilibration(dbs[db].sigma[:])
    t_sigma[i, 0] = t
    t_sigma[i, 1] = g
    t_sigma[i, 2] = Neff

np.save('t_sigma', t_sigma)

t_dev = np.zeros((23, 3))
for i, db in tqdm.tqdm(enumerate(dbs)):
    [t, g, Neff] = detectEquilibration(dbs[db].deviance[:])
    t_dev[i, 0] = t
    t_dev[i, 1] = g
    t_dev[i, 2] = Neff

np.save('t_dev', t_dev)
Exemple #12
0
from torsionfit.backends import sqlite_plus
from pymc import MCMC
from parmed.charmm import CharmmParameterSet
from torsionfit import parameters as par

param_to_opt = [('CG331', 'CG321', 'CG321', 'CG331')]
param = CharmmParameterSet('../../../../data/charmm_ff/top_all36_cgenff.rtf',
                           '../../../../data/charmm_ff/par_all36_cgenff.prm')
structure = '../../../structure/butane.psf'
scan = '../../../torsion_scans/MP2_torsion_scan/'

butane_scan = ScanSet.parse_psi4_out(scan, structure)
optimized = butane_scan.remove_nonoptimized()

# Start sampler with values from end of non-rj chain.
db = sqlite_plus.load('../n5/butane_n5_decouple_n.db')
par.add_missing(param_list=param_to_opt, param=param, sample_n5=True)
par.update_param_from_sample(param_list=param_to_opt,
                             param=param,
                             db=db,
                             i=-1,
                             rj=False,
                             n_5=True,
                             phase=False)

platform = mm.Platform.getPlatformByName('Reference')
model = Model.TorsionFitModel(param=param,
                              frags=optimized,
                              platform=platform,
                              param_to_opt=param_to_opt,
                              rj=True,
Exemple #13
0
 def load(self):
     return sqlite_plus.load(os.path.join(testdir, 'Disaster.sqlite'))
Exemple #14
0
 def load(self):
     return sqlite_plus.load(os.path.join(testdir, 'Disaster.sqlite'))