Пример #1
0
def test_print_xyz():
   """Tests that xyz files are printed correctly."""

   with open(local("test.pos_0.pdb"), "r") as f:
      with open(local("test.pos_1.pdb"), "w") as out:
         for num, (atoms, cell) in enumerate(io_pdb.iter_pdb(f)):
            assert(len(atoms) == 3)
            assert_equal(pos*(num+1), atoms.q)
            io_pdb.print_pdb(atoms, Cell(h=np.identity(3, float)), filedesc=out)

   assert(filecmp.cmp(local("test.pos_0.pdb"), local("test.pos_1.pdb")))
   os.unlink(local("test.pos_1.pdb"))
Пример #2
0
def test_print_xyz():
    """Tests that xyz files are printed correctly."""

    with open(local("test.pos_0.pdb"), "r") as f:
        with open(local("test.pos_1.pdb"), "w") as out:
            for num, ret in enumerate(iter_file("pdb", f)):
                atoms = ret["atoms"]
                assert len(atoms) == 3
                assert_equal(pos * (num + 1), atoms.q)
                print_file("pdb", atoms, ret["cell"], filedesc=out)

    assert filecmp.cmp(local("test.pos_0.pdb"), local("test.pos_1.pdb"))
    os.unlink(local("test.pos_1.pdb"))
Пример #3
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"))
Пример #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, (atoms, cell) in enumerate(io_pdb.iter_pdb(f)):
         assert(len(atoms) == 3)
         assert_equal(pos*(num+1), atoms.q)
Пример #5
0
def test_read_pdb():
   """Tests that pdb files are read correctly."""

   with open(local("test.pos_0.pdb"), "r") as f:
      atoms, cell = io_pdb.read_pdb(f)
      assert(len(atoms) == 3)
      assert_equal(pos, atoms.q)
Пример #6
0
def test_iter_xyz():
   """Tests that xyz files with multiple frames are read correctly."""

   with open(local("test.pos_0.xyz"), "r") as f:
      for num, atoms in enumerate(io_xyz.iter_xyz(f)):
         assert(len(atoms) == 3)
         assert_equal(pos*(num+1), atoms.q)
Пример #7
0
def test_read_xyz():
   """Tests that xyz files are read correctly."""

   with open(local("test.pos_0.xyz"), "r") as f:
      atoms = io_xyz.read_xyz(f)
      assert(len(atoms) == 3)
      assert_equal(pos, atoms.q)
Пример #8
0
def index(reqClass=None, reqAction=None, reqData=None):
    comReturn = common.local()
    if comReturn:
        return comReturn

    if (reqClass == None):
        reqClass = 'index'
    pageFile = ('config', 'control', 'crontab', 'files', 'firewall', 'index',
                'plugins', 'login', 'system', 'site', 'ssl', 'task', 'soft')
    if not reqClass in pageFile:
        return redirect('/')

    if reqAction == None:
        if not isLogined():
            return redirect('/login')

        import config_api
        data = config_api.config_api().get()
        return render_template(reqClass + '.html', data=data)

    classFile = ('config_api', 'crontab_api', 'files_api', 'firewall_api',
                 'plugins_api', 'system_api', 'site_api', 'task_api')
    className = reqClass + '_api'
    if not className in classFile:
        return "error"

    eval_str = "__import__('" + className + "')." + className + '()'
    newInstance = eval(eval_str)

    return publicObject(newInstance, reqAction)
Пример #9
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, atoms.q)
Пример #10
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 * (num + 1), atoms.q)
Пример #11
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, atoms.q)
Пример #12
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)
Пример #13
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)
Пример #14
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)
Пример #15
0
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"]
Пример #16
0
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"]