Ghost/Create_epsmap.py
def run_APBS(self,titgroup=None,charge=None,epsmap=None,focus=None,APBSauto=True,deletedir=True):
        """Run APBS in mg-auto mode to get a map focussed on the protein"""
        #
        # Potname
        #
        import tempfile
        thisdir=tempfile.mkdtemp(dir='/tmp')
        import os
        potname=os.path.join(thisdir,'%s_potential' %(titgroup))
        #
        # Get charge
        #
        import pKa.pKD_tools
        titgroup_type=pKa.pKD_tools.get_titgroup_type_from_titgroup(titgroup)
        charge=self.PI.titgroups[titgroup_type]['charge']
        #
        # Get the PQR file
        #
        import Protool.assign_parameters
        self.PQR=Protool.assign_parameters.assign_parameters(self.PI)
        self.PQR.clear_all_charges_and_radii()
        self.PQR.set_all_radii()
        titpos=self.get_charge_center(titgroup)
        self.PI.add_atom(uniqueid='Z:999:CHA',atomnumber=99999,atomname='CHA',    
                            chainid='Z',residuename='DUM',residuenumber='999',
                            xcoord=titpos[0],ycoord=titpos[1],zcoord=titpos[2],update=1,BFACTOR=None,OCCUPANCY=None,CHARGE=charge,RADIUS=1.55,tag=None)
        pqrfile=os.path.join(thisdir,'currentPQR.pqr')
        self.PI.writepqr(pqrfile)
        self.PI.remove_atom('Z:999:CHA')
        #
        # Get the coarse and fine centers
        #
        self.coarsecent,extent=self.PI.get_center_of_coords()
        self.coarsedim=1.5*extent
        if focus is None:
            self.finedim=extent
            self.finecent=self.coarsecent
        else:
            self.finecent=[focus[0],focus[1],focus[2]] 
            ngrid=65
            self.finedim=[ngrid*0.2,ngrid*0.2,ngrid*0.2]
        #
        # Run APBS
        #
        import os
        os.chdir(thisdir)
        infile=os.path.join(thisdir,'apbs.in')
        fp = open(infile, "w")
        text = "read\n"
        text += "    mol pqr %s\n" %pqrfile
        #
        #
        #
        if self.options.epsmap:
            name='usemap'
            dirname=thisdir
            names=self.epsmap.set_and_write_epsmap(dirname,name)
            text += "    diel dx %s %s %s\n" %(names[0],names[1],names[2])
            #text += "    kappa dx kappa%d.dx\n"%i
            #text += '    diel dx '
            #for n in ['x','y','z']:
            #    text=text+" %s " %(os.path.join(self.topdir,'start_values','%sdiel.dx' %n))
            #text=text+" \n"
            
        text += "end\n"
        #
        # Start of ELEC section
        #
        text += "elec\n"
        if APBSauto:
            text += "    mg-auto\n"
        else:
            text=text+"    mg-manual"
            
        text += "    dime 65 65 65\n"
        #text += "    grid %.2f %.2f %.2f\n"%(dim, dim, dim)
        #text += "    gcent %.3f %.3f %.3f\n"%(self.center[0], self.center[1], self.center[2])
       

        if APBSauto:
            text += "    cglen %.4f %.4f %.4f\n" % (self.coarsedim[0], self.coarsedim[1], self.coarsedim[2])
            text += "    cgcent %.3f %.3f %.3f\n" %(self.coarsecent[0],self.coarsecent[1],self.coarsecent[2])
            text += "    fglen %.4f %.4f %.4f\n" % (self.finedim[0], self.finedim[1], self.finedim[2])
            text += "    fgcent %.3f %.3f %.3f\n" %(self.finecent[0],self.finecent[1],self.finecent[2])
        else:
            text += "    glen %.4f %.4f %.4f\n" % (self.coarsedim[0], self.coarsedim[1], self.coarsedim[2])
            text += "    gcent %.3f %.3f %.3f\n" %(self.coarsecent[0],self.coarsecent[1],self.coarsecent[2])
        #
        text += "    mol 1\n"
        text += "    lpbe\n"
        text += "    ion charge 1 conc 0.00 radius 2.0\n"
        text += "    ion charge -1 conc 0.00 radius 2.0\n"
        if self.options.smoothe:
            text += "    srfm smol\n" # smoothe the surface
        else:
            text += "    srfm mol\n"  # do not smoothe the dielectric boundary!
        text += "    chgm spl0\n"
        text += "    srad 1.4\n"
        text += "    swin 0.3\n"
        text += "    sdens 10.0\n"
        text += "    temp 298.15\n"
        #text += "    usemap kappa 1\n"
        text += "    pdie %5.2f\n" %self.eps
        text += "    sdie %5.2f\n" %self.options.wateps
        if self.options.epsmap:
            text += "    usemap diel 1-3\n"
        text += "    bcfl sdh"
        text += "    calcenergy no\n"
        text += "    calcforce no\n"
        text += "    write dielx dx xdiel\n"
        text += "    write diely dx ydiel\n"
        text += "    write dielz dx zdiel\n"
        text += "    write pot dx %s\n" %potname
        #text += "    write kappa dx kappa\n"

        text += "end\n"
            
        fp.write(text)
        fp.close()
        # run APBS #
        if not options.verbose:
            import subprocess
            outputStream = open('/dev/null', 'w+')
            process = subprocess.Popen(['%s %s' %(APBSpath,infile)], stdout=outputStream, stderr=subprocess.STDOUT, shell=True)
            process.wait()
            outputStream.close()
            os.system("rm io.mc")
        else:
            import os
            os.system('%s %s' %(APBSpath,infile))
        #
        data=[]
        value=0.0
        startVio()
        grid = Vgrid_ctor(0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, data)
        Vgrid_readDX(grid, "FILE", "ASC", "", potname+'.dx')
        if deletedir:
            #
            # Delete the dir
            #
            import shutil
            shutil.rmtree(thisdir)
            return grid
        else:
            return thisdir
