コード例 #1
0
    def webData(self):
        """
        Returns 2 strings with HTML code
        """
        # Show weird bond angles topology

        we = self.settings.Engine3D()

        b1, b2 = '', ''

        # b1:
        # 1. use 3D geom
        # 2. if not available, make 2D picture,
        # 3. if not available, make ASCII pseudographics
        # ...

        #b2 += 'Version: %s' % (self.NBO_version)  + web.brn
        if self.options:
            b2 += web.tag('NBO options:', 'strong') + web.brn
            b2 += self.options + web.brn
        if self.comments:
            b2 += self.comments + web.brn
        if self.OpenShell:
            b2 += web.tag('Alpha spin NBO interactions', 'strong') + web.brn
            b2 += self.setA.webData()
            b2 += web.tag('Beta spin NBO interactions', 'strong') + web.brn
            b2 += self.setB.webData()
        else:
            b2 += web.tag('NBO interactions', 'strong') + web.brn
            b2 += self.setAB.webData()

        log.debug('webData generated successfully')
        return b1, b2
コード例 #2
0
ファイル: NBO.py プロジェクト: mtthwflst/terse
    def webData(self):
        """
        Returns 2 strings with HTML code
        """
        # Show weird bond angles topology

        we = self.settings.Engine3D()

        b1, b2 = '', ''

        # b1:
        # 1. use 3D geom
        # 2. if not available, make 2D picture,
        # 3. if not available, make ASCII pseudographics
        # ...

        #b2 += 'Version: %s' % (self.NBO_version)  + web.brn
        if self.options:
            b2 += web.tag('NBO options:','strong')+web.brn
            b2 += self.options + web.brn
        if self.comments:
            b2 += self.comments + web.brn
        if self.OpenShell:
            b2 += web.tag('Alpha spin NBO interactions','strong') + web.brn
            b2 += self.setA.webData()
            b2 += web.tag('Beta spin NBO interactions','strong') + web.brn
            b2 += self.setB.webData()
        else:
            b2 += web.tag('NBO interactions','strong') + web.brn
            b2 += self.setAB.webData()

        log.debug('webData generated successfully')
        return b1, b2
コード例 #3
0
    def webData(self):
        """
        Makes HTML row.
        If some parameteres were read from comment sections of .xyz files,
        graph is plotted
        return: b1,b2
        """

        we = self.settings.Engine3D()

        JmolScript = ''
        b2 = web.tag('Comments:', 'strong') + web.brn + self.geoms.comment
        if self.scan:
            b2 += self.scan.webData()
            JmolScript += we.measureGau(self.scan.props)
            self.wp = self.scan.write(fname='.xyz', vectors=self.vector)
        else:
            self.wp = self.geoms.write(fname='.xyz', vectors=self.vector)
        b1 = we.JMolApplet(webpath=self.wp, ExtraScript=JmolScript) + web.brn

        if len(self.geoms.geoms) > 1:
            b1 += we.MultipleGeoms()
        elif self.vector:
            b1 += we.JMolCheckBox('vibration on', 'vibration off', 'Vibration')

        log.debug('webData generated successfully')
        return b1, b2
コード例 #4
0
 def JMolRadioGroup(self, options):
     s = ''
     for opt in options:
         s2 = ''
         for o in opt:
             s2 += '"%s", ' % (o)
         s += '[%s],' % (s2[:-2])
     s = 'jmolRadioGroup([%s])' % (s[:-1])
     return web.tag(s,'SCRIPT')
コード例 #5
0
 def JMolMenu(self, options,script=True):
     s = ''
     for opt in options:
         s2 = ''
         for o in opt: s2 += '"%s", ' % (o)
         s += '[%s],' % (s2[:-2])
     s = 'jmolMenu([%s])' % (s[:-1])
     if script:
         s = web.tag(s,'SCRIPT')
     return s
