Exemplo n.º 1
0
def test_glow():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    from chemlab.graphics.postprocessing.glow import GlowEffect
    from PySide import QtCore

    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    #mol = datafile('tests/data/3ZJE.pdb').read('system')

    v = QtViewer()

    colors = np.array([(255, 0, 0, 255)]*mol.n_atoms)
    colors[0][3] = 0

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(SphereImpostorRenderer, mol.r_array, [0.1]*mol.n_atoms,
                        colors)

    ge = v.add_post_processing(GlowEffect)
    #v.add_post_processing(GammaCorrectionEffect)
    def changeglow():
        #ge.radius = np.sin(time.time()*10.0) + 2.5
        colors[0][3] = 255 * (np.sin(time.time()*10.0)*0.5 + 0.5)
        sr.update_colors(colors)
        v.widget.update()

    timer = QtCore.QTimer()
    timer.timeout.connect(changeglow)
    timer.start(10)
    #v.add_post_processing(SSAOEffect, ssao_power = 5.0)
    #v.add_post_processing(FXAAEffect)
    #v.add_post_processing(GammaCorrectionEffect)
    v.run()
Exemplo n.º 2
0
def test_glow():
    from PySide import QtCore

    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')

    v = QtViewer()
    colors = np.array([(255, 0, 0, 255)] * mol.n_atoms)
    colors[0][3] = 0

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(SphereImpostorRenderer, mol.r_array,
                        [0.1] * mol.n_atoms, colors)

    ge = v.add_post_processing(GlowEffect)

    #v.add_post_processing(GammaCorrectionEffect)
    def changeglow():
        #ge.radius = np.sin(time.time()*10.0) + 2.5
        colors[0][3] = 255 * (np.sin(time.time() * 10.0) * 0.5 + 0.5)
        sr.update_colors(colors)
        v.widget.update()

    timer = QtCore.QTimer()
    timer.timeout.connect(changeglow)
    timer.start(10)
    v.run()
Exemplo n.º 3
0
def test_glow():
    from PySide import QtCore
    
    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    
    v = QtViewer()
    colors = np.array([(255, 0, 0, 255)]*mol.n_atoms)
    colors[0][3] = 0

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(SphereImpostorRenderer, mol.r_array, [0.1]*mol.n_atoms,
                        colors)

    ge = v.add_post_processing(GlowEffect)
    #v.add_post_processing(GammaCorrectionEffect)
    def changeglow():
        #ge.radius = np.sin(time.time()*10.0) + 2.5
        colors[0][3] = 255 * (np.sin(time.time()*10.0)*0.5 + 0.5)
        sr.update_colors(colors)
        v.widget.update()

    timer = QtCore.QTimer()
    timer.timeout.connect(changeglow)
    timer.start(10)
    v.run()
Exemplo n.º 4
0
def test_glow():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    from chemlab.graphics.postprocessing.glow import GlowEffect
    from PySide import QtCore

    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    #mol = datafile('tests/data/3ZJE.pdb').read('system')

    v = QtViewer()

    colors = np.array([(255, 0, 0, 255)] * mol.n_atoms)
    colors[0][3] = 0

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(SphereImpostorRenderer, mol.r_array,
                        [0.1] * mol.n_atoms, colors)

    ge = v.add_post_processing(GlowEffect)

    #v.add_post_processing(GammaCorrectionEffect)
    def changeglow():
        #ge.radius = np.sin(time.time()*10.0) + 2.5
        colors[0][3] = 255 * (np.sin(time.time() * 10.0) * 0.5 + 0.5)
        sr.update_colors(colors)
        v.widget.update()

    timer = QtCore.QTimer()
    timer.timeout.connect(changeglow)
    timer.start(10)
    #v.add_post_processing(SSAOEffect, ssao_power = 5.0)
    #v.add_post_processing(FXAAEffect)
    #v.add_post_processing(GammaCorrectionEffect)
    v.run()
