def test_print_xyz(): """Tests that xyz files are printed correctly.""" with open(local("test.pos_0.xyz"), "r") as f: with open(local("test.pos_1.xyz"), "w") as out: for num, ret in enumerate(iter_file("xyz", f)): atoms = ret["atoms"] assert len(atoms) == 3 assert_equal(pos_xyz * (num + 1), atoms.q) print_file("xyz", atoms, ret["cell"], filedesc=out) assert filecmp.cmp(local("test.pos_0.xyz"), local("test.pos_1.xyz")) os.unlink(local("test.pos_1.xyz"))
def test_read_xyz2(): """Tests that mode/xyz files are read correctly.""" with open(local("test.pos_0.xyz"), "r") as f: ret = read_file("xyz", f) atoms = ret["atoms"] assert len(atoms) == 3 assert_equal(pos_xyz, atoms.q)
def test_read_pdb(): """Tests that pdb files are read correctly.""" with open(local("test.pos_0.pdb"), "r") as f: ret = read_file("pdb", f) atoms = ret["atoms"] assert len(atoms) == 3 assert_equal(pos_pdb, atoms.q)
def test_iter_pdb(): """Tests that pdb files with multiple frames are read correctly.""" with open(local("test.pos_0.pdb"), "r") as f: for num, ret in enumerate(iter_file("pdb", f)): atoms = ret["atoms"] assert len(atoms) == 3 assert_equal(pos_pdb * (num + 1), atoms.q)
def get_atoms(fin): """Reads atoms object from file @fin.""" with open(local(fin), "r") as f: ret = read_file("xyz", f) return ret["atoms"]