コード例 #6
0
    def MultipleGeoms(self):
        s = """jmolButton("frame 1","<<");
        jmolButton("anim direction +1 ; frame prev","<");
        jmolButton("anim direction +1 ; frame next",">");
        jmolButton("anim direction +1 ;frame last",">>");
        jmolButton("anim mode once; frame 1; anim direction +1 ; anim on", "Play once");
        jmolButton("anim mode once; frame last ; anim direction -1 ; anim on", "Play back");
        jmolButton("anim off", "Stop");
        """

        opts = []
        for a in (1,5,10,25,50):
            opts.append(['set animationFPS %s' % (a), a])
        opts[2].append('checked')

        s += self.JMolMenu(opts,script=False)
        return web.tag(s,'SCRIPT')
コード例 #7
0
 def JMolCheckBox(self, on, off, label=''):
     s = 'jmolCheckbox("%s", "%s", "%s")' % (on, off, label)
     return web.tag(s,'SCRIPT')
コード例 #8
0
 def JMolText(self,label,position='top left',color='green',script=True):
     s = "set echo %s; color echo %s; echo %s;" % (position,color,label)
     if script:
         s = web.tag(s,'SCRIPT')
     return s
コード例 #9
0
 def JMolCommandInput(self):
     s = 'jmolCommandInput("Execute")'
     return web.tag(s,'SCRIPT')
コード例 #10
0
ファイル: HTML.py プロジェクト: mtthwflst/terse
        f.write(self.s)
        f.close()
        log.debug('Web page %s was created' % (file))


    def finalize(self):
        d = {
                'JSMolPath' : self.settings.JSMolLocation,
                'timestamp' : self.settings.timestamp,
                'JMolPath'  : self.settings.JmolPath,
                'pageBody'  : self.pageBody,
                'JMolWinX'  : self.settings.JMolWinX,
                'JMolWinY'  : self.settings.JMolWinY,
            }
        self.s = self.s % d




if __name__ == "__main__":
    h = HTML()
    from Settings import Settings
    h.settings = Settings()
    tr = web.tag('abcd','tr')

    # This code is outdated!
    h.makeHeader()
    h.makeLine('abc','def')
    h.makeTail()
    print h
コード例 #11
0
ファイル: JSMol.py プロジェクト: mtthwflst/terse
 def JMolApplet(self, webpath='', ExtraScript=''):
     s = "jmolApplet%s = Jmol.getApplet(\"jmolApplet%s\", Info)" % ((self.settings.counter,)*2)
     script = self.JMolLoad(webpath=webpath,ExtraScript=ExtraScript)
     s += ';\n' + self.JSMolStyle(script)
     return web.tag(s,'SCRIPT')
コード例 #12
0
 def addLeftDiv(self, *args):
     left_panel = ''
     for a in args:
         left_panel += web.tag(a, 'div', "class='left_panel'") + '\n'
     return left_panel
コード例 #13
0
        except IOError:
            log.critical('Cannot open %s for writing' % (file))
            return
        f.write(self.s)
        f.close()
        log.debug('Web page %s was created' % (file))

    def finalize(self):
        d = {
            'JSMolPath': self.settings.JSMolLocation,
            'timestamp': self.settings.timestamp,
            'JMolPath': self.settings.JmolPath,
            'pageBody': self.pageBody,
            'JMolWinX': self.settings.JMolWinX,
            'JMolWinY': self.settings.JMolWinY,
        }
        self.s = self.s % d


if __name__ == "__main__":
    h = HTML()
    from Settings import Settings
    h.settings = Settings()
    tr = web.tag('abcd', 'tr')

    # This code is outdated!
    h.makeHeader()
    h.makeLine('abc', 'def')
    h.makeTail()
    print h