Run APBS in mg-auto mode to get a map focussed on the protein
Run APBS in mg-auto mode to get a map focussed on the protein
Run APBS in mg - auto mode to get a map focussed on the protein
def run_APBS(self,titgroup=None,charge=None,epsmap=None,focus=None,APBSauto=True,deletedir=True):
         Potname
        import tempfile
        thisdir=tempfile.mkdtemp(dir='/tmp')
        import os
        potname=os.path.join(thisdir,'%s_potential' %(titgroup))
         Get charge
        import pKa.pKD_tools
        titgroup_type=pKa.pKD_tools.get_titgroup_type_from_titgroup(titgroup)
        charge=self.PI.titgroups[titgroup_type]['charge']
         Get the PQR file
        import Protool.assign_parameters
        self.PQR=Protool.assign_parameters.assign_parameters(self.PI)
        self.PQR.clear_all_charges_and_radii()
        self.PQR.set_all_radii()
        titpos=self.get_charge_center(titgroup)
        self.PI.add_atom(uniqueid='Z:999:CHA',atomnumber=99999,atomname='CHA',    
                            chainid='Z',residuename='DUM',residuenumber='999',
                            xcoord=titpos[0],ycoord=titpos[1],zcoord=titpos[2],update=1,BFACTOR=None,OCCUPANCY=None,CHARGE=charge,RADIUS=1.55,tag=None)
        pqrfile=os.path.join(thisdir,'currentPQR.pqr')
        self.PI.writepqr(pqrfile)
        self.PI.remove_atom('Z:999:CHA')
         Get the coarse and fine centers
        self.coarsecent,extent=self.PI.get_center_of_coords()
        self.coarsedim=1.5*extent
        if focus is None:
            self.finedim=extent
            self.finecent=self.coarsecent
        else:
            self.finecent=[focus[0],focus[1],focus[2]] 
            ngrid=65
            self.finedim=[ngrid*0.2,ngrid*0.2,ngrid*0.2]
         Run APBS
        import os
        os.chdir(thisdir)
        infile=os.path.join(thisdir,'apbs.in')
        fp = open(infile, "w")
        text = "read\n"
        text += "    mol pqr %s\n" %pqrfile
        if self.options.epsmap:
            name='usemap'
            dirname=thisdir
            names=self.epsmap.set_and_write_epsmap(dirname,name)
            text += "    diel dx %s %s %s\n" %(names[0],names[1],names[2])
            text += "    kappa dx kappa%d.dx\n"%i
            text += '    diel dx '
            for n in ['x','y','z']:
                text=text+" %s " %(os.path.join(self.topdir,'start_values','%sdiel.dx' %n))
            text=text+" \n"
        text += "end\n"
         Start of ELEC section
        text += "elec\n"
        if APBSauto:
            text += "    mg-auto\n"
        else:
            text=text+"    mg-manual"
        text += "    dime 65 65 65\n"
        text += "    grid %.2f %.2f %.2f\n"%(dim, dim, dim)
        text += "    gcent %.3f %.3f %.3f\n"%(self.center[0], self.center[1], self.center[2])
        if APBSauto:
            text += "    cglen %.4f %.4f %.4f\n" % (self.coarsedim[0], self.coarsedim[1], self.coarsedim[2])
            text += "    cgcent %.3f %.3f %.3f\n" %(self.coarsecent[0],self.coarsecent[1],self.coarsecent[2])
            text += "    fglen %.4f %.4f %.4f\n" % (self.finedim[0], self.finedim[1], self.finedim[2])
            text += "    fgcent %.3f %.3f %.3f\n" %(self.finecent[0],self.finecent[1],self.finecent[2])
        else:
            text += "    glen %.4f %.4f %.4f\n" % (self.coarsedim[0], self.coarsedim[1], self.coarsedim[2])
            text += "    gcent %.3f %.3f %.3f\n" %(self.coarsecent[0],self.coarsecent[1],self.coarsecent[2])
        text += "    mol 1\n"
        text += "    lpbe\n"
        text += "    ion charge 1 conc 0.00 radius 2.0\n"
        text += "    ion charge -1 conc 0.00 radius 2.0\n"
        if self.options.smoothe:
            text += "    srfm smol\n"  smoothe the surface
        else:
            text += "    srfm mol\n"   do not smoothe the dielectric boundary!
        text += "    chgm spl0\n"
        text += "    srad 1.4\n"
        text += "    swin 0.3\n"
        text += "    sdens 10.0\n"
        text += "    temp 298.15\n"
        text += "    usemap kappa 1\n"
        text += "    pdie %5.2f\n" %self.eps
        text += "    sdie %5.2f\n" %self.options.wateps
        if self.options.epsmap:
            text += "    usemap diel 1-3\n"
        text += "    bcfl sdh"
        text += "    calcenergy no\n"
        text += "    calcforce no\n"
        text += "    write dielx dx xdiel\n"
        text += "    write diely dx ydiel\n"
        text += "    write dielz dx zdiel\n"
        text += "    write pot dx %s\n" %potname
        text += "    write kappa dx kappa\n"
        text += "end\n"
        fp.write(text)
        fp.close()
         run APBS 
        if not options.verbose:
            import subprocess
            outputStream = open('/dev/null', 'w+')
            process = subprocess.Popen(['%s %s' %(APBSpath,infile)], stdout=outputStream, stderr=subprocess.STDOUT, shell=True)
            process.wait()
            outputStream.close()
            os.system("rm io.mc")
        else:
            import os
            os.system('%s %s' %(APBSpath,infile))
        data=[]
        value=0.0
        startVio()
        grid = Vgrid_ctor(0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, data)
        Vgrid_readDX(grid, "FILE", "ASC", "", potname+'.dx')
        if deletedir:
             Delete the dir
            import shutil
            shutil.rmtree(thisdir)
            return grid
        else:
            return thisdir