Exemplo n.º 5
0
def test_outline():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    from chemlab.graphics.postprocessing.outline import OutlineEffect

    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')

    mol = datafile('tests/data/3ZJE.pdb').read('system')
    #mol = datafile('tests/data/water.gro').read('system')
    #mol = datafile('tests/data/benzene.mol').read('molecule')
    v = QtViewer()

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(AtomRenderer,
                        mol.r_array,
                        mol.type_array,
                        'impostors',
                        shading='toon')

    v.add_post_processing(OutlineEffect, 'depthnormal')
    v.add_post_processing(SSAOEffect, ssao_power=4.0)
    v.add_post_processing(FXAAEffect)
    v.add_post_processing(GammaCorrectionEffect)
    v.run()
Exemplo n.º 6
0
def test_random():
    '''Testing random made box'''
    from chemlab.db import ChemlabDB
    cdb = ChemlabDB()
    na = Molecule([Atom('Na', [0.0, 0.0, 0.0])])
    cl = Molecule([Atom('Cl', [0.0, 0.0, 0.0])])
    wat = cdb.get("molecule", 'gromacs.spce')

    s = random_lattice_box([na, cl, wat], [160, 160, 160], [4, 4, 4])
Exemplo n.º 7
0
def test_random():
    '''Testing random made box'''
    from chemlab.db import ChemlabDB
    cdb = ChemlabDB()
    na = Molecule([Atom('Na', [0.0, 0.0, 0.0])])
    cl = Molecule([Atom('Cl', [0.0, 0.0, 0.0])])
    wat = cdb.get("molecule", 'gromacs.spce')

    s = random_lattice_box([na, cl, wat], [160, 160, 160], [4, 4, 4])
Exemplo n.º 8
0
def test_local():
    db = ChemlabDB()
    bz = db.get("molecule", "example.norbornene")

    pre_string = bz.tojson()
    db = LocalDB("/tmp/testdb/")
    db.store("molecule", 'norbornene', bz, nowarn=True)
    
    post_string = db.get('molecule', 'norbornene').tojson()
    assert pre_string == post_string
    
    # Do the same thing for a system of 3 norbornenes
    s = System([bz.copy() for i in range(3)])
    pre_string = s.tojson()
    db.store("system", 'norbornene-3', s, nowarn=True)
    post_string = db.get('system', 'norbornene-3').tojson()
    
    assert pre_string == post_string
Exemplo n.º 9
0
def test_local():
    db = ChemlabDB()
    bz = db.get("molecule", "example.norbornene")
    pre_dict = bz.to_dict()

    db = LocalDB("/tmp/testdb/")
    db.store("molecule", 'norbornene', bz, nowarn=True)

    post_dict = db.get('molecule', 'norbornene').to_dict()

    npeq_(pre_dict['r_array'], post_dict['r_array'])

    # Do the same thing for a system of 3 norbornenes
    s = System([bz.copy() for i in range(3)])
    pre_dict = s.to_dict()
    db.store("system", 'norbornene-3', s, nowarn=True)
    post_dict = db.get('system', 'norbornene-3').to_dict()

    npeq_(pre_dict['r_array'], post_dict['r_array'])
Exemplo n.º 10
0
def test_molecular_viewer():
    from chemlab.mviewer.qtmolecularviewer import QtMolecularViewer
    from chemlab.mviewer.representations import BallAndStickRepresentation
    cdb = ChemlabDB()

    mol = cdb.get('molecule', 'example.norbornene')
    mol.guess_bonds()
    v = QtMolecularViewer()

    v.run()
Exemplo n.º 11
0
def test_molecular_viewer():
    from chemlab.mviewer.qtmolecularviewer import QtMolecularViewer
    from chemlab.mviewer.representations import BallAndStickRepresentation
    cdb = ChemlabDB()

    mol = cdb.get('molecule', 'example.norbornene')
    mol.guess_bonds()
    v = QtMolecularViewer()
    
    v.run()
Exemplo n.º 12
0
def test_local():
    db = ChemlabDB()
    bz = db.get("molecule", "example.norbornene")
    pre_dict = bz.to_dict()

    db = LocalDB("/tmp/testdb/")
    db.store("molecule", 'norbornene', bz, nowarn=True)
    
    post_dict = db.get('molecule', 'norbornene').to_dict()
    
    npeq_(pre_dict['r_array'], post_dict['r_array'])
    
    # Do the same thing for a system of 3 norbornenes
    s = System([bz.copy() for i in range(3)])
    pre_dict = s.to_dict()
    db.store("system", 'norbornene-3', s, nowarn=True)
    post_dict = db.get('system', 'norbornene-3').to_dict()
    
    npeq_(pre_dict['r_array'], post_dict['r_array'])
