Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_atom_indices_1(get_fn):
atom_indices = np.arange(10)
top = md.load(get_fn('native.pdb'))
t0 = md.load(get_fn('frame0.mdcrd'), top=top)
t1 = md.load(get_fn('frame0.mdcrd'), top=top, atom_indices=atom_indices)
eq(t0.xyz[:, atom_indices], t1.xyz)
def test_molecules(get_fn):
top = md.load(get_fn('4OH9.pdb')).topology
molecules = top.find_molecules()
assert sum(len(mol) for mol in molecules) == top.n_atoms
assert sum(1 for mol in molecules if len(mol) > 1) == 2 # All but two molecules are water
def test_trajectory_save_load(get_fn):
t = md.load(get_fn('native.pdb'))
t.unitcell_lengths = 1 * np.ones((1, 3))
t.unitcell_angles = 90 * np.ones((1, 3))
t.save(temp)
t2 = md.load(temp, top=t.topology)
eq(t.xyz, t2.xyz)
eq(t.unitcell_lengths, t2.unitcell_lengths)
def _load_to_position(spec, arr_shape):
'''
Load a specified file into a specified position by spec. The
arr_shape parameter lets us know how big the final array should be.
'''
(position, filename, load_kwargs) = spec
xyz = md.load(filename, **load_kwargs).xyz
# mp.Array must be converted to numpy array and reshaped
arr = _tonumpyarray(shared_array).reshape(arr_shape)
# dump coordinates in.
arr[position:position+len(xyz)] = xyz
return xyz.shape
'outfname' : 't4-tol',
'nprop':5,
'freeze_distance' : 10.0,
#'write_ncmc' : 1,
#'ncmc_traj': True
}
#Generate the ParmEd Structure
prmtop = utils.get_data_filename('blues', 'tests/data/eqToluene.prmtop')#
inpcrd = utils.get_data_filename('blues', 'tests/data/eqToluene.inpcrd')
struct = parmed.load_file(prmtop, xyz=inpcrd)
struct = parmed.load_file(prmtop, xyz='posA.pdb')
#Define the 'model' object we are perturbing here.
# Calculate particle masses of object to be moved
traj = md.load(inpcrd, top=prmtop)
fit_atoms = traj.top.select("resid 50 to 155 and name CA")
fit_atoms = traj.top.select("protein")
ligand = MolDart(structure=struct, resname='LIG',
pdb_files=['posB.pdb', 'posA.pdb'],
#pdb_files=['posA.pdb', 'posB.pdb'],
fit_atoms=fit_atoms)
# ligand = RandomLigandRotationMove(struct, 'LIG')
# ligand.calculateProperties()
# Initialize object that proposes moves.
ligand_mover = MoveEngine(ligand)
# Generate the MD, NCMC, ALCHEMICAL Simulation objects
simulations = SimulationFactory(struct, ligand_mover, **opt)
simulations.createSimulationSet()
import pandas as pd
import nmrpystar
import mdtraj as md
stride = 100
t0 = md.load(["./Trajectories_ff99sbnmr/1am7_%d.dcd" % i for i in range(10)], top="./1am7_fixed.pdb")[::stride]
t1 = md.load(["./Trajectories/1am7_%d.dcd" % i for i in range(15)], top="./1am7_fixed.pdb")[::stride]
#full_prediction0 = md.nmr.chemical_shifts_shiftx2(t0)
#full_prediction1 = md.nmr.chemical_shifts_shiftx2(t1)
#full_prediction0 = md.nmr.chemical_shifts_spartaplus(t0)
#full_prediction1 = md.nmr.chemical_shifts_spartaplus(t1)
full_prediction0 = md.nmr.chemical_shifts_ppm(t0)
full_prediction1 = md.nmr.chemical_shifts_ppm(t1)
parsed = nmrpystar.parse(open("./16664.str").read())
print(parsed.status)
def __init__(self, args):
self.args = args
if args.top is not None:
self.top = md.load(os.path.expanduser(args.top))
else:
self.top = None
self.featurizer = mixtape.featurizer.load(args.featurizer)
self.filenames = glob.glob(os.path.expanduser(args.dir) + '/*.' + args.ext)
Path to a trajectory containing timestep information to infer
the correct timestep from when plotting implied timescales.
"""
if timestep and infer_timestep:
raise exception.ImproperlyConfigured(
'Only one of --timestep and --infer-timestep can be '
'supplied, you supplied both --timestep=%s and '
'--infer-timestep=%s' % (timestep, infer_timestep))
if timestep:
unit_factor = timestep
unit_str = 'ns'
elif infer_timestep:
try:
timestep = md.load(infer_timestep).timestep
except ValueError:
if infer_timestep[-4:] != '.xtc':
raise exception.ImproperlyConfigured(
"Topologyless formats other than XTC are not supported.")
with md.formats.xtc.XTCTrajectoryFile(infer_timestep) as f:
xyz, time, step, box = f.read(n_frames=10)
timesteps = time[1:] - time[0:-1]
assert np.all(timesteps[0] == timesteps)
timestep = timesteps[0]
unit_factor = 1000 / timestep # units are ps
unit_str = 'ns'
else:
unit_factor = 1
unit_str = 'frames'
return unit_factor, unit_str
def single_traj_from_n_files(file_list, top):
""" Creates a single trajectory object from a list of files
"""
traj = None
for ff in file_list:
if traj is None:
traj = md.load(ff, top=top)
else:
traj = traj.join(md.load(ff, top=top))
return traj