def test_intermittent(self):
        hbond = HBAC(self.u,
                     hydrogens=self.H,
                     acceptors=self.O,
                     donors=self.N,
                     bond_type='intermittent',
                     sample_time=0.06,
        )
        hbond.run()

        assert_array_almost_equal(
            hbond.solution['results'],
            np.array([ 1.        ,  0.92668623,  0.84310848,
                       0.79325515,  0.76392961,  0.72287393],
                     dtype=np.float32)
        )
    def test_save(self):
        hbond = HBAC(self.u,
                     hydrogens=self.H,
                     acceptors=self.O,
                     donors=self.N,
                     bond_type='continuous',
                     sample_time=0.06,
        )
        hbond.run()

        with tempdir.in_tempdir():
            hbond.save_results('hbondout.npz')

            loaded = np.load('hbondout.npz')
            assert_('time' in loaded)
            assert_('results' in loaded)
    def test_continuous(self):
        hbond = HBAC(self.u,
                     hydrogens=self.H,
                     acceptors=self.O,
                     donors=self.N,
                     bond_type='continuous',
                     sample_time=0.06,
        )
        hbond.run()

        assert_array_almost_equal(
            hbond.solution['results'],
            np.array([ 1.        ,  0.92668623,  0.83137828,
                       0.74486804,  0.67741936,  0.60263932],
                     dtype=np.float32)
        )
    def test_intermittent(self, u, hydrogens, oxygens, nitrogens):
        hbond = HBAC(
            u,
            hydrogens=hydrogens,
            acceptors=oxygens,
            donors=nitrogens,
            bond_type='intermittent',
            sample_time=0.06,
        )
        hbond.run()

        assert_almost_equal(
            hbond.solution['results'],
            np.array([
                1., 0.92668623, 0.84310848, 0.79325515, 0.76392961, 0.72287393
            ],
                     dtype=np.float32))
    def test_continuous(self, u, hydrogens, oxygens, nitrogens):
        hbond = HBAC(
            u,
            hydrogens=hydrogens,
            acceptors=oxygens,
            donors=nitrogens,
            bond_type='continuous',
            sample_time=0.06,
        )
        hbond.run()

        assert_almost_equal(
            hbond.solution['results'],
            np.array([
                1., 0.92668623, 0.83137828, 0.74486804, 0.67741936, 0.60263932
            ],
                     dtype=np.float32))
    def test_save(self, u, hydrogens, oxygens, nitrogens):
        hbond = HBAC(
            u,
            hydrogens=hydrogens,
            acceptors=oxygens,
            donors=nitrogens,
            bond_type='continuous',
            sample_time=0.06,
        )
        hbond.run()

        with tempdir.in_tempdir():
            hbond.save_results('hbondout.npz')

            loaded = np.load('hbondout.npz')
            assert 'time' in loaded
            assert 'results' in loaded