コード例 #14
0
    def webData(self,StartApplet=True):
        we = self.settings.Engine3D()
        io = IO()

        color = {'err':'red', 'imag':'blue', 'lot':'green'}
        b2, JmolScript = '', ''
        comments = []

        if self.JobType:
            sx = self.JobType.upper()
            if 'irc' in self.JobType:
                sx += ' ' + self.series.textDirection()
            sx = web.br + web.tag(sx,'strong')

            if self.OK:
                b2 += sx
            else:
                b2 += web.tag(sx,"SPAN style='color:%s'" % (color['err']))

        if self.lot:
            if self.basis:
                self.lot += '/' + self.basis
            b2 += web.br + web.tag(self.lot.upper(),"SPAN style='color:%s'" % (color['lot']))

        if self.solvent:
            sx = 'Solvation: '
            if self.solv_model:
                sx += '%s(%s)' % (self.solv_model, self.solvent)
            else:
                sx += self.solvent
            b2 += web.br + web.tag(sx,"SPAN style='color:%s'" % (color['lot']))

        if self.sym:
            b2 += web.br + "Symmetry: %s\n" % (self.sym)

        if self.charge:
            b2 += web.br + "Charge: %s; "  % (self.charge)

        if self.mult:
            b2 += "Mult: %s\n"  % (self.mult)

        if self.lot and not self.lot.find('R')==0:
            b2 += web.br + "S2= %s,\n"  % (self.s2)

        if self.scf_e:
            b2 += web.br +  "E_SCF= %-11.6f\n" % (self.scf_e)

        if self.amplitude:
            f_ampl = float(self.amplitude)
            s_ampl = '%.3f' % (f_ampl)
            if f_ampl >= 0.1:
                sx = web.tag(s_ampl,"SPAN style='color:%s'" % (color['err']))
            else:
                sx = s_ampl
            b2 += web.br + "Max Amplitude= %s\n" % (sx)

        # Add pics for SP 
        if 'sp' in self.JobType and not self.OK:
            wftype = ''
            if not self.ci_cc_done:
                wftype = 'ci_cc'
            if not self.scf_done:
                wftype = 'scf'
            if wftype:
                b2 += web.br + wftype + ' not converged...'
                y = getattr(self,wftype+'_conv')
                picpath = io.writePic('-sp-conv.png',xname='Step N',yname='E, '+self.settings.EnergyUnits,y=y)
                b2 += web.img(picpath)
        # Freq
        if 'freq' in self.JobType:
            # Give thermochemistry values
            for i in range(len(self.freq_temp)):
                b2 += web.br + "T=%6.2f: H= %10.6f, E+ZPE= %10.6f, G= %10.6f\n" \
                      % (self.freq_temp[i],self.freq_ent[i],self.freq_zpe[i],self.freq_G[i])
            if self.freqs:
                # Show freqs
                b2 += web.br + "Freqs: "
                # Color i-freqs
                i = 0
                while self.freqs[i] < 0:
                    s_freq = "% .1f," % (self.freqs[i])
                    if i == 0:
                        col = 'imag'
                    else:
                        col = 'err'
                    b2 += web.tag(s_freq, "SPAN style='color:%s'" % (color[col]))
                    i += 1
                b2 += "%.1f .. %.1f\n" % (self.freqs[i], self.freqs[-1])
            if self.nimag > 0:
                b2 += web.brn + web.tag('Imaginary Freq(s) found!',"SPAN style='color:%s'" % (color['imag']))

        # Frozen
        if self.frozen:
            frs = self.frozen.values()
            self.extra += web.br + 'Frozen parameters detected (highlighted with measurement lines)'
            JmolScript += we.measureGau(frs)
            if len(frs)>3:
                JmolScript += 'set measurementlabels off;'
        # Opt
        if 'opt' in self.JobType:
            b2 += web.br + web.tag('NOpt=%i' % (self.opt_iter),'em')
            if not self.opt_ok:
                b2 += web.br + "Stationary Point not found!\n"
            if (not self.OK) or self.settings.FullGeomInfo:
                sg = self.geoms
                y = [sg.toBaseLine(), sg.max_force, sg.rms_force, sg.max_displacement, sg.rms_displacement]
                ylabel = 'E, %s' % (self.settings.EnergyUnits)
                picpath = io.writePic('-opt-conv.png',
                        xname='Step N',yname=ylabel,
                        keys=['E','Max Force', 'RMS Force', 'Max Displacement', 'RMS Displacement'],
                        y=y,ny2=4
                        )
                b2 += web.img(picpath)
                #b2 += self.geoms.plot(xlabel='Opt point')
        # IRC
        if 'irc' in self.JobType:
            b2 += self.series.webData()
            comments = self.series.comments

        # Scan
        if 'scan' in self.JobType:
            #print self.series.props
            b2 += self.series.webData()
            JmolScript += we.measureGau(self.series.props)

        # TD DFT
        if 'td' in self.JobType and self.uv:
            b2 += web.brn + web.tag('UV Spectra','em') + web.brn
            for w in sorted(self.uv):
                #if w > 1000.:
                if self.uv[w] > 0.01:
                    b2 += "%s %s\n" % (w, self.uv[w]) + web.brn
            b2 += web.brn

        #
        # Charges
        # 
        sx = ''
        for i in range(len(self.geoms)):
            g = self.geoms[i]
            if g.atprops:
                sx += 'Structure %i: ' % (i+1)
                for ap in g.atprops:
                    sx += getattr(g,ap).webData()
                sx += we.JMolButton('label off;color atoms cpk','Off') + web.brn
            if self.settings.full and hasattr(g,'nbo_analysis'):
                nbo_b1,nbo_b2 = g.nbo_analysis.webData()
                sx += nbo_b2
        b2 += web.brn + sx

        # NBO Topology
        nbobonds = ''
        bo = ('-','S','D','T','Q')
        if self.topologies:
            pass
            # TODO write this topology to MOL file
            #for i in self.nbo_topology:
                #for j in self.nbo_topology[i]:
                    #nbobonds += "%s %s %s " % (bo[self.nbo_topology[i][j]],i,j)
        if self.comments:
            b2 += web.br +  web.tag('Comments','strong') + ":%s\n" % self.comments

        if self.warnings:
            b2 += web.br +  web.tag('Warnings','strong') + ":%s\n" % self.warnings

        if self.extra:
            b2 += web.br + web.tag(self.extra,'em')

        b2 += web.br



        #
        # ----- b1 -----
        #
        #if self.nbo_topology and not self.vectors:
        wp = self.geoms.write(fname='.xyz', vectors=self.vector)
        labeltext = '%s: %s' %(self.JobType,self.lot)

        if StartApplet:
            JmolScript += '; ' + we.JMolText(label=labeltext.upper(),script=False)
            #JmolScript += '; ' + we.JMolText(label='model %{_modelNumber}',position='bottom left', script=False)
            JmolScript += '; ' + we.JMolText(label='model _modelNumber',position='bottom left', script=False)
            b1 = we.JMolApplet(webpath=wp, ExtraScript = JmolScript)
            b1 += web.brn + we.JMolCommandInput()
            if len(self.geoms)>1:
                b1 += web.brn + we.MultipleGeoms()
        else:
            b1 = we.JMolLoad(webpath=wp, ExtraScript=JmolScript)
            b1 += '; ' + we.JMolText(label=labeltext.upper(),script=False)
            #b1 += '; ' + we.JMolText(label='model %{_modelNumber}',position='bottom left', script=False)
            b1 += '; ' + we.JMolText(label='model _modelNumber',position='bottom left', script=False)

        log.debug('webData for Gaussian step generated successfully')
        return b1, b2
