def test_read_write_precision(get_fn): import random for t in [ md.load(get_fn('4waters.pdb')), # no unit cell md.load(get_fn('native2.pdb')), # unitcell md.load(get_fn('frame0.pdb')) ]: # multiframe with GroTrajectoryFile(temp, 'w') as f: f.write(t.xyz, t.topology, unitcell_vectors=t.unitcell_vectors, precision=random.randint(4, 10)) with GroTrajectoryFile(temp) as f: xyz, time, unitcell = f.read() top = f.topology eq(xyz, t.xyz, decimal=3) eq(list(top.atoms), list(t.top.atoms)) if t.unitcell_vectors is not None: eq(unitcell, t.unitcell_vectors) # Test out the automatic saver and loader with different precisions t = md.load(get_fn('native2.pdb')) t.save(temp, precision=5) eq(t.xyz, md.load(temp).xyz, decimal=3)
def test_read_write(): t = md.load(get_fn('4waters.pdb')) with GroTrajectoryFile(temp, 'w') as f: f.write(t.xyz, t.topology) with GroTrajectoryFile(temp) as f: xyz, time, unitcell = f.read() top = f.topology eq(xyz, t.xyz, decimal=3) eq(list(top.atoms), list(t.top.atoms))
def test_read_write(get_fn): for t in [md.load(get_fn('4waters.pdb')), # no unit cell md.load(get_fn('native2.pdb')), # unitcell md.load(get_fn('frame0.pdb'))]: # multiframe with GroTrajectoryFile(temp, 'w') as f: f.write(t.xyz, t.topology, unitcell_vectors=t.unitcell_vectors) with GroTrajectoryFile(temp) as f: xyz, time, unitcell = f.read() top = f.topology eq(xyz, t.xyz, decimal=3) eq(list(top.atoms), list(t.top.atoms)) if t.unitcell_vectors is not None: eq(unitcell, t.unitcell_vectors)
def test_load(): tref = md.load(get_fn('4waters.pdb')) with GroTrajectoryFile(temp, 'w') as f: f.write(tref.xyz, tref.topology) t = md.load(temp) eq(t.xyz, tref.xyz, decimal=3) eq(list(t.top.atoms), list(tref.top.atoms))
def test_load(get_fn): for tref in [ md.load(get_fn('4waters.pdb')), # no unit cell md.load(get_fn('native2.pdb')) ]: # unit cell with GroTrajectoryFile(temp, 'w') as f: f.write(tref.xyz, tref.topology, unitcell_vectors=tref.unitcell_vectors) t = md.load(temp) eq(t.xyz, tref.xyz, decimal=3) eq(list(t.top.atoms), list(tref.top.atoms)) eq(t.unitcell_vectors, tref.unitcell_vectors)
def test_load(get_fn): for tref in [md.load(get_fn('4waters.pdb')), # no unit cell md.load(get_fn('native2.pdb'))]: # unit cell with GroTrajectoryFile(temp, 'w') as f: f.write(tref.xyz, tref.topology, unitcell_vectors=tref.unitcell_vectors) t = md.load(temp) eq(t.xyz, tref.xyz, decimal=3) eq(list(t.top.atoms), list(tref.top.atoms)) eq(t.unitcell_vectors, tref.unitcell_vectors) #if there are 2 residues with same renum but different resname t = md.load(get_fn('two_residues_same_resnum.gro')) eq(t.n_residues, 2)