Exemplo n.º 13
0
def test_molecular_viewer():
    from chemlab.graphics.qtmolecularviewer import QtMolecularViewer
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile

    cdb = ChemlabDB()

    mol = cdb.get('molecule', 'example.norbornene')

    #mol = datafile('tests/data/3ZJE.pdb').read('system')
    #mol = datafile('tests/data/naclwater.gro').read('system')
    mol.guess_bonds()

    v = QtMolecularViewer(mol)

    v.widget.camera.autozoom(mol.r_array)

    def on_action1():
        if len(v.representation.selection) == 2:
            i, j = v.representation.selection
            distsq = ((mol.r_array[j] - mol.r_array[i])**2).sum()
            print 'distance between', i, j, np.sqrt(distsq)

    def select_all_atoms():
        which = v.representation.selection[0]
        at = mol.type_array[which]
        sel = mol.type_array == at
        v.representation.make_selection(sel.nonzero()[0])

    def select_all_molecules():
        which = v.representation.last_modified
        if which is None:
            return

        at = mol.type_array[which]
        sel = mol.type_array == at
        allmol = mol.atom_to_molecule_indices(sel)
        allmol = mol.mol_to_atom_indices(allmol)
        v.representation.make_selection(allmol, additive=True)

    def change_representation():
        BallAndStickRepresentation = 0
        # We need two representations
        rep = v.add_representation(BallAndStickRepresentation, mol)
        rep.set_mask(self.selection)
        rep.set_mask(not self.selection)

    def scale_radii():
        #v.representation.scale_radii(v.representation.selection, 0.9)
        v.representation.hide(v.representation.selection)

    v.run()
Exemplo n.º 14
0
def test_molecular_viewer():
    from chemlab.graphics.qtmolecularviewer import QtMolecularViewer
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile

    cdb = ChemlabDB()

    mol = cdb.get('molecule', 'example.norbornene')

    #mol = datafile('tests/data/3ZJE.pdb').read('system')
    #mol = datafile('tests/data/naclwater.gro').read('system')
    mol.guess_bonds()

    v = QtMolecularViewer(mol)

    v.widget.camera.autozoom(mol.r_array)

    def on_action1():
        if len(v.representation.selection) == 2:
            i, j = v.representation.selection
            distsq = ((mol.r_array[j] - mol.r_array[i])**2).sum()
            print 'distance between', i, j, np.sqrt(distsq)

    def select_all_atoms():
        which = v.representation.selection[0]
        at = mol.type_array[which]
        sel = mol.type_array == at
        v.representation.make_selection(sel.nonzero()[0])

    def select_all_molecules():
        which = v.representation.last_modified
        if which is None:
            return

        at = mol.type_array[which]
        sel = mol.type_array == at
        allmol = mol.atom_to_molecule_indices(sel)
        allmol = mol.mol_to_atom_indices(allmol)
        v.representation.make_selection(allmol, additive=True)

    def change_representation():
        BallAndStickRepresentation = 0
        # We need two representations
        rep = v.add_representation(BallAndStickRepresentation, mol)
        rep.set_mask(self.selection)
        rep.set_mask(not self.selection)

    def scale_radii():
        #v.representation.scale_radii(v.representation.selection, 0.9)
        v.representation.hide(v.representation.selection)

    v.run()
Exemplo n.º 15
0
def test_molecular_viewer():
    from chemlab.graphics.qtmolecularviewer import QtMolecularViewer
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    
    cdb = ChemlabDB()
    
    mol = cdb.get('molecule', 'example.norbornene')
    
    mol = datafile('tests/data/3ZJE.pdb').read('system')
    v = QtMolecularViewer(mol)
    v.highlight([0, 2, 8])
    v.run()
    
Exemplo n.º 16
0
def test_multiple_post_processing():
    v = QtViewer()
    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    #mol = datafile('/home/gabriele/projects/LiCl/interface/loafintjc-heat/equilibrium.gro').read('system')
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array, 'impostors', shading='toon')

    # Adding multiple post processing effects


    v.add_post_processing(SSAOEffect)
    v.add_post_processing(GammaCorrectionEffect, 2.0)
    #v.add_post_processing(GammaCorrectionEffect, 2.0)
    #v.add_post_processing(FXAAEffect)

    v.run()