コード例 #15
0
ファイル: HTML.py プロジェクト: mtthwflst/terse
 def addDivRowWrapper(self,*args):
     row = ''
     for a in args:
         row += a
     self.pageBody += web.tag(row,'div',"class='row_wrapper'")
コード例 #16
0
ファイル: HTML.py プロジェクト: mtthwflst/terse
 def addRightDiv(self,*args):
     right_panel = ''
     for a in args:
         right_panel += web.tag(a,'div',"class='right_panel'")+'\n'
     return right_panel
コード例 #17
0
ファイル: HTML.py プロジェクト: mtthwflst/terse
 def addLeftDiv(self,*args):
     left_panel = ''
     for a in args:
         left_panel += web.tag(a,'div',"class='left_panel'")+'\n'
     return left_panel
コード例 #18
0
 def JMolButton(self, action, label):
     s = 'jmolButton("%s","%s")' % (action, label)
     return web.tag(s,'SCRIPT')
コード例 #19
0
 def addRightDiv(self, *args):
     right_panel = ''
     for a in args:
         right_panel += web.tag(a, 'div', "class='right_panel'") + '\n'
     return right_panel
コード例 #20
0
 def addDivRowWrapper(self, *args):
     row = ''
     for a in args:
         row += a
     self.pageBody += web.tag(row, 'div', "class='row_wrapper'")
