def test_real_box(self): traj = pt.load(fn('tz2.ortho.nc'), fn('tz2.ortho.parm7')) trajiter = pt.iterload(fn('tz2.ortho.nc'), fn('tz2.ortho.parm7')) saved_box = Box( [3.94559740E+01, 4.68215170E+01, 4.04695410E+01, 90., 90., 90.]) aa_eq(traj.top.box.values, saved_box.values) for frame in traj: assert frame.box.type == 'ortho' aa_eq( frame.box.values, [35.2627796623, 41.8455476799, 36.168629529, 90.0, 90.0, 90.0], decimal=1) arr0 = traj.unitcells arr1 = trajiter.unitcells for b0, b1, frame in zip(arr0, arr1, trajiter): box = frame.box # FIXME: # python3) b2 = box.values aa_eq(b0, b1) aa_eq(b0, b2) # test assign Box with list/tuple b = Box(saved_box.values) b2 = Box((t for t in saved_box.values)) aa_eq(b.values, saved_box.values, decimal=7) aa_eq(b2.values, saved_box.values, decimal=7) # assign frame.box with list/tuple frame.box = b.values b3 = frame.box aa_eq(b3.values, saved_box.values, decimal=7)
def test_convert_to_dict_and_rebuild(self): '''test_convert_to_dict_and_rebuild ''' top = self.traj.top d = top.to_dict() new_top = pt.Topology() MOLNUM = 0 for idx, (aname, atype, charge, mass, resid, resname, mol_number) in enumerate( zip(d['atom_name'], d['atom_type'], d['atom_charge'], d[ 'atom_mass'], d['resid'], d['resname'], d[ 'mol_number'])): atom = pt.core.Atom( name=aname, type=atype, charge=charge, mass=mass, resid=resid) atom.set_mol(mol_number) residue = pt.core.Residue(resname, resid) new_top.add_atom(atom, residue) if idx == 0: new_top.start_new_mol() if mol_number > MOLNUM: new_top.start_new_mol() MOLNUM += 1 new_top.add_bonds(d['bond_index']) new_top.add_dihedrals(d['dihedral_index']) new_top.box = Box(top.box.values) assert_equal_topology(top, new_top, self.traj)
def test_1(self): box = Box() box.type = 'truncoct' box.set_nobox() dummy = 100. box.data[0] = dummy assert box.data[0] == dummy assert box.values[0] == dummy
def test_2(self): import numpy as np box = Box() arr0 = np.arange(6).astype(np.float64) box.data[:] = arr0 for idx, x in enumerate(arr0): assert box.data[idx] == x # set Box for Frame f1 = Frame() f1.box = box aa_eq(f1.box.values, box.values, decimal=7)
def test_box_constructor_with_type(self): # TODO: assertion Box('rhombic') Box('ortho')
def test_from_matrix_3x3(self): from pytraj.math import Matrix_3x3 mat = Matrix_3x3() Box(mat)