本文整理汇总了Python中mdtraj.testing.eq函数的典型用法代码示例。如果您正苦于以下问题:Python eq函数的具体用法?Python eq怎么用?Python eq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eq函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_repex_save_and_load
def test_repex_save_and_load():
nc_filename = tempfile.mkdtemp() + "/out.nc"
T_min = 1.0 * unit.kelvin
T_i = [T_min, T_min * 10., T_min * 100.]
n_replicas = len(T_i)
ho = testsystems.HarmonicOscillator()
system = ho.system
positions = ho.positions
states = [ ThermodynamicState(system=system, temperature=T_i[i]) for i in range(n_replicas) ]
coordinates = [positions] * n_replicas
parameters = {"number_of_iterations":5}
rex = replica_exchange.ReplicaExchange.create(states, coordinates, nc_filename, parameters=parameters)
rex.run()
rex.extend(5)
rex = resume(nc_filename)
rex.run()
eq(rex.__class__.__name__, "ReplicaExchange")
示例2: test_harmonic_oscillators_save_and_load
def test_harmonic_oscillators_save_and_load():
nc_filename = tempfile.mkdtemp() + "/out.nc"
T_min = 1.0 * unit.kelvin
T_i = [T_min, T_min * 10., T_min * 100.]
n_replicas = len(T_i)
ho = testsystems.HarmonicOscillator()
system = ho.system
positions = ho.positions
states = [ ThermodynamicState(system=system, temperature=T_i[i]) for i in range(n_replicas) ]
coordinates = [positions] * n_replicas
mpicomm = dummympi.DummyMPIComm()
parameters = {"number_of_iterations":200}
replica_exchange = ReplicaExchange.create(states, coordinates, nc_filename, mpicomm=mpicomm, parameters=parameters)
replica_exchange.run()
replica_exchange.extend(100)
replica_exchange = resume(nc_filename, mpicomm=mpicomm)
eq(replica_exchange.iteration, 200)
replica_exchange.run()
示例3: test_unique_pairs
def test_unique_pairs():
n = 10
a = np.arange(n)
b = np.arange(n, n+n)
eq(md.Topology._unique_pairs(a, a).sort(), md.Topology._unique_pairs_equal(a).sort())
eq(md.Topology._unique_pairs(a, b).sort(), md.Topology._unique_pairs_mutually_exclusive(a, b).sort())
示例4: test_bool
def test_bool():
sp = parse_selection("protein or water")
eq(sp.source, "(atom.residue.is_protein or atom.residue.is_water)")
sp = parse_selection("protein or water or all")
eq(sp.source,
"(atom.residue.is_protein or atom.residue.is_water or True)")
示例5: _test_against_vmd
def _test_against_vmd(pdb):
# this is probably not cross-platform compatible. I assume that the exact
# path to this CHARMM topology that is included with VMD depends on
# the install mechanism, especially for bundled mac or windows installers
VMD_ROOT = os.path.join(os.path.dirname(os.path.realpath(VMD)), '..')
top_paths = [os.path.join(r, f) for (r, _, fs) in os.walk(VMD_ROOT) for f in fs
if 'top_all27_prot_lipid_na.inp' in f]
assert len(top_paths) >= 0
top = os.path.abspath(top_paths[0]).replace(" ", "\\ ")
TEMPLATE = '''
package require psfgen
topology %(top)s
pdbalias residue HIS HSE
pdbalias atom ILE CD1 CD
segment U {pdb %(pdb)s}
coordpdb %(pdb)s U
guesscoord
writepdb out.pdb
writepsf out.psf
exit
''' % {'top': top, 'pdb' : pdb}
with enter_temp_directory():
with open('script.tcl', 'w') as f:
f.write(TEMPLATE)
os.system(' '.join([VMD, '-e', 'script.tcl', '-dispdev', 'none']))
out_pdb = md.load('out.pdb')
out_psf = md.load_psf('out.psf')
# make sure the two topologies are equal
eq(out_pdb.top, out_psf)
示例6: test_baker_hubbard_2
def test_baker_hubbard_2():
t = md.load(get_fn('1vii_sustiva_water.pdb'))
triplets = md.baker_hubbard(t)
N = 1000
rows = triplets[:, 0] * N*N + triplets[:, 1] * N + triplets[:, 2]
# ensure that there aren't any repeat rows
eq(len(np.unique(rows)), len(rows))
示例7: test_parallel_tempering
def test_parallel_tempering():
nc_filename = tempfile.mkdtemp() + "/out.nc"
T_min = 1.0 * unit.kelvin
T_max = 10.0 * unit.kelvin
n_temps = 3
ho = testsystems.HarmonicOscillator()
system = ho.system
positions = ho.positions
coordinates = [positions] * n_temps
mpicomm = dummympi.DummyMPIComm()
parameters = {"number_of_iterations":1000}
replica_exchange = ParallelTempering.create(system, coordinates, nc_filename, T_min=T_min, T_max=T_max, n_temps=n_temps, mpicomm=mpicomm, parameters=parameters)
eq(replica_exchange.n_replicas, n_temps)
replica_exchange.run()
u_permuted = replica_exchange.database.ncfile.variables["energies"][:]
s = replica_exchange.database.ncfile.variables["states"][:]
u = permute_energies(u_permuted, s)
states = replica_exchange.thermodynamic_states
u0 = np.array([[ho.reduced_potential_expectation(s0, s1) for s1 in states] for s0 in states])
l0 = np.log(u0) # Compare on log scale because uncertainties are proportional to values
l1 = np.log(u.mean(0))
eq(l0, l1, decimal=1)
示例8: test_double_set_thermodynamic_states
def test_double_set_thermodynamic_states():
nc_filename = tempfile.mkdtemp() + "/out.nc"
T_min = 1.0 * unit.kelvin
T_max = 10.0 * unit.kelvin
n_temps = 3
ho = testsystems.HarmonicOscillator()
system = ho.system
positions = ho.positions
coordinates = [positions] * n_temps
mpicomm = dummympi.DummyMPIComm()
parameters = {"number_of_iterations": 3}
replica_exchange = ParallelTempering.create(
system,
coordinates,
nc_filename,
T_min=T_min,
T_max=T_max,
n_temps=n_temps,
mpicomm=mpicomm,
parameters=parameters,
)
eq(replica_exchange.n_replicas, n_temps)
replica_exchange.run()
states = replica_exchange.thermodynamic_states
replica_exchange.database.thermodynamic_states = states
示例9: test_write_coordinates_reshape
def test_write_coordinates_reshape():
coordinates = np.random.randn(10,3)
with LH5TrajectoryFile(temp, 'w') as f:
f.write(coordinates)
with LH5TrajectoryFile(temp) as f:
eq(f.read(), coordinates.reshape(1,10,3), decimal=3)
示例10: test_hrex_save_and_load
def test_hrex_save_and_load(mpicomm):
nc_filename = tempfile.mkdtemp() + "/out.nc"
temperature = 1 * unit.kelvin
K0 = 100.0 # Units are automatically added by the testsystem
K = [K0, K0 * 10., K0 * 1.]
powers = [2., 2., 4.]
n_replicas = len(K)
oscillators = [testsystems.PowerOscillator(b=powers[i]) for i in range(n_replicas)]
systems = [ho.system for ho in oscillators]
positions = [ho.positions for ho in oscillators]
state = ThermodynamicState(system=systems[0], temperature=temperature)
parameters = {"number_of_iterations":200}
replica_exchange = hamiltonian_exchange.HamiltonianExchange.create(state, systems, positions, nc_filename, mpicomm=mpicomm, parameters=parameters)
replica_exchange.run()
replica_exchange.extend(100)
replica_exchange = resume(nc_filename, mpicomm=mpicomm)
eq(replica_exchange.iteration, 200)
replica_exchange.run()
示例11: test_parse_ligand_filename
def test_parse_ligand_filename():
molecule_name = "sustiva"
input_filename = utils.get_data_filename("chemicals/sustiva/sustiva.mol2")
name, ext = utils.parse_ligand_filename(input_filename)
eq(name, "sustiva")
eq(ext, ".mol2")
示例12: test_power_oscillators
def test_power_oscillators(mpicomm):
nc_filename = tempfile.mkdtemp() + "/out.nc"
temperature = 1 * unit.kelvin
K0 = 100.0 # Units are automatically added by the testsystem
K = [K0, K0 * 10., K0 * 1.]
powers = [2., 2., 4.]
n_replicas = len(K)
oscillators = [testsystems.PowerOscillator(b=powers[i]) for i in range(n_replicas)]
systems = [ho.system for ho in oscillators]
positions = [ho.positions for ho in oscillators]
state = ThermodynamicState(system=systems[0], temperature=temperature)
parameters = {"number_of_iterations":2000}
replica_exchange = hamiltonian_exchange.HamiltonianExchange.create(state, systems, positions, nc_filename, mpicomm=mpicomm, parameters=parameters)
replica_exchange.run()
u_permuted = replica_exchange.database.ncfile.variables["energies"][:]
s = replica_exchange.database.ncfile.variables["states"][:]
u = permute_energies(u_permuted, s)
beta = (state.temperature * kB) ** -1.
u0 = np.array([[testsystems.PowerOscillator.reduced_potential(beta, ho2.K, ho2.b, ho.K, ho.b) for ho in oscillators] for ho2 in oscillators])
l = np.log(u.mean(0))
l0 = np.log(u0)
eq(l0, l, decimal=1)
示例13: test_inertia
def test_inertia():
assert eq(order.compute_inertia_tensor(TRAJ1),
order._compute_inertia_tensor_slow(TRAJ1))
assert eq(order.compute_inertia_tensor(TRAJ2),
order._compute_inertia_tensor_slow(TRAJ2))
assert eq(order.compute_inertia_tensor(TRAJ3),
order._compute_inertia_tensor_slow(TRAJ3))
示例14: test_parallel_tempering_save_and_load
def test_parallel_tempering_save_and_load():
nc_filename = tempfile.mkdtemp() + "/out.nc"
T_min = 1.0 * unit.kelvin
T_max = 10.0 * unit.kelvin
n_temps = 3
ho = testsystems.HarmonicOscillator()
system = ho.system
positions = ho.positions
coordinates = [positions] * n_temps
parameters = {"number_of_iterations":5}
rex = parallel_tempering.ParallelTempering.create(system, coordinates, nc_filename, T_min=T_min, T_max=T_max, n_temps=n_temps, parameters=parameters)
rex.run()
rex.extend(5)
rex = resume(nc_filename)
rex.run()
eq(rex.__class__.__name__, "ParallelTempering")
示例15: test_select_atom_indices
def test_select_atom_indices():
top = md.load(get_fn("native.pdb")).topology
yield lambda: eq(top.select_atom_indices("alpha"), np.array([8]))
yield lambda: eq(top.select_atom_indices("minimal"), np.array([4, 5, 6, 8, 10, 14, 15, 16, 18]))
assert_raises(ValueError, lambda: top.select_atom_indices("sdfsdfsdf"))