Exemple #7
0
    def test_save(self):
        hbond = HBAC(
            self.u,
            hydrogens=self.H,
            acceptors=self.O,
            donors=self.N,
            bond_type='continuous',
            sample_time=0.06,
        )
        hbond.run()

        with tempdir.in_tempdir():
            hbond.save_results('hbondout.npz')

            loaded = np.load('hbondout.npz')
            assert_('time' in loaded)
            assert_('results' in loaded)
    def test_intermittent_timecut(self):
        hbond = HBAC(self.u,
                     hydrogens=self.H,
                     acceptors=self.O,
                     donors=self.N,
                     bond_type='intermittent',
                     time_cut=0.01,  # time cut at traj.dt == continuous
                     sample_time=0.06,
        )
        hbond.run()

        assert_array_almost_equal(
            hbond.solution['results'],
            np.array([ 1.        ,  0.92668623,  0.83137828,
                       0.74486804,  0.67741936,  0.60263932],
                     dtype=np.float32)
        )
    def test_save(self, u, hydrogens, oxygens, nitrogens, tmpdir):
        hbond = HBAC(u,
                     hydrogens=hydrogens,
                     acceptors=oxygens,
                     donors=nitrogens,
                     bond_type='continuous',
                     sample_time=0.06,
        )
        hbond.run()

        tmpfile = os.path.join(str(tmpdir), 'hbondout.npz')

        hbond.save_results(tmpfile)

        loaded = np.load(tmpfile)
        assert 'time' in loaded
        assert 'results' in loaded
    def test_intermittent_timecut(self, u, hydrogens, oxygens, nitrogens):
        hbond = HBAC(
            u,
            hydrogens=hydrogens,
            acceptors=oxygens,
            donors=nitrogens,
            bond_type='intermittent',
            time_cut=0.01,  # time cut at traj.dt == continuous
            sample_time=0.06,
        )
        hbond.run()

        assert_almost_equal(
            hbond.solution['results'],
            np.array([
                1., 0.92668623, 0.83137828, 0.74486804, 0.67741936, 0.60263932
            ],
                     dtype=np.float32))
    def test_continuous_excl(self, u, hydrogens, oxygens, nitrogens):
        hbond = HBAC(u,
                     hydrogens=hydrogens,
                     acceptors=oxygens,
                     donors=nitrogens,
                     bond_type='continuous',
                     exclusions=(np.arange(len(hydrogens)), np.array(
                         range(len(oxygens)))),
                     sample_time=0.06,
        )
        hbond.run()

        assert_almost_equal(
            hbond.solution['results'],
            np.array([ 1.        ,  0.92668623,  0.83137828,
                       0.74486804,  0.67741936,  0.60263932],
                     dtype=np.float32)
        )
    def test_intermittent_excl(self, u, hydrogens, oxygens, nitrogens):
        hbond = HBAC(u,
                     hydrogens=hydrogens,
                     acceptors=oxygens,
                     donors=nitrogens,
                     bond_type='intermittent',
                     exclusions=(np.arange(len(hydrogens)), np.array(
                         range(len(oxygens)))),
                     sample_time=0.06,
        )
        hbond.run()

        assert_almost_equal(
            hbond.solution['results'],
            np.array([ 1.        ,  0.92668623,  0.84310848,
                       0.79325515,  0.76392961,  0.72287393],
                     dtype=np.float32)
        )
Exemple #13
0
    def test_save(self, u, hydrogens, oxygens, nitrogens, tmpdir):
        hbond = HBAC(
            u,
            hydrogens=hydrogens,
            acceptors=oxygens,
            donors=nitrogens,
            bond_type='continuous',
            sample_time=0.06,
        )
        hbond.run()

        tmpfile = os.path.join(str(tmpdir), 'hbondout.npz')

        hbond.save_results(tmpfile)

        loaded = np.load(tmpfile)
        assert 'time' in loaded
        assert 'results' in loaded
Exemple #14
0
    def test_continuous_excl(self):
        hbond = HBAC(
            self.u,
            hydrogens=self.H,
            acceptors=self.O,
            donors=self.N,
            bond_type='continuous',
            exclusions=self.excl_list,
            sample_time=0.06,
        )
        hbond.run()

        assert_array_almost_equal(
            hbond.solution['results'],
            np.array([
                1., 0.92668623, 0.83137828, 0.74486804, 0.67741936, 0.60263932
            ],
                     dtype=np.float32))
Exemple #15
0
    def test_intermittent_excl(self):
        hbond = HBAC(
            self.u,
            hydrogens=self.H,
            acceptors=self.O,
            donors=self.N,
            bond_type='intermittent',
            exclusions=self.excl_list,
            sample_time=0.06,
        )
        hbond.run()

        assert_array_almost_equal(
            hbond.solution['results'],
            np.array([
                1., 0.92668623, 0.84310848, 0.79325515, 0.76392961, 0.72287393
            ],
                     dtype=np.float32))
Exemple #16
0
    'O9' : u.select_atoms('bynum 64'),
    'O10' : u.select_atoms('bynum 18')
}

oxygens = sum(list(oxygen_dict.values()))
hydrogens = sum(list(hydrogen_dict.values()))
nitrogens = sum(list(nitrogen_dict.values()))
""

"Run HBond Autocorrelation"
hb_ac = HydrogenBondAutoCorrel(u, 
                               acceptors = oxygens,
                               hydrogens = hydrogens,
                               donors = nitrogens,
                               bond_type='continuous')
hb_ac.run()
hb_ac.solve()
tau = hb_ac.solution['tau']
time = hb_ac.solution['time']
results = hb_ac.solution['results']
estimate = hb_ac.solution['estimate']

"Max Range"
factor = 0.5
max_d = int(data[:,0].size * factor)
max_h = int(time.size * factor)
max_r = int(len(u.trajectory) * factor)

"Plot Results and Find Correlation"
fig, ax1 = plt.subplots()
color = 'red'