コード例 #1
0
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"))
コード例 #2
0
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)
コード例 #3
0
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)
コード例 #4
0
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)
コード例 #5
0
ファイル: test_atoms.py プロジェクト: eljost/i-pi
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"]