Exemplo n.º 17
0
def test_multiple_post_processing():
    v = QtViewer()
    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    #mol = datafile('/home/gabriele/projects/LiCl/interface/loafintjc-heat/equilibrium.gro').read('system')
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array, 'impostors', shading='toon')

    # Adding multiple post processing effects


    v.add_post_processing(SSAOEffect)
    v.add_post_processing(GammaCorrectionEffect, 2.0)
    #v.add_post_processing(GammaCorrectionEffect, 2.0)
    #v.add_post_processing(FXAAEffect)

    v.run()
Exemplo n.º 18
0
def test_ssao():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    
    cdb = ChemlabDB()
    
    mol = cdb.get('molecule', 'example.norbornene')
    
    mol = datafile('tests/data/3ZJE.pdb').read('system')
    v = QtViewer()
    

    v.widget.camera.autozoom(mol.r_array)
    v.widget.post_processing.append(SSAOEffect(v.widget, kernel_size=16, kernel_radius=3.0, ssao_power=2.7))
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array, 'impostors')
    #ar = v.add_renderer(BallAndStickRenderer, mol.r_array, mol.type_array, [])
    
    v.run()
Exemplo n.º 19
0
def test_ssao():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile

    cdb = ChemlabDB()

    mol = cdb.get('molecule', 'example.norbornene')

    mol = datafile('tests/data/3ZJE.pdb').read('system')
    v = QtViewer()

    v.widget.camera.autozoom(mol.r_array)
    v.widget.post_processing.append(
        SSAOEffect(v.widget, kernel_size=16, kernel_radius=3.0,
                   ssao_power=2.7))
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array, 'impostors')
    #ar = v.add_renderer(BallAndStickRenderer, mol.r_array, mol.type_array, [])

    v.run()
Exemplo n.º 20
0
def test_outline():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    from chemlab.graphics.postprocessing.outline import OutlineEffect
    
    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    
    mol = datafile('tests/data/3ZJE.pdb').read('system')
    #mol = datafile('tests/data/water.gro').read('system')
    #mol = datafile('tests/data/benzene.mol').read('molecule')
    v = QtViewer()

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array,
                        'impostors', shading='toon')
    
    v.add_post_processing(OutlineEffect, 'depthonly')
    v.add_post_processing(FXAAEffect)
    v.add_post_processing(GammaCorrectionEffect)
    v.run()
Exemplo n.º 21
0
def test_glow():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    from chemlab.graphics.postprocessing.glow import GlowEffect
    
    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    #mol = datafile('tests/data/3ZJE.pdb').read('system')

    v = QtViewer()

    colors = np.array([(255, 0, 0, 255)]*mol.n_atoms)
    colors[0][3] = 0
    
    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(SphereImpostorRenderer, mol.r_array, [0.1]*mol.n_atoms,
                        colors)
    
    v.add_post_processing(GlowEffect)
    #v.add_post_processing(SSAOEffect, ssao_power = 5.0)
    #v.add_post_processing(FXAAEffect)
    #v.add_post_processing(GammaCorrectionEffect)
    v.run()
Exemplo n.º 22
0
from ....cclib_patch.parser import gausscomparser
from ....cclib_patch.parser import gaussianparser

_types = {
    'gamess': GAMESS,
    'gamessuk': GAMESSUK,
    'gaussian': gaussianparser.Gaussian,
    'gausscom': gausscomparser.Gausscom,
    'jaguar': Jaguar,
    'molpro': Molpro,
    #'nwchem': NWChem,
    'orca': ORCA
}

cdb = ChemlabDB()
symbols = cdb.get('data', 'symbols')


def _create_cclib_handler(type):
    if type not in _types:
        raise FormatNotSupported(type)

    class _Handler(IOHandler):
        def __init__(self, fd, filetype=type):
            super(_Handler, self).__init__(fd)
            self.filetype = filetype
            self.data = _types[filetype](fd, loglevel=logging.ERROR).parse()

        def read(self, feature, *args, **kwargs):
            if feature == 'molecular orbitals':
                n = args[0]