def run_APBS ( self , titgroup = None , charge = None , epsmap = None , focus = None , APBSauto = True , deletedir = True ) : import tempfile thisdir = tempfile . mkdtemp ( dir = '/tmp' ) import os potname = os . path . join ( thisdir , '%s_potential' % ( titgroup ) ) import pKa . pKD_tools titgroup_type = pKa . pKD_tools . get_titgroup_type_from_titgroup ( titgroup ) charge = self . PI . titgroups [ titgroup_type ] [ 'charge' ] import Protool . assign_parameters self . PQR = Protool . assign_parameters . assign_parameters ( self . PI ) self . PQR . clear_all_charges_and_radii ( ) self . PQR . set_all_radii ( ) titpos = self . get_charge_center ( titgroup ) self . PI . add_atom ( uniqueid = 'Z:999:CHA' , atomnumber = 99999 , atomname = 'CHA' , chainid = 'Z' , residuename = 'DUM' , residuenumber = '999' , xcoord = titpos [ 0 ] , ycoord = titpos [ 1 ] , zcoord = titpos [ 2 ] , update = 1 , BFACTOR = None , OCCUPANCY = None , CHARGE = charge , RADIUS = 1.55 , tag = None ) pqrfile = os . path . join ( thisdir , 'currentPQR.pqr' ) self . PI . writepqr ( pqrfile ) self . PI . remove_atom ( 'Z:999:CHA' ) self . coarsecent , extent = self . PI . get_center_of_coords ( ) self . coarsedim = 1.5 * extent if focus is None : self . finedim = extent self . finecent = self . coarsecent else : self . finecent = [ focus [ 0 ] , focus [ 1 ] , focus [ 2 ] ] ngrid = 65 self . finedim = [ ngrid * 0.2 , ngrid * 0.2 , ngrid * 0.2 ] import os os . chdir ( thisdir ) infile = os . path . join ( thisdir , 'apbs.in' ) fp = open ( infile , "w" ) text = "read\n" text += "    mol pqr %s\n" % pqrfile if self . options . epsmap : name = 'usemap' dirname = thisdir names = self . epsmap . set_and_write_epsmap ( dirname , name ) text += "    diel dx %s %s %s\n" % ( names [ 0 ] , names [ 1 ] , names [ 2 ] ) text += "end\n" text += "elec\n" if APBSauto : text += "    mg-auto\n" else : text = text + "    mg-manual" text += "    dime 65 65 65\n" if APBSauto : text += "    cglen %.4f %.4f %.4f\n" % ( self . coarsedim [ 0 ] , self . coarsedim [ 1 ] , self . coarsedim [ 2 ] ) text += "    cgcent %.3f %.3f %.3f\n" % ( self . coarsecent [ 0 ] , self . coarsecent [ 1 ] , self . coarsecent [ 2 ] ) text += "    fglen %.4f %.4f %.4f\n" % ( self . finedim [ 0 ] , self . finedim [ 1 ] , self . finedim [ 2 ] ) text += "    fgcent %.3f %.3f %.3f\n" % ( self . finecent [ 0 ] , self . finecent [ 1 ] , self . finecent [ 2 ] ) else : text += "    glen %.4f %.4f %.4f\n" % ( self . coarsedim [ 0 ] , self . coarsedim [ 1 ] , self . coarsedim [ 2 ] ) text += "    gcent %.3f %.3f %.3f\n" % ( self . coarsecent [ 0 ] , self . coarsecent [ 1 ] , self . coarsecent [ 2 ] ) text += "    mol 1\n" text += "    lpbe\n" text += "    ion charge 1 conc 0.00 radius 2.0\n" text += "    ion charge -1 conc 0.00 radius 2.0\n" if self . options . smoothe : text += "    srfm smol\n" else : text += "    srfm mol\n" text += "    chgm spl0\n" text += "    srad 1.4\n" text += "    swin 0.3\n" text += "    sdens 10.0\n" text += "    temp 298.15\n" text += "    pdie %5.2f\n" % self . eps text += "    sdie %5.2f\n" % self . options . wateps if self . options . epsmap : text += "    usemap diel 1-3\n" text += "    bcfl sdh" text += "    calcenergy no\n" text += "    calcforce no\n" text += "    write dielx dx xdiel\n" text += "    write diely dx ydiel\n" text += "    write dielz dx zdiel\n" text += "    write pot dx %s\n" % potname text += "end\n" fp . write ( text ) fp . close ( ) if not options . verbose : import subprocess outputStream = open ( '/dev/null' , 'w+' ) process = subprocess . Popen ( [ '%s %s' % ( APBSpath , infile ) ] , stdout = outputStream , stderr = subprocess . STDOUT , shell = True ) process . wait ( ) outputStream . close ( ) os . system ( "rm io.mc" ) else : import os os . system ( '%s %s' % ( APBSpath , infile ) ) data = [ ] value = 0.0 startVio ( ) grid = Vgrid_ctor ( 0 , 0 , 0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , data ) Vgrid_readDX ( grid , "FILE" , "ASC" , "" , potname + '.dx' ) if deletedir : import shutil shutil . rmtree ( thisdir ) return grid else : return thisdir
Run APBS in mg-auto mode to get a map focussed on the protein
Run APBS in mg - auto mode to get a map focussed on the protein
"""Run APBS in mg-auto mode to get a map focussed on the protein""" # # Potname # # # Get charge # # # Get the PQR file # # # Get the coarse and fine centers # # # Run APBS # # # # #text += "    kappa dx kappa%d.dx\n"%i #text += '    diel dx ' #for n in ['x','y','z']: #    text=text+" %s " %(os.path.join(self.topdir,'start_values','%sdiel.dx' %n)) #text=text+" \n" # # Start of ELEC section # #text += "    grid %.2f %.2f %.2f\n"%(dim, dim, dim) #text += "    gcent %.3f %.3f %.3f\n"%(self.center[0], self.center[1], self.center[2]) # # smoothe the surface # do not smoothe the dielectric boundary! #text += "    usemap kappa 1\n" #text += "    write kappa dx kappa\n" # run APBS # # # # Delete the dir #
self
titgroup
charge
epsmap
focus
APBSauto
deletedir