コード例 #21
0
 def JMolApplet(self, webpath='', ExtraScript=''):
     script = self.JMolLoad(webpath=webpath,ExtraScript=ExtraScript)
     s = 'jmolApplet([%s,%s],"%s")' % (self.settings.JmolWinX, self.settings.JmolWinY, script)
     return web.tag(s,'SCRIPT')
コード例 #22
0
 def JSMolScript(self, s, intag=''):
     s2 = self.JSMolStyle(s)
     return web.tag(s2, 'SCRIPT', intag=intag)
コード例 #23
0
ファイル: JSMol.py プロジェクト: mtthwflst/terse
 def JSMolScript(self, s, intag=''):
     s2 = self.JSMolStyle(s)
     return web.tag(s2,'SCRIPT',intag=intag)
コード例 #24
0
 def Vibration(self):
     s = 'jmolCheckbox("vibration on", "vibration off", "Vibration");'
     return web.tag(s,'SCRIPT')
コード例 #25
0
    def webData(self):
        """
        Returns 2 strings with HTML code
        """
        # Show weird bond angles topology

        we = self.settings.Engine3D()

        Lb1, Lb2 = self.L.webData()
        Cb1, Cb2 = self.C.webData()

        b1 = Lb1

        b2  = web.tag('Gaussian Log File','strong')+web.brn + Lb2
        b2 += web.tag('Gaussian Chk File','strong')+web.brn + Cb2

        #---
        def set_webData(nbo_result):
            s = ''
            any_shown = False
            script_off = 'isosurface off; '
            if 't' in self.file:
                threshold = float(self.file['t'])
            else:
                threshold = float(self.settings.inbo_threshold)

            cubes_done = {}
            for sopta in nbo_result.sopta:
                if float(sopta.e2) > threshold:
                    any_shown = True
                    s += '%s -> %s: %s kcal/mol' % (sopta.donor.sorb, sopta.acceptor.sorb, sopta.e2)
                    i_donor = str(sopta.donor.chk_index)
                    if i_donor in cubes_done:
                        c_donor = cubes_done[i_donor]
                    else:
                        c_donor = self.C.fchk.makeCube('MO='+i_donor, name='mo'+i_donor)

                    i_acceptor = str(sopta.acceptor.chk_index)
                    if i_acceptor in cubes_done:
                        c_acceptor = cubes_done[i_acceptor]
                    else:
                        c_acceptor = self.C.fchk.makeCube('MO='+i_acceptor, name='mo'+i_acceptor,colors='phase green yellow')

                    script = "%s ; %s ; %s" % (script_off, c_donor.s_script, c_acceptor.s_script)
                    #script += we.JMolIsosurface(webpath = c_donor.wpcube,  surftype='MO',name='mo'+i_donor)
                    #script += "; "
                    #script += we.JMolIsosurface(webpath = c_acceptor.wpcube,  surftype='MO',name='mo'+i_acceptor,colors='phase green yellow')
                    s += we.JMolButton(action=script,label='Show')
                    s += web.brn
            if any_shown:
                s += we.JMolButton(action=script_off,label='Off')
            return s
        #---
        if self.nbo.options:
            b2 += web.tag('Options:','strong')+web.brn
            b2 += self.nbo.options + web.brn
        if self.nbo.comments:
            b2 += self.nbo.comments + web.brn
        if self.nbo.OpenShell:
            b2 += web.tag('Alpha spin NBO interactions','strong') + web.brn
            b2 += set_webData(self.nbo.setA)
            b2 += web.tag('Beta spin NBO interactions','strong') + web.brn
            b2 += set_webData(self.nbo.setB)
        else:
            b2 += web.tag('NBO interactions','strong') + web.brn
            b2 += set_webData(self.nbo.setAB)

        log.debug('webData generated successfully')
        return b1, b2
コード例 #26
0
 def JMolApplet(self, webpath='', ExtraScript=''):
     s = "jmolApplet%s = Jmol.getApplet(\"jmolApplet%s\", Info)" % (
         (self.settings.counter, ) * 2)
     script = self.JMolLoad(webpath=webpath, ExtraScript=ExtraScript)
     s += ';\n' + self.JSMolStyle(script)
     return web.tag(s, 'SCRIPT')