MayaChemTools

    1 #!/bin/env python
    2 #
    3 # File: PyMOLVisualizeElectronDensity.py
    4 # Author: Manish Sud <msud@san.rr.com>
    5 #
    6 # Copyright (C) 2019 Manish Sud. All rights reserved.
    7 #
    8 # The functionality available in this script is implemented using PyMOL, a
    9 # molecular visualization system on an open source foundation originally
   10 # developed by Warren DeLano.
   11 #
   12 # This file is part of MayaChemTools.
   13 #
   14 # MayaChemTools is free software; you can redistribute it and/or modify it under
   15 # the terms of the GNU Lesser General Public License as published by the Free
   16 # Software Foundation; either version 3 of the License, or (at your option) any
   17 # later version.
   18 #
   19 # MayaChemTools is distributed in the hope that it will be useful, but without
   20 # any warranty; without even the implied warranty of merchantability of fitness
   21 # for a particular purpose.  See the GNU Lesser General Public License for more
   22 # details.
   23 #
   24 # You should have received a copy of the GNU Lesser General Public License
   25 # along with MayaChemTools; if not, see <http://www.gnu.org/licenses/> or
   26 # write to the Free Software Foundation Inc., 59 Temple Place, Suite 330,
   27 # Boston, MA, 02111-1307, USA.
   28 #
   29 
   30 from __future__ import print_function
   31 
   32 # Add local python path to the global path and import standard library modules...
   33 import os
   34 import sys;  sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), "..", "lib", "Python"))
   35 import time
   36 import re
   37 
   38 # PyMOL imports...
   39 try:
   40     import pymol
   41     # Finish launching PyMOL in  a command line mode for batch processing (-c)
   42     # along with the following options:  disable loading of pymolrc and plugins (-k);
   43     # suppress start up messages (-q)
   44     pymol.finish_launching(['pymol', '-ckq'])
   45 except ImportError as ErrMsg:
   46     sys.stderr.write("\nFailed to import PyMOL module/package: %s\n" % ErrMsg)
   47     sys.stderr.write("Check/update your PyMOL environment and try again.\n\n")
   48     sys.exit(1)
   49 
   50 # MayaChemTools imports...
   51 try:
   52     from docopt import docopt
   53     import MiscUtil
   54     import PyMOLUtil
   55 except ImportError as ErrMsg:
   56     sys.stderr.write("\nFailed to import MayaChemTools module/package: %s\n" % ErrMsg)
   57     sys.stderr.write("Check/update your MayaChemTools environment and try again.\n\n")
   58     sys.exit(1)
   59 
   60 ScriptName = os.path.basename(sys.argv[0])
   61 Options = {}
   62 OptionsInfo = {}
   63 
   64 def main():
   65     """Start execution of the script"""
   66     
   67     MiscUtil.PrintInfo("\n%s (PyMOL v%s; %s) Starting...\n" % (ScriptName, pymol.cmd.get_version()[0], time.asctime()))
   68     
   69     (WallClockTime, ProcessorTime) = MiscUtil.GetWallClockAndProcessorTime()
   70     
   71     # Retrieve command line arguments and options...
   72     RetrieveOptions()
   73     
   74     # Process and validate command line arguments and options...
   75     ProcessOptions()
   76 
   77     # Perform actions required by the script...
   78     GenerateElectronDensityVisualization()
   79     
   80     MiscUtil.PrintInfo("\n%s: Done...\n" % ScriptName)
   81     MiscUtil.PrintInfo("Total time: %s" % MiscUtil.GetFormattedElapsedTime(WallClockTime, ProcessorTime))
   82 
   83 def GenerateElectronDensityVisualization():
   84     """Generate electron density visualization."""
   85 
   86     Outfile = OptionsInfo["PMLOutfile"]
   87     OutFH = open(Outfile, "w")
   88     if OutFH is None:
   89         MiscUtil.PrintError("Failed to open output fie %s " % Outfile)
   90     
   91     MiscUtil.PrintInfo("\nGenerating file %s..." % Outfile)
   92 
   93     # Setup header...
   94     WritePMLHeader(OutFH, ScriptName)
   95     WritePyMOLParameters(OutFH)
   96 
   97     # Load reffile for alignment..
   98     if OptionsInfo["Align"]:
   99         WriteAlignReference(OutFH)
  100 
  101     # Setup view for each input file...
  102     FirstComplex = True
  103     FirstComplexFirstChainName = None
  104     for FileIndex in range(0, len(OptionsInfo["InfilesInfo"]["InfilesNames"])):
  105         # Setup PyMOL object names...
  106         PyMOLObjectNames = SetupPyMOLObjectNames(FileIndex)
  107 
  108         # Setup complex view...
  109         WriteComplexView(OutFH, FileIndex, PyMOLObjectNames, FirstComplex)
  110         
  111         SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
  112         FirstChain = True
  113         for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
  114             if FirstComplex and FirstChain:
  115                 FirstComplexFirstChainName = PyMOLObjectNames["Chains"][ChainID]["ChainAlone"]
  116                 
  117             WriteChainView(OutFH, FileIndex, PyMOLObjectNames, ChainID)
  118             
  119             # Setup ligand views...
  120             FirstLigand = True
  121             for LigandID in SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]:
  122                 WriteChainLigandView(OutFH, FileIndex, PyMOLObjectNames, ChainID, LigandID)
  123                 
  124                 # Set up ligand level group...
  125                 Enable, Action = [False, "close"]
  126                 if FirstLigand:
  127                     FirstLigand = False
  128                     Enable, Action = [True, "open"]
  129                 GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Ligands"][ChainID][LigandID]["ChainLigandGroup"], PyMOLObjectNames["Ligands"][ChainID][LigandID]["ChainLigandGroupMembers"], Enable, Action)
  130             
  131             # Setup Chain level group...
  132             Enable, Action = [False, "close"]
  133             if FirstChain:
  134                 FirstChain = False
  135                 Enable, Action = [True, "open"]
  136             GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"], Enable, Action)
  137     
  138         # Set up complex level group...
  139         Enable, Action = [False, "close"]
  140         if FirstComplex:
  141             FirstComplex = False
  142             Enable, Action = [True, "open"]
  143         GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["PDBGroup"], PyMOLObjectNames["PDBGroupMembers"], Enable, Action)
  144         
  145         # Delete empty PyMOL objects...
  146         DeleteEmptyPyMOLObjects(OutFH, FileIndex, PyMOLObjectNames)
  147         
  148     if OptionsInfo["Align"]:
  149         DeleteAlignReference(OutFH)
  150 
  151     if FirstComplexFirstChainName is not None:
  152         OutFH.write("""\ncmd.orient("%s", animate = -1)\n""" % FirstComplexFirstChainName)
  153     else:
  154         OutFH.write("""\ncmd.orient("visible", animate = -1)\n""")
  155     
  156     OutFH.close()
  157 
  158     # Generate PSE file as needed...
  159     if OptionsInfo["PSEOut"]:
  160         GeneratePyMOLSessionFile()
  161 
  162 def WritePMLHeader(OutFH, ScriptName):
  163     """Write out PML setting up complex view"""
  164 
  165     HeaderInfo = PyMOLUtil.SetupPMLHeaderInfo(ScriptName)
  166     OutFH.write("%s\n" % HeaderInfo)
  167 
  168 def WritePyMOLParameters(OutFH):
  169     """Write out PyMOL global parameters. """
  170 
  171     PMLCmds = []
  172     PMLCmds.append("""cmd.set("mesh_width", %.2f)""" % (OptionsInfo["MeshWidth"]))
  173     PMLCmds.append("""cmd.set("transparency", %.2f, "", 0)""" % (OptionsInfo["SurfaceTransparency"]))
  174     PMLCmds.append("""cmd.set("label_font_id", %s)""" % (OptionsInfo["LabelFontID"]))
  175     PML = "\n".join(PMLCmds)
  176     
  177     OutFH.write("""\n""\n"Setting up PyMOL gobal parameters..."\n""\n""")
  178     OutFH.write("%s\n" % PML)
  179 
  180 def WriteAlignReference(OutFH):
  181     """Setup object for alignment reference """
  182 
  183     RefFileInfo = OptionsInfo["RefFileInfo"]
  184     RefFile = RefFileInfo["RefFileName"]
  185     RefName = RefFileInfo["PyMOLObjectName"]
  186     
  187     PMLCmds = []
  188     PMLCmds.append("""cmd.load("%s", "%s")""" % (RefFile, RefName))
  189     PMLCmds.append("""cmd.hide("everything", "%s")""" % (RefName))
  190     PMLCmds.append("""cmd.disable("%s")""" % (RefName))
  191     PML = "\n".join(PMLCmds)
  192     
  193     OutFH.write("""\n""\n"Loading %s and setting up view for align reference..."\n""\n""" % RefFile)
  194     OutFH.write("%s\n" % PML)
  195     
  196 def WriteAlignComplex(OutFH, FileIndex, PyMOLObjectNames):
  197     """Setup alignment of complex to reference"""
  198 
  199     RefFileInfo = OptionsInfo["RefFileInfo"]
  200     RefName = RefFileInfo["PyMOLObjectName"]
  201     
  202     ComplexName = PyMOLObjectNames["Complex"]
  203     
  204     if re.match("^FirstChain$", OptionsInfo["AlignMode"], re.I):
  205         RefFirstChainID = RefFileInfo["ChainsAndLigandsInfo"]["ChainIDs"][0]
  206         RefAlignSelection = "%s and chain %s" % (RefName, RefFirstChainID)
  207         
  208         ComplexFirstChainID = RetrieveFirstChainID(FileIndex)
  209         ComplexAlignSelection = "%s and chain %s" % (ComplexName, ComplexFirstChainID)
  210     else:
  211         RefAlignSelection = RefName
  212         ComplexAlignSelection = ComplexName
  213 
  214     PML = PyMOLUtil.SetupPMLForAlignment(OptionsInfo["AlignMethod"], RefAlignSelection, ComplexAlignSelection)
  215     OutFH.write("""\n""\n"Aligning %s against reference %s ..."\n""\n""" % (ComplexAlignSelection, RefAlignSelection))
  216     OutFH.write("%s\n" % PML)
  217     
  218 def DeleteAlignReference(OutFH):
  219     """Delete alignment reference object."""
  220     
  221     RefName = OptionsInfo["RefFileInfo"]["PyMOLObjectName"]
  222     OutFH.write("""\n""\n"Deleting alignment reference object %s..."\n""\n""" % RefName)
  223     OutFH.write("""cmd.delete("%s")\n""" % RefName)
  224 
  225 def WriteComplexView(OutFH, FileIndex, PyMOLObjectNames, FirstComplex):
  226     """Write out PML for viewing polymer complex along with electron density."""
  227 
  228     # Setup complex...
  229     Infile = OptionsInfo["InfilesInfo"]["InfilesNames"][FileIndex]
  230     PML = PyMOLUtil.SetupPMLForPolymerComplexView(PyMOLObjectNames["Complex"], Infile, True)
  231     OutFH.write("""\n""\n"Loading %s and setting up view for complex..."\n""\n""" % Infile)
  232     OutFH.write("%s\n" % PML)
  233     
  234     if OptionsInfo["Align"]:
  235         # No need to align complex on to itself...
  236         if not (re.match("^FirstInputFile$", OptionsInfo["AlignRefFile"], re.I) and FirstComplex):
  237             WriteAlignComplex(OutFH, FileIndex, PyMOLObjectNames)
  238 
  239     # Setup electron density maps and meshes...
  240     CompositeEDMapFile = OptionsInfo["CompositeEDMapFiles"][FileIndex]
  241     WriteComplexCompositeElectronDensityMapView(OutFH, PyMOLObjectNames, CompositeEDMapFile)
  242     
  243     if PyMOLObjectNames["SetupDiffEDMapObjects"]:
  244         DifferenceEDMapFile = OptionsInfo["DiffEDMapFiles"][FileIndex]
  245         WriteComplexDifferenceElectronDensityMapView(OutFH, PyMOLObjectNames, DifferenceEDMapFile)
  246 
  247     # Setup complex group...
  248     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["ComplexGroup"], PyMOLObjectNames["ComplexGroupMembers"], False, "close")
  249 
  250 def WriteComplexCompositeElectronDensityMapView(OutFH, PyMOLObjectNames, MapFileName):
  251     """Write out PML for viewing composite maps."""
  252 
  253     # Load composite map (2Fo - Fc) and setup mesh views...
  254     Info = """\
  255 ""
  256 "Loading composite map (2Fo - Fc) %s and setting up mesh view for complex..."
  257 "" """ % MapFileName
  258     OutFH.write("\n%s\n" % Info)
  259 
  260     MapName = PyMOLObjectNames["ComplexCompositeEDMap"]
  261     ComplexName = PyMOLObjectNames["Complex"]
  262     
  263     ContourLevel = OptionsInfo["MeshLevelCompositeMap"]
  264     Color = OptionsInfo["MeshColorCompositeMap"]
  265     
  266     VolumeColorRamp = OptionsInfo["VolumeColorRampCompositeMap"]
  267     
  268     VolumeName = PyMOLObjectNames["ComplexCompositeEDVolume"]
  269     MeshName = PyMOLObjectNames["ComplexCompositeEDMesh"]
  270     SurfaceName = PyMOLObjectNames["ComplexCompositeEDSurface"]
  271     
  272     AlignMapToObjectName = ComplexName if OptionsInfo["Align"] else None
  273     EnableMap = True
  274     PML = SetupPMLForElectronDensityMap(MapFileName, MapName, AlignMapToObjectName, EnableMap)
  275     OutFH.write("%s\n" % PML)
  276 
  277     EnableMesh = OptionsInfo["MeshComplex"]
  278     
  279     EnableVolume = OptionsInfo["VolumeComplex"]
  280     if EnableVolume and EnableMesh:
  281         EnableVolume = False
  282         
  283     EnableSurface = OptionsInfo["SurfaceComplex"]
  284     if EnableSurface and (EnableVolume or EnableMesh):
  285         EnableSurface = False
  286     
  287     if OptionsInfo["VolumeComplex"]:
  288         PML = SetupPMLForElectronDensityVolume(MapName, VolumeName, VolumeColorRamp, Enable = EnableVolume, Selection = ComplexName)
  289         OutFH.write("\n%s\n" % PML)
  290         
  291     if OptionsInfo["MeshComplex"]:
  292         PML = SetupPMLForElectronDensityMesh(MapName, MeshName, ContourLevel, Color, Enable = EnableMesh, Selection = ComplexName)
  293         OutFH.write("\n%s\n" % PML)
  294 
  295     if OptionsInfo["SurfaceComplex"]:
  296         PML = SetupPMLForElectronDensitySurface(MapName, SurfaceName, ContourLevel, Color, Enable = EnableSurface, Selection = ComplexName)
  297         OutFH.write("\n%s\n" % PML)
  298 
  299     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["ComplexCompositeEDGroup"], PyMOLObjectNames["ComplexCompositeEDGroupMembers"], True, "close")
  300     
  301 def WriteComplexDifferenceElectronDensityMapView(OutFH, PyMOLObjectNames, MapFileName):
  302     """Write out PML for viewing difference maps."""
  303 
  304     # Load difference map (Fo - Fc ) and setup mesh views...
  305     Info = """\
  306 ""
  307 "Loading difference map (Fo - Fc ) map %s and setting up mesh views..."
  308 "" """ % MapFileName
  309     OutFH.write("\n%s\n" % Info)
  310 
  311     MapName = PyMOLObjectNames["ComplexDiffEDMap"]
  312     ComplexName = PyMOLObjectNames["Complex"]
  313 
  314     ContourLevel1 = OptionsInfo["Mesh1LevelDiffMap"]
  315     ContourLevel2 = OptionsInfo["Mesh2LevelDiffMap"]
  316     Color1 = OptionsInfo["Mesh1ColorDiffMap"]
  317     Color2 = OptionsInfo["Mesh2ColorDiffMap"]
  318     
  319     VolumeColorRamp = OptionsInfo["VolumeColorRampDiffMap"]
  320     
  321     VolumeName = PyMOLObjectNames["ComplexDiffEDVolume"]
  322     Mesh1Name = PyMOLObjectNames["ComplexDiffEDMesh1"]
  323     Surface1Name = PyMOLObjectNames["ComplexDiffEDSurface1"]
  324     Mesh2Name = PyMOLObjectNames["ComplexDiffEDMesh2"]
  325     Surface2Name = PyMOLObjectNames["ComplexDiffEDSurface2"]
  326     
  327     EnableMesh = OptionsInfo["MeshComplex"]
  328     
  329     EnableVolume = OptionsInfo["VolumeComplex"]
  330     if EnableVolume and EnableMesh:
  331         EnableVolume = False
  332         
  333     EnableSurface = OptionsInfo["SurfaceComplex"]
  334     if EnableSurface and (EnableVolume or EnableMesh):
  335         EnableSurface = False
  336     
  337     AlignMapToObjectName = ComplexName if OptionsInfo["Align"] else None
  338     EnableMap = True
  339     PML = SetupPMLForElectronDensityMap(MapFileName, MapName, AlignMapToObjectName, EnableMap)
  340     OutFH.write("%s\n" % PML)
  341     
  342     if OptionsInfo["VolumeComplex"]:
  343         PML = SetupPMLForElectronDensityVolume(MapName, VolumeName, VolumeColorRamp, Enable = EnableVolume, Selection = ComplexName)
  344         OutFH.write("\n%s\n" % PML)
  345         
  346     if OptionsInfo["MeshComplex"]:
  347         PML = SetupPMLForElectronDensityMesh(MapName, Mesh1Name, ContourLevel1, Color1, Enable = EnableMesh, Selection = ComplexName)
  348         OutFH.write("\n%s\n" % PML)
  349         
  350     if OptionsInfo["SurfaceComplex"]:
  351         PML = SetupPMLForElectronDensitySurface(MapName, Surface1Name, ContourLevel1, Color1, Enable = EnableSurface, Selection = ComplexName)
  352         OutFH.write("\n%s\n" % PML)
  353     
  354     if OptionsInfo["MeshComplex"]:
  355         PML = SetupPMLForElectronDensityMesh(MapName, Mesh2Name, ContourLevel2, Color2, Enable = EnableMesh, Selection = ComplexName)
  356         OutFH.write("\n%s\n" % PML)
  357     
  358     if OptionsInfo["SurfaceComplex"]:
  359         PML = SetupPMLForElectronDensitySurface(MapName, Surface2Name, ContourLevel2, Color2, Enable = EnableSurface, Selection = ComplexName)
  360         OutFH.write("\n%s\n" % PML)
  361     
  362     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["ComplexDiffEDGroup"], PyMOLObjectNames["ComplexDiffEDGroupMembers"], True, "close")
  363 
  364 def WriteChainView(OutFH, FileIndex, PyMOLObjectNames, ChainID):
  365     """Write out PML for viewing chain."""
  366     
  367     OutFH.write("""\n""\n"Setting up views for chain %s..."\n""\n""" % ChainID)
  368     
  369     ChainComplexName = PyMOLObjectNames["Chains"][ChainID]["ChainComplex"]
  370     
  371     # Setup chain complex group view...
  372     WriteChainComplexAndMeshViews(OutFH, FileIndex, PyMOLObjectNames, ChainID)
  373 
  374     # Setup chain view...
  375     WriteChainAloneViews(OutFH, FileIndex, PyMOLObjectNames, ChainID)
  376     
  377     # Setup chain solvent view...
  378     PML = PyMOLUtil.SetupPMLForSolventView(PyMOLObjectNames["Chains"][ChainID]["Solvent"], ChainComplexName, False)
  379     OutFH.write("\n%s\n" % PML)
  380 
  381     # Setup chain inorganic view...
  382     PML = PyMOLUtil.SetupPMLForInorganicView(PyMOLObjectNames["Chains"][ChainID]["Inorganic"], ChainComplexName, False)
  383     OutFH.write("\n%s\n" % PML)
  384 
  385 def WriteChainComplexAndMeshViews(OutFH, FileIndex, PyMOLObjectNames, ChainID):
  386     """Write chain complex and mesh views. """
  387     
  388     # Setup chain complex...
  389     ChainComplexName = PyMOLObjectNames["Chains"][ChainID]["ChainComplex"]
  390     PML = PyMOLUtil.SetupPMLForPolymerChainComplexView(ChainComplexName, PyMOLObjectNames["Complex"], ChainID, True)
  391     OutFH.write("%s\n" % PML)
  392 
  393     SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
  394     
  395     MeshChainComplex = SpecifiedChainsAndLigandsInfo["MeshChainComplex"][ChainID]
  396     VolumeChainComplex = SpecifiedChainsAndLigandsInfo["VolumeChainComplex"][ChainID]
  397     SurfaceChainComplex = SpecifiedChainsAndLigandsInfo["SurfaceChainComplex"][ChainID]
  398     
  399     EnableVolumeChainComplex = SpecifiedChainsAndLigandsInfo["EnableVolumeChainComplex"][ChainID]
  400     EnableMeshChainComplex = SpecifiedChainsAndLigandsInfo["EnableMeshChainComplex"][ChainID]
  401     EnableSurfaceChainComplex = SpecifiedChainsAndLigandsInfo["EnableSurfaceChainComplex"][ChainID]
  402     
  403     if MeshChainComplex or VolumeChainComplex or SurfaceChainComplex:
  404         # Set up composite mesh and group...
  405         MapName = PyMOLObjectNames["ComplexCompositeEDMap"]
  406         ContourLevel = OptionsInfo["MeshLevelCompositeMap"]
  407         Color = OptionsInfo["MeshColorCompositeMap"]
  408         VolumeColorRamp = OptionsInfo["VolumeColorRampCompositeMap"]
  409         
  410         MeshName = PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDMesh"]
  411         VolumeName = PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDVolume"]
  412         SurfaceName = PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDSurface"]
  413         
  414         if VolumeChainComplex:
  415             PML = SetupPMLForElectronDensityVolume(MapName, VolumeName, VolumeColorRamp, Enable = EnableVolumeChainComplex, Selection = ChainComplexName)
  416             OutFH.write("\n%s\n" % PML)
  417         
  418         if MeshChainComplex:
  419             PML = SetupPMLForElectronDensityMesh(MapName, MeshName, ContourLevel, Color, Enable = EnableMeshChainComplex, Selection = ChainComplexName)
  420             OutFH.write("\n%s\n" % PML)
  421         
  422         if SurfaceChainComplex:
  423             PML = SetupPMLForElectronDensitySurface(MapName, SurfaceName, ContourLevel, Color, Enable = EnableSurfaceChainComplex, Selection = ChainComplexName)
  424             OutFH.write("\n%s\n" % PML)
  425         
  426         GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDGroupMembers"], True, "close")
  427         if PyMOLObjectNames["SetupDiffEDMapObjects"]:
  428             # Set up difference meshes and group...
  429             MapName = PyMOLObjectNames["ComplexDiffEDMap"]
  430             
  431             ContourLevel1 = OptionsInfo["Mesh1LevelDiffMap"]
  432             ContourLevel2 = OptionsInfo["Mesh2LevelDiffMap"]
  433             Color1 = OptionsInfo["Mesh1ColorDiffMap"]
  434             Color2 = OptionsInfo["Mesh2ColorDiffMap"]
  435             
  436             VolumeColorRamp = OptionsInfo["VolumeColorRampDiffMap"]
  437             VolumeName = PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDVolume"]
  438             
  439             Mesh1Name = PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDMesh1"]
  440             Surface1Name = PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDSurface1"]
  441             Mesh2Name = PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDMesh2"]
  442             Surface2Name = PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDSurface2"]
  443         
  444             if VolumeChainComplex:
  445                 PML = SetupPMLForElectronDensityVolume(MapName, VolumeName, VolumeColorRamp, Enable = EnableVolumeChainComplex, Selection = ChainComplexName)
  446                 OutFH.write("\n%s\n" % PML)
  447             
  448             if MeshChainComplex:
  449                 PML = SetupPMLForElectronDensityMesh(MapName, Mesh1Name, ContourLevel1, Color1, Enable = EnableMeshChainComplex, Selection = ChainComplexName)
  450                 OutFH.write("\n%s\n" % PML)
  451             
  452             if SurfaceChainComplex:
  453                 PML = SetupPMLForElectronDensitySurface(MapName, Surface1Name, ContourLevel1, Color1, Enable = EnableSurfaceChainComplex, Selection = ChainComplexName)
  454                 OutFH.write("\n%s\n" % PML)
  455             
  456             if MeshChainComplex:
  457                 PML = SetupPMLForElectronDensityMesh(MapName, Mesh2Name, ContourLevel2, Color2, Enable = EnableMeshChainComplex, Selection = ChainComplexName)
  458                 OutFH.write("\n%s\n" % PML)
  459             
  460             if SurfaceChainComplex:
  461                 PML = SetupPMLForElectronDensitySurface(MapName, Surface2Name, ContourLevel2, Color2, Enable = EnableSurfaceChainComplex, Selection = ChainComplexName)
  462                 OutFH.write("\n%s\n" % PML)
  463         
  464             GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDGroupMembers"], True, "close")
  465     
  466     # Setup chain complex group...
  467     EnableChainComplexGroup = SpecifiedChainsAndLigandsInfo["EnableChainComplexGroup"][ChainID]
  468     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroupMembers"], EnableChainComplexGroup, "close")
  469     
  470 def WriteChainAloneViews(OutFH, FileIndex, PyMOLObjectNames, ChainID):
  471     """Write individual chain views. """
  472 
  473     ChainComplexName = PyMOLObjectNames["Chains"][ChainID]["ChainComplex"]
  474     
  475     # Setup chain view...
  476     ChainName = PyMOLObjectNames["Chains"][ChainID]["ChainAlone"]
  477     PML = PyMOLUtil.SetupPMLForPolymerChainView(ChainName, ChainComplexName, Enable = True)
  478     OutFH.write("\n%s\n" % PML)
  479 
  480     # Setup chain putty by B-factor view...
  481     if OptionsInfo["BFactorChainCartoonPutty"]:
  482         BFactorPuttyName = PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorPutty"]
  483         PML = PyMOLUtil.SetupPMLForBFactorPuttyView(BFactorPuttyName, ChainName, ColorPalette = OptionsInfo["BFactorColorPalette"], Enable = False)
  484         OutFH.write("\n%s\n" % PML)
  485         
  486     # Setup chain group...
  487     SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
  488     EnableChainAloneGroup = SpecifiedChainsAndLigandsInfo["EnableChainAloneGroup"][ChainID]
  489     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"], EnableChainAloneGroup, "close")
  490     
  491 def WriteChainLigandView(OutFH, FileIndex, PyMOLObjectNames, ChainID, LigandID):
  492     """Write out PML for viewing ligand in a chain."""
  493     
  494     for GroupID in ["Ligand", "Pocket", "PocketSolvent", "PocketInorganic"]:
  495         ComplexName = PyMOLObjectNames["Chains"][ChainID]["ChainComplex"]
  496         LigandName = PyMOLObjectNames["Ligands"][ChainID][LigandID]["Ligand"]
  497         
  498         # Setup main object...
  499         GroupTypeObjectID = "%s" % (GroupID)
  500         GroupTypeObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupTypeObjectID]
  501         
  502         if re.match("^Ligand$", GroupID, re.I):
  503             OutFH.write("""\n""\n"Setting up views for ligand %s in chain %s..."\n""\n""" % (LigandID, ChainID))
  504             PML = PyMOLUtil.SetupPMLForLigandView(GroupTypeObjectName, ComplexName, LigandID, True)
  505             OutFH.write("%s\n" % PML)
  506         elif re.match("^Pocket$", GroupID, re.I):
  507             OutFH.write("""\n""\n"Setting up views for pocket around ligand %s in chain %s..."\n""\n""" % (LigandID, ChainID))
  508             PML = PyMOLUtil.SetupPMLForLigandPocketView(GroupTypeObjectName, ComplexName, LigandName, OptionsInfo["PocketDistanceCutoff"], True)
  509             OutFH.write("%s\n" % PML)
  510             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (OptionsInfo["PocketLabelColor"], GroupTypeObjectName))
  511         elif re.match("^PocketSolvent$", GroupID, re.I):
  512             OutFH.write("""\n""\n"Setting up views for solvent in pockect around ligand %s in chain %s..."\n""\n""" % (LigandID, ChainID))
  513             PML = PyMOLUtil.SetupPMLForLigandPocketSolventView(GroupTypeObjectName, ComplexName, LigandName, OptionsInfo["PocketDistanceCutoff"], Enable = True)
  514             OutFH.write("%s\n" % PML)
  515         elif re.match("^PocketInorganic$", GroupID, re.I):
  516             OutFH.write("""\n""\n"Setting up views for inorganic in pockect around ligand %s in chain %s..."\n""\n""" % (LigandID, ChainID))
  517             PML = PyMOLUtil.SetupPMLForLigandPocketInorganicView(GroupTypeObjectName, ComplexName, LigandName, OptionsInfo["PocketDistanceCutoff"], Enable = True)
  518             OutFH.write("%s\n" % PML)
  519         
  520         # Set up composite mesh and group...
  521         CompositeMeshGroupID = "%sCompositeEDMeshGroup" % (GroupID)
  522         CompositeMeshGroupMembersID = "%sCompositeEDMeshGroupMembers" % (GroupID)
  523         CompositeMeshID = "%sCompositeEDMesh" % (GroupID)
  524         CompositeVolumeID = "%sCompositeEDVolume" % (GroupID)
  525         CompositeSurfaceID = "%sCompositeEDSurface" % (GroupID)
  526 
  527         CompositeMapName = PyMOLObjectNames["ComplexCompositeEDMap"]
  528         CompositeMeshName = PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeMeshID]
  529         CompositeVolumeName = PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeVolumeID]
  530         CompositeSurfaceName = PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeSurfaceID]
  531         CompositeMeshGroupName = PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeMeshGroupID]
  532         CompositeMeshGroupMembers = PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeMeshGroupMembersID]
  533         
  534         PML = SetupPMLForElectronDensityVolume(CompositeMapName, CompositeVolumeName, OptionsInfo["VolumeColorRampCompositeMap"], Enable = False, Selection = GroupTypeObjectName)
  535         OutFH.write("\n%s\n" % PML)
  536         
  537         PML = SetupPMLForElectronDensityMesh(CompositeMapName, CompositeMeshName, OptionsInfo["MeshLevelCompositeMap"], OptionsInfo["MeshColorCompositeMap"], Enable = True, Selection = GroupTypeObjectName)
  538         OutFH.write("\n%s\n" % PML)
  539         
  540         PML = SetupPMLForElectronDensitySurface(CompositeMapName, CompositeSurfaceName, OptionsInfo["MeshLevelCompositeMap"], OptionsInfo["MeshColorCompositeMap"], Enable = False, Selection = GroupTypeObjectName)
  541         OutFH.write("\n%s\n" % PML)
  542         
  543         GenerateAndWritePMLForGroup(OutFH, CompositeMeshGroupName, CompositeMeshGroupMembers, True, "close")
  544         
  545         if PyMOLObjectNames["SetupDiffEDMapObjects"]:
  546             # Set up difference meshes and group...
  547             DiffMeshGroupID = "%sDiffEDMeshGroup" % (GroupID)
  548             DiffMeshGroupMembersID = "%sDiffEDMeshGroupMembers" % (GroupID)
  549             DiffVolumeID = "%sDiffEDVolume" % (GroupID)
  550             DiffMesh1ID = "%sDiffEDMesh1" % (GroupID)
  551             DiffSurface1ID = "%sDiffEDSurface1" % (GroupID)
  552             DiffMesh2ID = "%sDiffEDMesh2" % (GroupID)
  553             DiffSurface2ID = "%sDiffEDSurface2" % (GroupID)
  554         
  555             DiffMapName = PyMOLObjectNames["ComplexDiffEDMap"]
  556             DiffVolumeName = PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffVolumeID]
  557             DiffMesh1Name = PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffMesh1ID]
  558             DiffSurface1Name = PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffSurface1ID]
  559             DiffMesh2Name = PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffMesh2ID]
  560             DiffSurface2Name = PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffSurface2ID]
  561             DiffMeshGroupName = PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffMeshGroupID]
  562             DiffMeshGroupMembers = PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffMeshGroupMembersID]
  563             
  564             PML = SetupPMLForElectronDensityVolume(DiffMapName, DiffVolumeName, OptionsInfo["VolumeColorRampDiffMap"], Enable = False, Selection = GroupTypeObjectName)
  565             OutFH.write("\n%s\n" % PML)
  566             
  567             PML = SetupPMLForElectronDensityMesh(DiffMapName, DiffMesh1Name, OptionsInfo["Mesh1LevelDiffMap"], OptionsInfo["Mesh1ColorDiffMap"],  Enable = True, Selection = GroupTypeObjectName)
  568             OutFH.write("\n%s\n" % PML)
  569             
  570             PML = SetupPMLForElectronDensitySurface(DiffMapName, DiffSurface1Name, OptionsInfo["Mesh1LevelDiffMap"], OptionsInfo["Mesh1ColorDiffMap"],  Enable = False, Selection = GroupTypeObjectName)
  571             OutFH.write("\n%s\n" % PML)
  572             
  573             PML = SetupPMLForElectronDensityMesh(DiffMapName, DiffMesh2Name, OptionsInfo["Mesh2LevelDiffMap"], OptionsInfo["Mesh2ColorDiffMap"],  Enable = True, Selection = GroupTypeObjectName)
  574             OutFH.write("\n%s\n" % PML)
  575             
  576             PML = SetupPMLForElectronDensitySurface(DiffMapName, DiffSurface2Name, OptionsInfo["Mesh2LevelDiffMap"], OptionsInfo["Mesh2ColorDiffMap"],  Enable = False, Selection = GroupTypeObjectName)
  577             OutFH.write("\n%s\n" % PML)
  578         
  579             GenerateAndWritePMLForGroup(OutFH, DiffMeshGroupName, DiffMeshGroupMembers, True, "close")
  580         
  581         # Set up polar contacts...
  582         if re.match("^(Pocket|PocketSolvent|PocketInorganic)$", GroupID, re.I):
  583             PolarContactsID = "%sPolarContacts" % (GroupID)
  584             PolarContactsName = PyMOLObjectNames["Ligands"][ChainID][LigandID][PolarContactsID]
  585             
  586             PolarContactsColor = OptionsInfo["PocketContactsLigandColor"]
  587             if re.match("^PocketSolvent$", GroupID, re.I):
  588                 PolarContactsColor = OptionsInfo["PocketContactsSolventColor"]
  589             elif re.match("^PocketInorganic$", GroupID, re.I):
  590                 PolarContactsColor = OptionsInfo["PocketContactsInorganicColor"]
  591             
  592             PML = PyMOLUtil.SetupPMLForPolarContactsView(PolarContactsName, LigandName, GroupTypeObjectName, Enable = False, Color = PolarContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  593             OutFH.write("\n%s\n" % PML)
  594             
  595             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (PolarContactsColor, PolarContactsName))
  596             
  597         # Set up hydrophobic contacts...
  598         if re.match("^Pocket$", GroupID, re.I):
  599             HydrophobicContactsID = "%sHydrophobicContacts" % (GroupID)
  600             HydrophobicContactsName = PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicContactsID]
  601             HydrophobicContactsColor = OptionsInfo["PocketContactsLigandHydrophobicColor"]
  602             
  603             PML = PyMOLUtil.SetupPMLForHydrophobicContactsView(HydrophobicContactsName, LigandName, GroupTypeObjectName, Enable = False, Color = HydrophobicContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  604             OutFH.write("\n%s\n" % PML)
  605             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (HydrophobicContactsColor, HydrophobicContactsName))
  606         
  607         # Set up hydrophobic surface...
  608         if re.match("^Pocket$", GroupID, re.I) and OptionsInfo["PocketSurface"]:
  609             HydrophobicSurfaceID = "%sHydrophobicSurface" % (GroupID)
  610             HydrophobicSurfaceName = PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicSurfaceID]
  611             PML = PyMOLUtil.SetupPMLForHydrophobicSurfaceView(HydrophobicSurfaceName, GroupTypeObjectName, ColorPalette = "RedToWhite", Enable = False)
  612             OutFH.write("\n%s\n" % PML)
  613             
  614             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (OptionsInfo["PocketLabelColor"], HydrophobicSurfaceName))
  615         
  616         # Setup group....
  617         GroupNameID = "%sGroup" % (GroupID)
  618         GroupMembersID = "%sGroupMembers" % (GroupID)
  619         GroupName = PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupNameID]
  620         GroupMembers = PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID]
  621 
  622         Action = "close"
  623         Enable = False
  624         if  re.match("^(Ligand|Pocket)$", GroupID, re.I):
  625             Action = "open"
  626             Enable = True
  627         GenerateAndWritePMLForGroup(OutFH, GroupName, GroupMembers, Enable, Action)
  628 
  629 def GenerateAndWritePMLForGroup(OutFH, GroupName, GroupMembers, Enable = False, Action = "close"):
  630     """Generate and write PML for group. """
  631     
  632     PML = PyMOLUtil.SetupPMLForGroup(GroupName, GroupMembers, Enable, Action)
  633     OutFH.write("""\n""\n"Setting up group %s..."\n""\n""" % GroupName)
  634     OutFH.write("%s\n" % PML)
  635 
  636 def SetupPMLForElectronDensityMap(MapFileName, MapName, AlignMapToObjectName = None, Enable = True):
  637     """Setup PML for loading and viewing electron density map. """
  638 
  639     PMLCmds = []
  640     PMLCmds.append("""cmd.load("%s", "%s")""" % (MapFileName, MapName))
  641     if AlignMapToObjectName is not None:
  642         PMLCmds.append("""cmd.matrix_copy("%s", "%s")""" % (AlignMapToObjectName, MapName))
  643         
  644     PMLCmds.append(PyMOLUtil.SetupPMLForEnableDisable(MapName, Enable))
  645     
  646     PML = "\n".join(PMLCmds)
  647     
  648     return PML
  649     
  650 def SetupPMLForElectronDensityMesh(MapName, MeshName, SigmaLevel, Color, Enable = True, Selection = None):
  651     """Setup PML for electron density mesh. """
  652 
  653     Carve = OptionsInfo["MeshCarveRadius"]
  654     
  655     PMLCmds = []
  656     if Selection is None:
  657         PMLCmds.append("""cmd.isomesh("%s", "%s", %.1f)""" % (MeshName, MapName, SigmaLevel))
  658     else:
  659         PMLCmds.append("""cmd.isomesh("%s", "%s", %.1f, "(%s)", carve = %.1f)""" % (MeshName, MapName, SigmaLevel, Selection, Carve))
  660     PMLCmds.append("""util.color_deep("%s", "%s")""" % (Color, MeshName))
  661     PMLCmds.append(PyMOLUtil.SetupPMLForEnableDisable(MeshName, Enable))
  662     
  663     PML = "\n".join(PMLCmds)
  664     
  665     return PML
  666 
  667 def SetupPMLForElectronDensityVolume(MapName, VolumeName, VolumeColorRamp, Enable = True, Selection = None):
  668     """Setup PML for electron density volume. """
  669 
  670     Carve = OptionsInfo["VolumeCarveRadius"]
  671     
  672     PMLCmds = []
  673     if Selection is None:
  674         PMLCmds.append("""cmd.volume("%s", "%s", "%s")""" % (VolumeName, MapName, VolumeColorRamp))
  675     else:
  676         PMLCmds.append("""cmd.volume("%s", "%s", "%s", "(%s)", carve = %.1f)""" % (VolumeName, MapName, VolumeColorRamp, Selection, Carve))
  677     PMLCmds.append(PyMOLUtil.SetupPMLForEnableDisable(VolumeName, Enable))
  678     
  679     PML = "\n".join(PMLCmds)
  680     
  681     return PML
  682 
  683 def SetupPMLForElectronDensitySurface(MapName, SurfaceName, SigmaLevel, Color, Enable = True, Selection = None):
  684     """Setup PML for electron density surface. """
  685 
  686     Carve = OptionsInfo["MeshCarveRadius"]
  687     
  688     PMLCmds = []
  689     if Selection is None:
  690         PMLCmds.append("""cmd.isosurface("%s", "%s", %.1f)""" % (SurfaceName, MapName, SigmaLevel))
  691     else:
  692         PMLCmds.append("""cmd.isosurface("%s", "%s", %.1f, "(%s)", carve = %.1f)""" % (SurfaceName, MapName, SigmaLevel, Selection, Carve))
  693     PMLCmds.append("""util.color_deep("%s", "%s")""" % (Color, SurfaceName))
  694     PMLCmds.append(PyMOLUtil.SetupPMLForEnableDisable(SurfaceName, Enable))
  695     
  696     PML = "\n".join(PMLCmds)
  697     
  698     return PML
  699 
  700 def GeneratePyMOLSessionFile():
  701     """Generate PME file from PML file. """
  702 
  703     PSEOutfile = OptionsInfo["PSEOutfile"]
  704     PMLOutfile = OptionsInfo["PMLOutfile"]
  705     
  706     MiscUtil.PrintInfo("\nGenerating file %s..." % PSEOutfile)
  707     
  708     PyMOLUtil.ConvertPMLFileToPSEFile(PMLOutfile, PSEOutfile)
  709     
  710     if not os.path.exists(PSEOutfile):
  711         MiscUtil.PrintWarning("Failed to generate PSE file, %s..." % (PSEOutfile))
  712     
  713     if not OptionsInfo["PMLOut"]:
  714         MiscUtil.PrintInfo("Deleting file %s..." % PMLOutfile)
  715         os.remove(PMLOutfile)
  716 
  717 def DeleteEmptyPyMOLObjects(OutFH, FileIndex, PyMOLObjectNames):
  718     """Delete empty PyMOL objects. """
  719     
  720     if OptionsInfo["AllowEmptyObjects"]:
  721         return
  722     
  723     SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
  724     for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
  725         OutFH.write("""\n""\n"Checking and deleting empty objects for chain %s..."\n""\n""" % (ChainID))
  726         
  727         # Delete any chain level objects...
  728         WritePMLToCheckAndDeleteEmptyObjects(OutFH, PyMOLObjectNames["Chains"][ChainID]["Solvent"])
  729         WritePMLToCheckAndDeleteEmptyObjects(OutFH, PyMOLObjectNames["Chains"][ChainID]["Inorganic"])
  730         
  731         for LigandID in SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]:
  732             # Delete ligand level objects...
  733             for GroupID in ["Pocket", "PocketSolvent", "PocketInorganic"]:
  734                 GroupNameID = "%sGroup" % (GroupID)
  735                 GroupName = PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupNameID]
  736 
  737                 GroupTypeObjectID = "%s" % (GroupID)
  738                 GroupTypeObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupTypeObjectID]
  739                 
  740                 WritePMLToCheckAndDeleteEmptyObjects(OutFH, GroupTypeObjectName, GroupName)
  741 
  742 def WritePMLToCheckAndDeleteEmptyObjects(OutFH, ObjectName, ParentObjectName = None):
  743     """Write PML to check and delete empty PyMOL objects. """
  744     
  745     if ParentObjectName is None:
  746         PML = """CheckAndDeleteEmptyObjects("%s")""" % (ObjectName)
  747     else:
  748         PML = """CheckAndDeleteEmptyObjects("%s", "%s")""" % (ObjectName, ParentObjectName)
  749     
  750     OutFH.write("%s\n" % PML)
  751 
  752 def SetupPyMOLObjectNames(FileIndex):
  753     """Setup hierarchy of PyMOL groups and objects for ligand centric views of
  754     electron density for chains and ligands present in input file.
  755     """
  756 
  757     PyMOLObjectNames = {}
  758     PyMOLObjectNames["Chains"] = {}
  759     PyMOLObjectNames["Ligands"] = {}
  760 
  761     PyMOLObjectNames["SetupDiffEDMapObjects"] = False if OptionsInfo["DiffEDMapFiles"][FileIndex] is None else True
  762 
  763     # Setup groups and objects for complex...
  764     SetupPyMOLObjectNamesForComplex(FileIndex, PyMOLObjectNames)
  765     
  766     # Setup groups and objects for chain...
  767     SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
  768     for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
  769         SetupPyMOLObjectNamesForChain(FileIndex, PyMOLObjectNames, ChainID)
  770         
  771         # Setup groups and objects for ligand...
  772         for LigandID in SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]:
  773             SetupPyMOLObjectNamesForLigand(FileIndex, PyMOLObjectNames, ChainID, LigandID)
  774 
  775     return PyMOLObjectNames
  776 
  777 def SetupPyMOLObjectNamesForComplex(FileIndex, PyMOLObjectNames):
  778     """Stetup groups and objects for complex. """
  779     
  780     PDBFileRoot = OptionsInfo["InfilesInfo"]["InfilesRoots"][FileIndex]
  781     
  782     PDBGroupName = "%s" % PDBFileRoot
  783     PyMOLObjectNames["PDBGroup"] = PDBGroupName
  784     PyMOLObjectNames["PDBGroupMembers"] = []
  785 
  786     ComplexGroupName = "%s.Complex" % PyMOLObjectNames["PDBGroup"]
  787     PyMOLObjectNames["ComplexGroup"] = ComplexGroupName
  788     PyMOLObjectNames["PDBGroupMembers"].append(ComplexGroupName)
  789     
  790     PyMOLObjectNames["Complex"] = "%s.Complex" % ComplexGroupName
  791 
  792     CompositeMeshGroupName = "%s.2Fo-Fc" % (ComplexGroupName)
  793     CompositeMapName = "%s.Map" % (CompositeMeshGroupName)
  794     CompositeMeshName = "%s.Mesh" % (CompositeMeshGroupName)
  795     CompositeVolumeName = "%s.Volume" % (CompositeMeshGroupName)
  796     CompositeSurfaceName = "%s.Surface" % (CompositeMeshGroupName)
  797     
  798     PyMOLObjectNames["ComplexCompositeEDGroup"] = CompositeMeshGroupName
  799     PyMOLObjectNames["ComplexCompositeEDMap"] = CompositeMapName
  800     PyMOLObjectNames["ComplexCompositeEDMesh"] = CompositeMeshName
  801     PyMOLObjectNames["ComplexCompositeEDVolume"] = CompositeVolumeName
  802     PyMOLObjectNames["ComplexCompositeEDSurface"] = CompositeSurfaceName
  803 
  804     PyMOLObjectNames["ComplexCompositeEDGroupMembers"] = []
  805     PyMOLObjectNames["ComplexCompositeEDGroupMembers"].append(CompositeMapName)
  806     if OptionsInfo["VolumeComplex"]:
  807         PyMOLObjectNames["ComplexCompositeEDGroupMembers"].append(CompositeVolumeName)
  808     if OptionsInfo["MeshComplex"]:
  809         PyMOLObjectNames["ComplexCompositeEDGroupMembers"].append(CompositeMeshName)
  810     if OptionsInfo["SurfaceComplex"]:
  811         PyMOLObjectNames["ComplexCompositeEDGroupMembers"].append(CompositeSurfaceName)
  812     if PyMOLObjectNames["SetupDiffEDMapObjects"]:
  813         DiffMeshGroupName = "%s.Fo-Fc" % ComplexGroupName
  814         DiffMapName = "%s.Map" % DiffMeshGroupName
  815         DiffVolumeName = "%s.Volume" % DiffMeshGroupName
  816         DiffMesh1Name = "%s.Mesh1" % DiffMeshGroupName
  817         DiffSurface1Name = "%s.Surface1" % DiffMeshGroupName
  818         DiffMesh2Name = "%s.Mesh2" % DiffMeshGroupName
  819         DiffSurface2Name = "%s.Surface2" % DiffMeshGroupName
  820         
  821         PyMOLObjectNames["ComplexDiffEDGroup"] = DiffMeshGroupName
  822         PyMOLObjectNames["ComplexDiffEDMap"] = DiffMapName
  823         PyMOLObjectNames["ComplexDiffEDVolume"] = DiffVolumeName
  824         PyMOLObjectNames["ComplexDiffEDMesh1"] = DiffMesh1Name
  825         PyMOLObjectNames["ComplexDiffEDSurface1"] = DiffSurface1Name
  826         PyMOLObjectNames["ComplexDiffEDMesh2"] = DiffMesh2Name
  827         PyMOLObjectNames["ComplexDiffEDSurface2"] = DiffSurface2Name
  828         
  829         PyMOLObjectNames["ComplexDiffEDGroupMembers"] = []
  830         PyMOLObjectNames["ComplexDiffEDGroupMembers"].append(DiffMapName)
  831         if OptionsInfo["VolumeComplex"]:
  832             PyMOLObjectNames["ComplexDiffEDGroupMembers"].append(DiffVolumeName)
  833         if OptionsInfo["MeshComplex"]:
  834             PyMOLObjectNames["ComplexDiffEDGroupMembers"].append(DiffMesh1Name)
  835         if OptionsInfo["SurfaceComplex"]:
  836             PyMOLObjectNames["ComplexDiffEDGroupMembers"].append(DiffSurface1Name)
  837         if OptionsInfo["MeshComplex"]:
  838             PyMOLObjectNames["ComplexDiffEDGroupMembers"].append(DiffMesh2Name)
  839         if OptionsInfo["SurfaceComplex"]:
  840             PyMOLObjectNames["ComplexDiffEDGroupMembers"].append(DiffSurface2Name)
  841     
  842     PyMOLObjectNames["ComplexGroupMembers"] = []
  843     PyMOLObjectNames["ComplexGroupMembers"].append(PyMOLObjectNames["Complex"])
  844     PyMOLObjectNames["ComplexGroupMembers"].append(PyMOLObjectNames["ComplexCompositeEDGroup"])
  845     if PyMOLObjectNames["SetupDiffEDMapObjects"]:
  846         PyMOLObjectNames["ComplexGroupMembers"].append(PyMOLObjectNames["ComplexDiffEDGroup"])
  847     
  848 def SetupPyMOLObjectNamesForChain(FileIndex, PyMOLObjectNames, ChainID):
  849     """Setup groups and objects for chain."""
  850     
  851     PDBGroupName = PyMOLObjectNames["PDBGroup"]
  852     
  853     SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
  854     MeshChainComplex = SpecifiedChainsAndLigandsInfo["MeshChainComplex"][ChainID]
  855     VolumeChainComplex = SpecifiedChainsAndLigandsInfo["VolumeChainComplex"][ChainID]
  856     SurfaceChainComplex = SpecifiedChainsAndLigandsInfo["SurfaceChainComplex"][ChainID]
  857     
  858     PyMOLObjectNames["Chains"][ChainID] = {}
  859     PyMOLObjectNames["Ligands"][ChainID] = {}
  860     
  861     # Set up chain group and chain objects...
  862     ChainGroupName = "%s.Chain%s" % (PDBGroupName, ChainID)
  863     PyMOLObjectNames["Chains"][ChainID]["ChainGroup"] = ChainGroupName
  864     PyMOLObjectNames["PDBGroupMembers"].append(ChainGroupName)
  865     PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"] = []
  866     
  867     # Setup chain complex group and objects...
  868     ChainComplexGroupName = "%s.Complex" % (ChainGroupName)
  869     PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroup"] = ChainComplexGroupName
  870     PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"].append(ChainComplexGroupName)
  871     
  872     PyMOLObjectNames["Chains"][ChainID]["ChainComplex"] = "%s.Complex" % (ChainComplexGroupName)
  873     
  874     CompositeMeshGroupName = "%s.2Fo-Fc" % (ChainComplexGroupName)
  875     CompositeMeshName = "%s.Mesh" % (CompositeMeshGroupName)
  876     CompositeVolumeName = "%s.Volume" % (CompositeMeshGroupName)
  877     CompositeSurfaceName = "%s.Surface" % (CompositeMeshGroupName)
  878     
  879     PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDGroup"] = CompositeMeshGroupName
  880     PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDMesh"] = CompositeMeshName
  881     PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDVolume"] = CompositeVolumeName
  882     PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDSurface"] = CompositeSurfaceName
  883     
  884     PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDGroupMembers"] = []
  885     if VolumeChainComplex:
  886         PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDGroupMembers"].append(CompositeVolumeName)
  887     if MeshChainComplex:
  888         PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDGroupMembers"].append(CompositeMeshName)
  889     if SurfaceChainComplex:
  890         PyMOLObjectNames["Chains"][ChainID]["ChainComplexCompositeEDGroupMembers"].append(CompositeSurfaceName)
  891     
  892     if PyMOLObjectNames["SetupDiffEDMapObjects"]:
  893         DiffMeshGroupName = "%s.Fo-Fc" % (ChainComplexGroupName)
  894         DiffVolumeName = "%s.Volume" % (DiffMeshGroupName)
  895         DiffMesh1Name = "%s.Mesh1" % (DiffMeshGroupName)
  896         DiffSurface1Name = "%s.Surface1" % (DiffMeshGroupName)
  897         DiffMesh2Name = "%s.Mesh2" % (DiffMeshGroupName)
  898         DiffSurface2Name = "%s.Surface2" % (DiffMeshGroupName)
  899         
  900         PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDGroup"] = DiffMeshGroupName
  901         PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDVolume"] = DiffVolumeName
  902         PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDMesh1"] = DiffMesh1Name
  903         PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDSurface1"] = DiffSurface1Name
  904         PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDMesh2"] = DiffMesh2Name
  905         PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDSurface2"] = DiffSurface2Name
  906         
  907         PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDGroupMembers"] = []
  908         if VolumeChainComplex:
  909             PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDGroupMembers"].append(DiffVolumeName)
  910         if MeshChainComplex:
  911             PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDGroupMembers"].append(DiffMesh1Name)
  912         if SurfaceChainComplex:
  913             PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDGroupMembers"].append(DiffSurface1Name)
  914         if MeshChainComplex:
  915             PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDGroupMembers"].append(DiffMesh2Name)
  916         if SurfaceChainComplex:
  917             PyMOLObjectNames["Chains"][ChainID]["ChainComplexDiffEDGroupMembers"].append(DiffSurface2Name)
  918         
  919     NameIDs = ["ChainComplex"]
  920     if MeshChainComplex or VolumeChainComplex or SurfaceChainComplex :
  921         NameIDs.append("ChainComplexCompositeEDGroup")
  922         if PyMOLObjectNames["SetupDiffEDMapObjects"]:
  923             NameIDs.append("ChainComplexDiffEDGroup")
  924         
  925     PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroupMembers"] = []
  926     for NameID in NameIDs:
  927         Name = PyMOLObjectNames["Chains"][ChainID][NameID]
  928         PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroupMembers"].append(Name)
  929 
  930     # Setup up a group for individual chains...
  931     ChainAloneGroupName = "%s.Chain" % (ChainGroupName)
  932     PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroup"] = ChainAloneGroupName
  933     PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"].append(ChainAloneGroupName)
  934         
  935     PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"] = []
  936         
  937     Name = "%s.Chain" % (ChainAloneGroupName)
  938     PyMOLObjectNames["Chains"][ChainID]["ChainAlone"] = Name
  939     PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"].append(Name)
  940         
  941     if OptionsInfo["BFactorChainCartoonPutty"]:
  942         Name = "%s.BFactor" % (ChainAloneGroupName)
  943         PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorPutty"] = Name
  944         PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"].append(Name)
  945     
  946     # Setup solvent and inorganic objects for chain...
  947     for NameID in ["Solvent", "Inorganic"]:
  948         Name = "%s.%s" % (ChainGroupName, NameID)
  949         PyMOLObjectNames["Chains"][ChainID][NameID] = Name
  950         PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"].append(Name)
  951 
  952 def SetupPyMOLObjectNamesForLigand(FileIndex, PyMOLObjectNames, ChainID, LigandID):
  953     """Stetup groups and objects for ligand."""
  954 
  955     PyMOLObjectNames["Ligands"][ChainID][LigandID] = {}
  956     
  957     ChainGroupName = PyMOLObjectNames["Chains"][ChainID]["ChainGroup"]
  958     
  959     # Setup a chain level ligand group...
  960     ChainLigandGroupName = "%s.Ligand%s" % (ChainGroupName, LigandID)
  961     PyMOLObjectNames["Ligands"][ChainID][LigandID]["ChainLigandGroup"] = ChainLigandGroupName
  962     PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"].append(ChainLigandGroupName)
  963     
  964     PyMOLObjectNames["Ligands"][ChainID][LigandID]["ChainLigandGroupMembers"] = []
  965 
  966     # Set up groups and objects for a specific ligand group...
  967     for GroupType in ["Ligand", "Pocket", "Pocket_Solvent", "Pocket_Inorganic"]:
  968         GroupID = re.sub("_", "", GroupType)
  969         GroupName = "%s.%s" % (ChainLigandGroupName, GroupType)
  970                 
  971         GroupNameID = "%sGroup" % (GroupID)
  972         GroupMembersID = "%sGroupMembers" % (GroupID)
  973         
  974         PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupNameID] = GroupName
  975         PyMOLObjectNames["Ligands"][ChainID][LigandID]["ChainLigandGroupMembers"].append(GroupName)
  976         
  977         GroupTypeObjectName = "%s.%s" % (GroupName, GroupType)
  978         GroupTypeObjectID = "%s" % (GroupID)
  979         PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupTypeObjectID] = GroupTypeObjectName
  980         
  981         CompositeMeshGroupName = "%s.2Fo-Fc" % (GroupName)
  982         CompositeMeshName = "%s.Mesh" % (CompositeMeshGroupName)
  983         CompositeVolumeName = "%s.Volume" % (CompositeMeshGroupName)
  984         CompositeSurfaceName = "%s.Surface" % (CompositeMeshGroupName)
  985                 
  986         CompositeMeshGroupID = "%sCompositeEDMeshGroup" % (GroupID)
  987         CompositeMeshGroupMembersID = "%sCompositeEDMeshGroupMembers" % (GroupID)
  988         CompositeMeshID = "%sCompositeEDMesh" % (GroupID)
  989         CompositeVolumeID = "%sCompositeEDVolume" % (GroupID)
  990         CompositeSurfaceID = "%sCompositeEDSurface" % (GroupID)
  991         
  992         PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeMeshGroupID] = CompositeMeshGroupName
  993         PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeMeshID] = CompositeMeshName
  994         PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeVolumeID] = CompositeVolumeName
  995         PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeSurfaceID] = CompositeSurfaceName
  996         PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeMeshGroupMembersID] = []
  997         PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeMeshGroupMembersID].append(CompositeVolumeName)
  998         PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeMeshGroupMembersID].append(CompositeMeshName)
  999         PyMOLObjectNames["Ligands"][ChainID][LigandID][CompositeMeshGroupMembersID].append(CompositeSurfaceName)
 1000                 
 1001         if PyMOLObjectNames["SetupDiffEDMapObjects"]:
 1002             DiffMeshGroupName = "%s.Fo-Fc" % GroupName
 1003             DiffVolumeName = "%s.Volume" % DiffMeshGroupName
 1004             DiffMesh1Name = "%s.Mesh1" % DiffMeshGroupName
 1005             DiffSurface1Name = "%s.Surface1" % DiffMeshGroupName
 1006             DiffMesh2Name = "%s.Mesh2" % DiffMeshGroupName
 1007             DiffSurface2Name = "%s.Surface2" % DiffMeshGroupName
 1008                     
 1009             DiffMeshGroupID = "%sDiffEDMeshGroup" % (GroupID)
 1010             DiffMeshGroupMembersID = "%sDiffEDMeshGroupMembers" % (GroupID)
 1011             DiffVolumeID = "%sDiffEDVolume" % (GroupID)
 1012             DiffMesh1ID = "%sDiffEDMesh1" % (GroupID)
 1013             DiffSurface1ID = "%sDiffEDSurface1" % (GroupID)
 1014             DiffMesh2ID = "%sDiffEDMesh2" % (GroupID)
 1015             DiffSurface2ID = "%sDiffEDSurface2" % (GroupID)
 1016                     
 1017             PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffMeshGroupID] = DiffMeshGroupName
 1018             PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffVolumeID] = DiffVolumeName
 1019             PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffMesh1ID] = DiffMesh1Name
 1020             PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffSurface1ID] = DiffSurface1Name
 1021             PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffMesh2ID] = DiffMesh2Name
 1022             PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffSurface2ID] = DiffSurface2Name
 1023             PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffMeshGroupMembersID] = []
 1024             PyMOLObjectNames["Ligands"][ChainID][LigandID][DiffMeshGroupMembersID].extend([DiffVolumeName, DiffMesh1Name, DiffSurface1Name, DiffMesh2Name,  DiffSurface2Name])
 1025                 
 1026         PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID] = []
 1027         NameIDs = [GroupTypeObjectID, CompositeMeshGroupID]
 1028         if PyMOLObjectNames["SetupDiffEDMapObjects"]:
 1029             NameIDs.append(DiffMeshGroupID)
 1030         
 1031         for NameID in NameIDs:
 1032             Name = PyMOLObjectNames["Ligands"][ChainID][LigandID][NameID]
 1033             PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(Name)
 1034         
 1035         if re.match("^Ligand$", GroupType, re.I):
 1036             # No other object needed for Ligand group...
 1037             continue
 1038         
 1039         PolarContactsName = "%s.Polar_Contacts" % (GroupName)
 1040         PolarContactsID = "%sPolarContacts" % (GroupID)
 1041         PyMOLObjectNames["Ligands"][ChainID][LigandID][PolarContactsID] = PolarContactsName
 1042         PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(PolarContactsName)
 1043                 
 1044         if not re.match("^Pocket$", GroupType, re.I):
 1045             # No other object needed for any other group besides Pocket...
 1046             continue
 1047         
 1048         if not OptionsInfo["PocketSurface"]:
 1049             continue
 1050         
 1051         HydrophobicContactsName = "%s.Hydrophobic_Contacts" % (GroupName)
 1052         HydrophobicContactsID = "%sHydrophobicContacts" % (GroupID)
 1053         PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicContactsID] = HydrophobicContactsName
 1054         PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(HydrophobicContactsName)
 1055         
 1056         HydrophobicSurfaceName = "%s.Surface" % (GroupName)
 1057         HydrophobicSurfaceID = "%sHydrophobicSurface" % (GroupID)
 1058         PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicSurfaceID] = HydrophobicSurfaceName
 1059         PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(HydrophobicSurfaceName)
 1060 
 1061 def ProcessEDMapFilesAndSuffixes():
 1062     """Process specified ED map files or suffixes for input files."""
 1063     
 1064     EDMapFiles = OptionsInfo["EDMapFiles"]
 1065     EDMapSuffixes = OptionsInfo["EDMapSuffixes"]
 1066 
 1067     if (not re.match("^auto$", EDMapFiles, re.I)) and (not re.match("^auto$", EDMapSuffixes, re.I)):
 1068             MiscUtil.PrintError("The values, \"%s\" and \"%s\", specified using \"--EDMapFiles\" and \"--EDMapSuffixes\" are not valid. Both of these options can't be specified simultaneously." % (EDMapFiles, EDMapSuffixes))
 1069 
 1070     if not re.match("^auto$", EDMapFiles, re.I):
 1071         ProcessEDMapFiles()
 1072     else:
 1073         ProcessEDMapSuffixes()
 1074         
 1075 def ProcessEDMapFiles():
 1076     """Process specified ED map files"""
 1077 
 1078     EDMapFiles = re.sub(" ", "", OptionsInfo["EDMapFiles"])
 1079     if not EDMapFiles:
 1080         MiscUtil.PrintError("No valid parameter name and value pairs specified using \"--EDMapFiles\" option.")
 1081     
 1082     EDMapFilesWords = EDMapFiles.split(",")
 1083     EDMapFilesWordsCount = len(EDMapFilesWords)
 1084     if EDMapFilesWordsCount % 2:
 1085         MiscUtil.PrintError("The number of comma delimited ED map files, %d, specified using \"--EDMapFiles\" option must be an even number." % (EDMapFilesWordsCount))
 1086 
 1087     InfilesNamesCount = len(OptionsInfo["InfilesNames"])
 1088     if EDMapFilesWordsCount != 2*InfilesNamesCount:
 1089         MiscUtil.PrintError("The number of comma delimited ED map files, %d, specified using \"--EDMapFiles\" must be twice the number of input files, %s, specified using \"-i, --infiles\" option." % (EDMapFilesWordsCount, InfilesNamesCount))
 1090     
 1091     OptionsInfo["CompositeEDMapFiles"] = []
 1092     OptionsInfo["DiffEDMapFiles"] = []
 1093 
 1094     CompositeEDMapFiles = []
 1095     DiffEDMapFiles = []
 1096     for Index in range(0, EDMapFilesWordsCount, 2):
 1097         CompositeEDMapFiles.append(EDMapFilesWords[Index])
 1098         DiffEDMapFiles.append(EDMapFilesWords[Index + 1])
 1099         
 1100     for Index in range(0, InfilesNamesCount):
 1101         Infile = OptionsInfo["InfilesNames"][Index]
 1102         CompositeEDMapFile = CompositeEDMapFiles[Index]
 1103         DiffEDMapFile = DiffEDMapFiles[Index]
 1104 
 1105         if not os.path.exists(CompositeEDMapFile):
 1106             MiscUtil.PrintError("The composite ED map file, %s, specified using option \"--EDMapFiles\", corresponding to input file, %s,  doesn't exist.\n" % (CompositeEDMapFile, Infile))
 1107 
 1108         DiffEDMapFileExists = False
 1109         if not re.match("^None$", DiffEDMapFile, re.I):
 1110             if os.path.exists(DiffEDMapFile):
 1111                 DiffEDMapFileExists = True
 1112             else:
 1113                 MiscUtil.PrintWarning("The difference ED map file, %s, specified using option \"--EDMapFiles\", corresponding to input file, %s,  doesn't exist. PyMOL groups and objectes related to difference maps won't be created.\n" % (DiffEDMapFile, Infile))
 1114         
 1115         OptionsInfo["CompositeEDMapFiles"].append(CompositeEDMapFile)
 1116         if DiffEDMapFileExists:
 1117             OptionsInfo["DiffEDMapFiles"].append(DiffEDMapFile)
 1118         else:
 1119             OptionsInfo["DiffEDMapFiles"].append(None)
 1120             
 1121 def ProcessEDMapSuffixes():
 1122     """Process suffixes for ED map files"""
 1123     
 1124     OptionsInfo["EDMapSuffixesMap"] = {"CompositeMap" : "", "DifferenceMap" : "_diff"}
 1125     
 1126     if re.match("^auto$", OptionsInfo["EDMapSuffixes"], re.I):
 1127         SetupEDMapFileNamesUsingSuffixes()
 1128         return
 1129     
 1130     EDMapSuffixes = re.sub(" ", "", OptionsInfo["EDMapSuffixes"])
 1131     if not EDMapSuffixes:
 1132         MiscUtil.PrintError("No valid parameter name and value pairs specified using \"--EDMapSuffixes\" option.")
 1133     
 1134     EDMapSuffixesWords = EDMapSuffixes.split(",")
 1135     if len(EDMapSuffixesWords) % 2:
 1136         MiscUtil.PrintError("The number of comma delimited ED map types names and suffixes, %d, specified using \"--EDMapSuffixes\" option must be an even number." % (len(EDMapSuffixesWords)))
 1137 
 1138     for Index in range(0, len(EDMapSuffixesWords), 2):
 1139         EDMapType = EDMapSuffixesWords[Index]
 1140         EDMapSuffix = EDMapSuffixesWords[Index + 1]
 1141         
 1142         if re.match("^CompositeMap$", EDMapType, re.I):
 1143             EDMapType = "CompositeMap"
 1144         elif re.match("^DifferenceMap$", EDMapType, re.I):
 1145             EDMapType = "DifferenceMap"
 1146         else:
 1147             MiscUtil.PrintError("The ED map type, %s, specified using \"--EDMapSuffixes\" option is not a valid ED map type. Supported ED map types: CompositeMap, DifferenceMap" % (EDMapType))
 1148             
 1149         if re.match(EDMapSuffix, "None", re.I):
 1150             EDMapSuffix = ""
 1151         
 1152         OptionsInfo["EDMapSuffixesMap"][EDMapType] = EDMapSuffix
 1153     
 1154     SetupEDMapFileNamesUsingSuffixes()
 1155 
 1156 def SetupEDMapFileNamesUsingSuffixes():
 1157     """Set up ED map file names. """
 1158     
 1159     OptionsInfo["CompositeEDMapFiles"] = []
 1160     OptionsInfo["DiffEDMapFiles"] = []
 1161     
 1162     CompositeMapSuffix = OptionsInfo["EDMapSuffixesMap"]["CompositeMap"]
 1163     DiffMapSuffix = OptionsInfo["EDMapSuffixesMap"]["DifferenceMap"]
 1164     InfilesNamesCount = len(OptionsInfo["InfilesNames"])
 1165     
 1166     for Index in range(0, InfilesNamesCount):
 1167         Infile = OptionsInfo["InfilesNames"][Index]
 1168         FileDir, FileName, FileExt = MiscUtil.ParseFileName(Infile)
 1169         InfileRoot = FileName
 1170         
 1171         CompositeEDMapFile = "%s%s.ccp4" % (InfileRoot, CompositeMapSuffix)
 1172         DiffEDMapFile = "%s%s.ccp4" % (InfileRoot, DiffMapSuffix)
 1173         
 1174         if not os.path.exists(CompositeEDMapFile):
 1175             MiscUtil.PrintError("The composite ED map file, %s, for option \"--EDMapSuffixes\", corresponding to input file, %s, doesn't exist.\n" % (CompositeEDMapFile, Infile))
 1176 
 1177         DiffEDMapFileExists = False
 1178         if os.path.exists(DiffEDMapFile):
 1179             DiffEDMapFileExists = True
 1180         else:
 1181             MiscUtil.PrintWarning("The difference ED map file, %s, for option \"--EDMapSuffixes\", corresponding to input file, %s,  doesn't exist. PyMOL groups and objectes related to difference maps won't be created.\n" % (DiffEDMapFile, Infile))
 1182         
 1183         OptionsInfo["CompositeEDMapFiles"].append(CompositeEDMapFile)
 1184         if DiffEDMapFileExists:
 1185             OptionsInfo["DiffEDMapFiles"].append(DiffEDMapFile)
 1186         else:
 1187             OptionsInfo["DiffEDMapFiles"].append(None)
 1188 
 1189 def RetrieveInfilesInfo():
 1190     """Retrieve information for input files."""
 1191 
 1192     InfilesInfo = {}
 1193     
 1194     InfilesInfo["InfilesNames"] = []
 1195     InfilesInfo["InfilesRoots"] = []
 1196     InfilesInfo["ChainsAndLigandsInfo"] = []
 1197     
 1198     for Infile in OptionsInfo["InfilesNames"]:
 1199         FileDir, FileName, FileExt = MiscUtil.ParseFileName(Infile)
 1200         InfileRoot = FileName
 1201         
 1202         ChainsAndLigandInfo = PyMOLUtil.GetChainsAndLigandsInfo(Infile, InfileRoot)
 1203         
 1204         InfilesInfo["InfilesNames"].append(Infile)
 1205         InfilesInfo["InfilesRoots"].append(InfileRoot)
 1206         InfilesInfo["ChainsAndLigandsInfo"].append(ChainsAndLigandInfo)
 1207     
 1208     OptionsInfo["InfilesInfo"] = InfilesInfo
 1209 
 1210 def RetrieveRefFileInfo():
 1211     """Retrieve information for ref file."""
 1212 
 1213     RefFileInfo = {}
 1214     if not OptionsInfo["Align"]:
 1215         OptionsInfo["RefFileInfo"] = RefFileInfo
 1216         return
 1217 
 1218     RefFile = OptionsInfo["RefFileName"]
 1219     
 1220     FileDir, FileName, FileExt = MiscUtil.ParseFileName(RefFile)
 1221     RefFileRoot = FileName
 1222     
 1223     if re.match("^FirstInputFile$", OptionsInfo["AlignRefFile"], re.I):
 1224         ChainsAndLigandInfo = OptionsInfo["InfilesInfo"]["ChainsAndLigandsInfo"][0]
 1225     else:
 1226         MiscUtil.PrintInfo("\nRetrieving chain and ligand information for alignment reference file %s..." % RefFile)
 1227         ChainsAndLigandInfo = PyMOLUtil.GetChainsAndLigandsInfo(RefFile, RefFileRoot)
 1228 
 1229     RefFileInfo["RefFileName"] = RefFile
 1230     RefFileInfo["RefFileRoot"] = RefFileRoot
 1231     RefFileInfo["PyMOLObjectName"] = "AlignRef_%s" % RefFileRoot
 1232     RefFileInfo["ChainsAndLigandsInfo"] = ChainsAndLigandInfo
 1233     
 1234     OptionsInfo["RefFileInfo"] = RefFileInfo
 1235 
 1236 def ProcessChainAndLigandIDs():
 1237     """Process specified chain and ligand IDs for infiles."""
 1238     
 1239     OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"] = []
 1240     
 1241     for FileIndex in range(0, len(OptionsInfo["InfilesInfo"]["InfilesNames"])):
 1242         MiscUtil.PrintInfo("\nProcessing specified chain and ligand IDs for input file %s..." % OptionsInfo["InfilesInfo"]["InfilesNames"][FileIndex])
 1243         
 1244         ChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["ChainsAndLigandsInfo"][FileIndex]
 1245         SpecifiedChainsAndLigandsInfo = PyMOLUtil.ProcessChainsAndLigandsOptionsInfo(ChainsAndLigandsInfo, "-c, --chainIDs", OptionsInfo["ChainIDs"], "-l, --ligandIDs", OptionsInfo["LigandIDs"])
 1246         ProcessChainMeshesVolumesAndSurfacesOptions(SpecifiedChainsAndLigandsInfo)
 1247         OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"].append(SpecifiedChainsAndLigandsInfo)
 1248         
 1249         CheckPresenceOfValidLigandIDs(ChainsAndLigandsInfo, SpecifiedChainsAndLigandsInfo)
 1250         
 1251 def CheckPresenceOfValidLigandIDs(ChainsAndLigandsInfo, SpecifiedChainsAndLigandsInfo):
 1252     """Check presence of valid ligand IDs."""
 1253 
 1254     MiscUtil.PrintInfo("\nSpecified chain IDs: %s" % (", ".join(SpecifiedChainsAndLigandsInfo["ChainIDs"])))
 1255     
 1256     for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
 1257         if len (SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]):
 1258             MiscUtil.PrintInfo("Chain ID: %s; Specified LigandIDs: %s" % (ChainID, ", ".join(SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID])))
 1259         else:
 1260             MiscUtil.PrintInfo("Chain IDs: %s; Specified LigandIDs: None" % (ChainID))
 1261             MiscUtil.PrintWarning("No valid ligand IDs found for chain ID, %s. PyMOL groups and objects related to ligand and binding pockect won't be created." % (ChainID))
 1262 
 1263 def RetrieveFirstChainID(FileIndex):
 1264     """Get first chain ID."""
 1265     
 1266     ChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["ChainsAndLigandsInfo"][FileIndex]
 1267     
 1268     FirstChainID = None
 1269     if len(ChainsAndLigandsInfo["ChainIDs"]):
 1270         FirstChainID = ChainsAndLigandsInfo["ChainIDs"][0]
 1271     
 1272     return FirstChainID
 1273 
 1274 def ProcessChainMeshesVolumesAndSurfacesOptions(SpecifiedChainsAndLigandsInfo):
 1275     """Process options to create meshes and surfaces for chains."""
 1276 
 1277     SpecifiedChainsAndLigandsInfo["VolumeChainComplex"] = {}
 1278     SpecifiedChainsAndLigandsInfo["MeshChainComplex"] = {}
 1279     SpecifiedChainsAndLigandsInfo["SurfaceChainComplex"] = {}
 1280 
 1281     SpecifiedChainsAndLigandsInfo["EnableVolumeChainComplex"] = {}
 1282     SpecifiedChainsAndLigandsInfo["EnableMeshChainComplex"] = {}
 1283     SpecifiedChainsAndLigandsInfo["EnableSurfaceChainComplex"] = {}
 1284     
 1285     SpecifiedChainsAndLigandsInfo["EnableChainComplexGroup"] = {}
 1286     SpecifiedChainsAndLigandsInfo["EnableChainAloneGroup"] = {}
 1287     
 1288     for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
 1289         LigandsPresent = True if len(SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]) else False
 1290 
 1291         # Create and enable mesh  or volume in auto mode...
 1292         if re.match("^auto$", OptionsInfo["MeshChainComplex"], re.I):
 1293             MeshChainComplex = False if LigandsPresent else True
 1294             EnableMeshChainComplex = False if LigandsPresent else True
 1295         else:
 1296             MeshChainComplex = True if re.match("^Yes$", OptionsInfo["MeshChainComplex"], re.I) else False
 1297             EnableMeshChainComplex = True if re.match("^Yes$", OptionsInfo["MeshChainComplex"], re.I) else False
 1298         
 1299         if re.match("^auto$", OptionsInfo["VolumeChainComplex"], re.I):
 1300             VolumeChainComplex = False if LigandsPresent else True
 1301             EnableVolumeChainComplex = False if LigandsPresent else True
 1302         else:
 1303             VolumeChainComplex = True if re.match("^Yes$", OptionsInfo["VolumeChainComplex"], re.I) else False
 1304             EnableVolumeChainComplex = True if re.match("^Yes$", OptionsInfo["VolumeChainComplex"], re.I) else False
 1305         
 1306         if MeshChainComplex and EnableMeshChainComplex:
 1307             EnableVolumeChainComplex = False
 1308         
 1309         # Create and enable surface in auto mode based on the status of mesh and volume...
 1310         if re.match("^auto$", OptionsInfo["SurfaceChainComplex"], re.I):
 1311             SurfaceChainComplex = False if LigandsPresent else True
 1312             EnableSurfaceChainComplex = False if LigandsPresent else True
 1313             
 1314             if MeshChainComplex or VolumeChainComplex:
 1315                 SurfaceChainComplex = False
 1316                 EnableSurfaceChainComplex = False
 1317         else:
 1318             SurfaceChainComplex = True if re.match("^Yes$", OptionsInfo["SurfaceChainComplex"], re.I) else False
 1319             EnableSurfaceChainComplex = True if re.match("^Yes$", OptionsInfo["SurfaceChainComplex"], re.I) else False
 1320         
 1321         if (MeshChainComplex and EnableMeshChainComplex) or (VolumeChainComplex or EnableVolumeChainComplex):
 1322             EnableSurfaceChainComplex = False
 1323             
 1324         if LigandsPresent:
 1325             EnableChainComplexGroup = False
 1326             EnableChainAloneGroup = True
 1327         else:
 1328             EnableChainComplexGroup = True
 1329             EnableChainAloneGroup = False
 1330 
 1331         SpecifiedChainsAndLigandsInfo["VolumeChainComplex"][ChainID] = VolumeChainComplex
 1332         SpecifiedChainsAndLigandsInfo["MeshChainComplex"][ChainID] = MeshChainComplex
 1333         SpecifiedChainsAndLigandsInfo["SurfaceChainComplex"][ChainID] = SurfaceChainComplex
 1334         
 1335         SpecifiedChainsAndLigandsInfo["EnableVolumeChainComplex"][ChainID] = EnableVolumeChainComplex
 1336         SpecifiedChainsAndLigandsInfo["EnableMeshChainComplex"][ChainID] = EnableMeshChainComplex
 1337         SpecifiedChainsAndLigandsInfo["EnableSurfaceChainComplex"][ChainID] = EnableSurfaceChainComplex
 1338         
 1339         SpecifiedChainsAndLigandsInfo["EnableChainComplexGroup"][ChainID] = EnableChainComplexGroup
 1340         SpecifiedChainsAndLigandsInfo["EnableChainAloneGroup"][ChainID] = EnableChainAloneGroup
 1341 
 1342 def ProcessOptions():
 1343     """Process and validate command line arguments and options"""
 1344     
 1345     MiscUtil.PrintInfo("Processing options...")
 1346     
 1347     # Validate options...
 1348     ValidateOptions()
 1349     
 1350     OptionsInfo["Align"] = True if re.match("^Yes$", Options["--align"], re.I) else False
 1351     OptionsInfo["AlignMethod"] = Options["--alignMethod"].lower()
 1352     OptionsInfo["AlignMode"] = Options["--alignMode"]
 1353     
 1354     OptionsInfo["AllowEmptyObjects"] = True if re.match("^Yes$", Options["--allowEmptyObjects"], re.I) else False
 1355     
 1356     OptionsInfo["BFactorChainCartoonPutty"] = True if re.match("^Yes$", Options["--BFactorChainCartoonPutty"], re.I) else False
 1357     OptionsInfo["BFactorColorPalette"] = Options["--BFactorColorPalette"]
 1358     
 1359     OptionsInfo["Infiles"] = Options["--infiles"]
 1360     OptionsInfo["InfilesNames"] =  Options["--infileNames"]
 1361 
 1362     OptionsInfo["AlignRefFile"] = Options["--alignRefFile"]
 1363     if re.match("^FirstInputFile$", Options["--alignRefFile"], re.I):
 1364         OptionsInfo["RefFileName"] = OptionsInfo["InfilesNames"][0]
 1365     else:
 1366         OptionsInfo["RefFileName"] = Options["--alignRefFile"]
 1367     
 1368     OptionsInfo["EDMapFiles"] = Options["--EDMapFiles"]
 1369     OptionsInfo["EDMapSuffixes"] = Options["--EDMapSuffixes"]
 1370     ProcessEDMapFilesAndSuffixes()
 1371 
 1372     OptionsInfo["Overwrite"] = Options["--overwrite"]
 1373     OptionsInfo["PMLOut"] = True if re.match("^Yes$", Options["--PMLOut"], re.I) else False
 1374     
 1375     OptionsInfo["Outfile"] = Options["--outfile"]
 1376     FileDir, FileName, FileExt = MiscUtil.ParseFileName(OptionsInfo["Outfile"])
 1377     OptionsInfo["PSEOut"] = False 
 1378     if re.match("^pml$", FileExt, re.I):
 1379         OptionsInfo["PMLOutfile"] = OptionsInfo["Outfile"] 
 1380         OptionsInfo["PMEOutfile"] = re.sub(".pml$", ".pme", OptionsInfo["Outfile"]) 
 1381     elif re.match("^pse$", FileExt, re.I):
 1382         OptionsInfo["PSEOut"] = True 
 1383         OptionsInfo["PSEOutfile"] = OptionsInfo["Outfile"] 
 1384         OptionsInfo["PMLOutfile"] = re.sub(".pse$", ".pml", OptionsInfo["Outfile"]) 
 1385         if os.path.exists(OptionsInfo["PMLOutfile"]) and (not OptionsInfo["Overwrite"]):
 1386             MiscUtil.PrintError("The intermediate output file to be generated, %s, already exist. Use option \"--ov\" or \"--overwrite\" and try again." % OptionsInfo["PMLOutfile"] )
 1387 
 1388     OptionsInfo["LabelFontID"] = int(Options["--labelFontID"])
 1389     
 1390     # Process mesh parameters...
 1391     OptionsInfo["MeshCarveRadius"] = float(Options["--meshCarveRadius"])
 1392     OptionsInfo["MeshComplex"] = True if re.match("^Yes$", Options["--meshComplex"], re.I) else False
 1393     OptionsInfo["MeshChainComplex"] = Options["--meshChainComplex"]
 1394     OptionsInfo["MeshWidth"] = float(Options["--meshWidth"])
 1395     
 1396     OptionsInfo["MeshColorCompositeMap"] = Options["--meshColorCompositeMap"]
 1397     OptionsInfo["MeshLevelCompositeMap"] = float(Options["--meshLevelCompositeMap"])
 1398     OptionsInfo["Mesh1ColorDiffMap"] = Options["--mesh1ColorDiffMap"]
 1399     OptionsInfo["Mesh1LevelDiffMap"] = float(Options["--mesh1LevelDiffMap"])
 1400     OptionsInfo["Mesh2ColorDiffMap"] = Options["--mesh2ColorDiffMap"]
 1401     OptionsInfo["Mesh2LevelDiffMap"] = float(Options["--mesh2LevelDiffMap"])
 1402     
 1403     OptionsInfo["SurfaceComplex"] = True if re.match("^Yes$", Options["--surfaceComplex"], re.I) else False
 1404     OptionsInfo["SurfaceChainComplex"] = Options["--surfaceChainComplex"]
 1405     OptionsInfo["SurfaceTransparency"] = float(Options["--surfaceTransparency"])
 1406     
 1407     OptionsInfo["PocketContactsLigandColor"] = Options["--pocketContactsLigandColor"]
 1408     OptionsInfo["PocketContactsLigandHydrophobicColor"] = Options["--pocketContactsLigandHydrophobicColor"]
 1409     OptionsInfo["PocketContactsSolventColor"] = Options["--pocketContactsSolventColor"]
 1410     OptionsInfo["PocketContactsInorganicColor"] = Options["--pocketContactsInorganicColor"]
 1411     
 1412     OptionsInfo["PocketContactsCutoff"] = float(Options["--pocketContactsCutoff"])
 1413     OptionsInfo["PocketDistanceCutoff"] = float(Options["--pocketDistanceCutoff"])
 1414     
 1415     OptionsInfo["PocketLabelColor"] = Options["--pocketLabelColor"]
 1416     OptionsInfo["PocketSurface"] = True if re.match("^Yes$", Options["--pocketSurface"], re.I) else False
 1417     
 1418     OptionsInfo["VolumeCarveRadius"] = float(Options["--volumeCarveRadius"])
 1419     OptionsInfo["VolumeComplex"] = True if re.match("^Yes$", Options["--volumeComplex"], re.I) else False
 1420     OptionsInfo["VolumeChainComplex"] = Options["--volumeChainComplex"]
 1421     
 1422     OptionsInfo["VolumeColorRampCompositeMap"] = Options["--volumeColorRampCompositeMap"]
 1423     OptionsInfo["VolumeColorRampDiffMap"] = Options["--volumeColorRampDiffMap"]
 1424     
 1425     RetrieveInfilesInfo()
 1426     RetrieveRefFileInfo()
 1427     
 1428     OptionsInfo["ChainIDs"] = Options["--chainIDs"]
 1429     OptionsInfo["LigandIDs"] = Options["--ligandIDs"]
 1430     
 1431     ProcessChainAndLigandIDs()
 1432 
 1433 def RetrieveOptions(): 
 1434     """Retrieve command line arguments and options"""
 1435     
 1436     # Get options...
 1437     global Options
 1438     Options = docopt(_docoptUsage_)
 1439     
 1440     # Set current working directory to the specified directory...
 1441     WorkingDir = Options["--workingdir"]
 1442     if WorkingDir:
 1443         os.chdir(WorkingDir)
 1444     
 1445     # Handle examples option...
 1446     if "--examples" in Options and Options["--examples"]:
 1447         MiscUtil.PrintInfo(MiscUtil.GetExamplesTextFromDocOptText(_docoptUsage_))
 1448         sys.exit(0)
 1449 
 1450 def ValidateOptions():
 1451     """Validate option values"""
 1452     
 1453     MiscUtil.ValidateOptionTextValue("--align", Options["--align"], "yes no")
 1454     MiscUtil.ValidateOptionTextValue("--alignMethod", Options["--alignMethod"], "align cealign super")
 1455     MiscUtil.ValidateOptionTextValue("--alignMode", Options["--alignMode"], "FirstChain Complex")
 1456     
 1457     MiscUtil.ValidateOptionTextValue("--allowEmptyObjects", Options["--allowEmptyObjects"], "yes no")
 1458     
 1459     MiscUtil.ValidateOptionTextValue("--BFactorChainCartoonPutty", Options["--BFactorChainCartoonPutty"], "yes no")
 1460     
 1461     # Expand infiles to handle presence of multiple input files...
 1462     InfileNames = MiscUtil.ExpandFileNames(Options["--infiles"], ",")
 1463     if not len(InfileNames):
 1464         MiscUtil.PrintError("No input files specified for \"-i, --infiles\" option")
 1465 
 1466     # Validate file extensions...
 1467     for Infile in InfileNames:
 1468         MiscUtil.ValidateOptionFilePath("-i, --infiles", Infile)
 1469         MiscUtil.ValidateOptionFileExt("-i, --infiles", Infile, "pdb cif")
 1470         MiscUtil.ValidateOptionsDistinctFileNames("-i, --infiles", Infile, "-o, --outfile", Options["--outfile"])
 1471     Options["--infileNames"] = InfileNames
 1472     
 1473     MiscUtil.ValidateOptionFileExt("-o, --outfile", Options["--outfile"], "pml pse")
 1474     MiscUtil.ValidateOptionsOutputFileOverwrite("-o, --outfile", Options["--outfile"], "--overwrite", Options["--overwrite"])
 1475     
 1476     if re.match("^yes$", Options["--align"], re.I):
 1477         if not re.match("^FirstInputFile$", Options["--alignRefFile"], re.I):
 1478             AlignRefFile = Options["--alignRefFile"]
 1479             MiscUtil.ValidateOptionFilePath("--alignRefFile", AlignRefFile)
 1480             MiscUtil.ValidateOptionFileExt("--alignRefFile", AlignRefFile, "pdb cif")
 1481             MiscUtil.ValidateOptionsDistinctFileNames("--AlignRefFile", AlignRefFile, "-o, --outfile", Options["--outfile"])
 1482     
 1483     MiscUtil.ValidateOptionTextValue("--PMLOut", Options["--PMLOut"], "yes no")
 1484     MiscUtil.ValidateOptionIntegerValue("--labelFontID", Options["--labelFontID"], {})
 1485 
 1486     MiscUtil.ValidateOptionFloatValue("--meshCarveRadius", Options["--meshCarveRadius"], {">": 0.0})
 1487     MiscUtil.ValidateOptionTextValue("--meshComplex", Options["--meshComplex"], "yes no")
 1488     MiscUtil.ValidateOptionTextValue("--meshChainComplex", Options["--meshChainComplex"], "yes no auto")
 1489     MiscUtil.ValidateOptionFloatValue("--meshWidth", Options["--meshWidth"], {">": 0.0})
 1490     
 1491     MiscUtil.ValidateOptionFloatValue("--meshLevelCompositeMap", Options["--meshLevelCompositeMap"], {})
 1492     MiscUtil.ValidateOptionFloatValue("--mesh1LevelDiffMap", Options["--mesh1LevelDiffMap"], {})
 1493     MiscUtil.ValidateOptionFloatValue("--mesh2LevelDiffMap", Options["--mesh2LevelDiffMap"], {})
 1494     
 1495     MiscUtil.ValidateOptionTextValue("--surfaceComplex", Options["--surfaceComplex"], "yes no")
 1496     MiscUtil.ValidateOptionTextValue("--surfaceChainComplex", Options["--surfaceChainComplex"], "yes no auto")
 1497     MiscUtil.ValidateOptionFloatValue("--surfaceTransparency", Options["--surfaceTransparency"], {">=": 0.0, "<=": 1.0})
 1498     
 1499     MiscUtil.ValidateOptionFloatValue("--pocketContactsCutoff", Options["--pocketContactsCutoff"], {">": 0.0})
 1500     MiscUtil.ValidateOptionFloatValue("--pocketDistanceCutoff", Options["--pocketDistanceCutoff"], {">": 0.0})
 1501     if (float(Options["--pocketContactsCutoff"]) > float(Options["--pocketDistanceCutoff"])):
 1502         MiscUtil.PrintError("The value, %s, specified using option \"--pocketContactsCutoff\" must be less than value, %s, specified using \"-pocketDistanceCutoff\" option." % (Options["--pocketContactsCutoff"], Options["--pocketDistanceCutoff"]))
 1503     
 1504     MiscUtil.ValidateOptionTextValue("--pocketSurface", Options["--pocketSurface"], "yes no")
 1505     
 1506     MiscUtil.ValidateOptionFloatValue("--volumeCarveRadius", Options["--volumeCarveRadius"], {">": 0.0})
 1507     MiscUtil.ValidateOptionTextValue("--volumeComplex", Options["--volumeComplex"], "yes no")
 1508     MiscUtil.ValidateOptionTextValue("--volumeChainComplex", Options["--volumeChainComplex"], "yes no auto")
 1509     
 1510 # Setup a usage string for docopt...
 1511 _docoptUsage_ = """
 1512 PyMOLVisualizeElectronDensity.py - Visualize electron density
 1513 
 1514 Usage:
 1515     PyMOLVisualizeElectronDensity.py  [--align <yes or no>] [--alignMethod <align, cealign, super>]
 1516                                      [--alignMode <FirstChain or Complex>] [--alignRefFile <filename>]
 1517                                      [--allowEmptyObjects <yes or no>] [--BFactorChainCartoonPutty <yes or no>]
 1518                                      [--BFactorColorPalette <text> ] [--chainIDs <First, All or ID1,ID2...>]
 1519                                      [--EDMapFiles <file1,file2,...>] [--EDMapSuffixes <CompositeMap,None,...>]
 1520                                      [--ligandIDs <Largest, All or ID1,ID2...>] [--labelFontID <number>]
 1521                                      [--meshCarveRadius <number>] [--meshComplex <yes or no>]
 1522                                      [--meshChainComplex <yes or no>] [--meshColorCompositeMap <text>]
 1523                                      [--meshLevelCompositeMap <number>] [--meshWidth <number>]
 1524                                      [--mesh1ColorDiffMap <text>] [--mesh1LevelDiffMap <number>]
 1525                                      [--mesh2ColorDiffMap <text>] [--mesh2LevelDiffMap <number>]
 1526                                      [--PMLOut <yes or no>] [--pocketContactsLigandColor <text>]
 1527                                      [--pocketContactsLigandHydrophobicColor <text>] [--pocketContactsSolventColor <text>]
 1528                                      [--pocketContactsInorganicColor <text>] [--pocketContactsCutoff <number>]
 1529                                      [--pocketDistanceCutoff <number>] [--pocketLabelColor <text>]
 1530                                      [--pocketSurface <yes or no>] [--surfaceComplex <yes or no> ]
 1531                                      [--surfaceChainComplex <yes or no>] [--surfaceTransparency <number>]
 1532                                      [--volumeCarveRadius <number>] [--volumeComplex <yes or no>]
 1533                                      [--volumeChainComplex <yes, no, or auto>] [--volumeColorRampCompositeMap <text>]
 1534                                      [--volumeColorRampDiffMap <text> ] [--overwrite] [-w <dir>] -i <infile1,infile2...> -o <outfile>
 1535     PyMOLVisualizeElectronDensity.py -h | --help | -e | --examples
 1536 
 1537 Description:
 1538     Generate PyMOL visualization files for viewing X-ray electron density around
 1539     chains, ligands, and ligand binding pockets in macromolecules including proteins
 1540     and nucleic acids.
 1541 
 1542     The supported input file formats are: Macromolecule - PDB (.pdb) or CIF(.cif),
 1543     Electron Density - Collaborative Computational Project Number 4 (CCP4) ( .ccp4)
 1544 
 1545     The supported output file formats are: PyMOL script file (.pml), PyMOL session
 1546     file (.pse)
 1547 
 1548     Two types of CCP4 electron density map files may be used for visualizing electron
 1549     density. These file types along with default file names are shown below:
 1550     
 1551         CompositeMap (2Fobs - Fcalc) - <InfileRoot>.ccp4 (required)
 1552         DifferenceMap (Fobs - Fcalc) - <InfileRoot>_diff.ccp4 (optional)
 1553     
 1554     The compsite map file must be present. The difference map file is optional.
 1555     The mesh, volume, and surface PyMOL objects are not generated for missing
 1556     difference map file.
 1557 
 1558     The electron density present in composite map file is generated by adding two
 1559     difference maps to a calculated map (Fcalc) as shown below:
 1560     
 1561         Fcalc + 2(Fobs - Fcalc) = 2Fobs - Fcalc
 1562     
 1563     The following types of meshes and volumes may be created by default for
 1564     electron density present in composite and difference map files:
 1565     
 1566         CompositeVolume - VolumeColorRamp: 2fofc
 1567         CompositeMesh - ContourLevel: 1; Color: Blue
 1568         DiffVolume - VolumeColorRamp: fofc
 1569         DiffMesh1 - ContourLevel: 3; Color: Green
 1570         DiffMesh2 - ContourLevel: -3; Color: Red
 1571 
 1572     The two meshes created for difference maps correspond to false negative and
 1573     false positive in terms of electron density present in the model. The first mesh
 1574     shown in  green color corresponds to observed electron density missing in the
 1575     model. The second mesh in in red color indicates model electron density not
 1576     observed in the experiment.
 1577     
 1578     A variety of PyMOL groups and objects may be  created for visualization of
 1579     electron density present in map files. These groups and objects correspond to
 1580     maps, volumes, meshes, surfaces,chains, ligands, inorganics, ligand binding
 1581     pockets, polar interactions, and pocket hydrophobic surfaces. A complete
 1582     hierarchy of all possible PyMOL groups and objects is shown below:
 1583     
 1584         <PDBFileRoot>
 1585             .Complex
 1586                 .Complex
 1587                 .2Fo-Fc
 1588                     .Map
 1589                     .Volume
 1590                     .Mesh
 1591                     .Surface
 1592                 .Fo-Fc
 1593                     .Map
 1594                     .Volume
 1595                     .Mesh1
 1596                     .Surface1
 1597                     .Mesh2
 1598                     .Surface2
 1599             .Chain<ID>
 1600                 .Complex
 1601                     .Complex
 1602                     .2Fo-Fc
 1603                         .Volume
 1604                         .Mesh
 1605                         .Surface
 1606                     .Fo-Fc
 1607                         .Volume
 1608                         .Mesh1
 1609                         .Surface1
 1610                         .Mesh2
 1611                         .Surface2
 1612                 .Chain
 1613                     .Chain
 1614                     .BFactor
 1615                 .Solvent
 1616                 .Inorganic
 1617                 .Ligand<ID>
 1618                     .Ligand
 1619                         .Ligand
 1620                         .2Fo-Fc
 1621                             .Volume
 1622                             .Mesh
 1623                             .Surface
 1624                         .Fo-Fc
 1625                             .Volume
 1626                             .Mesh1
 1627                             .Surface1
 1628                             .Mesh2
 1629                             .Surface2
 1630                     .Pocket
 1631                         .Pocket
 1632                         .2Fo-Fc
 1633                             .Volume
 1634                             .Mesh
 1635                             .Surface
 1636                         .Fo-Fc
 1637                             .Volume
 1638                             .Mesh1
 1639                             .Surface1
 1640                             .Mesh2
 1641                             .Surface2
 1642                         .Polar_Contacts
 1643                         .Hydrophobic_Contacts
 1644                         .Surface
 1645                     .Pocket_Solvent
 1646                         .Pocket_Solvent
 1647                         .2Fo-Fc
 1648                             .Volume
 1649                             .Mesh
 1650                             .Surface
 1651                         .Fo-Fc
 1652                             .Volume
 1653                             .Mesh1
 1654                             .Surface1
 1655                             .Mesh2
 1656                             .Surface2
 1657                         .Polar_Contacts
 1658                     .Pocket_Inorganic
 1659                         .Pocket_Inorganic
 1660                         .2Fo-Fc
 1661                             .Volume
 1662                             .Mesh
 1663                             .Surface
 1664                         .Fo-Fc
 1665                             .Volume
 1666                             .Mesh1
 1667                             .Surface1
 1668                             .Mesh2
 1669                             .Surface2
 1670                         .Polar_Contacts
 1671                 .Ligand<ID>
 1672                     .Ligand
 1673                         ... ... ...
 1674                     .Pocket
 1675                         ... ... ...
 1676                     .Pocket_Solvent
 1677                         ... ... ...
 1678                     .Pocket_Inorganic
 1679                         ... ... ...
 1680             .Chain<ID>
 1681                 ... ... ...
 1682                 .Ligand<ID>
 1683                     ... ... ...
 1684                 .Ligand<ID>
 1685                     ... ... ...
 1686             .Chain<ID>
 1687                 ... ... ...
 1688         <PDBFileRoot>
 1689             .Complex
 1690                 ... ... ...
 1691             .Chain<ID>
 1692                 ... ... ...
 1693                 .Ligand<ID>
 1694                     ... ... ...
 1695                 .Ligand<ID>
 1696                     ... ... ...
 1697             .Chain<ID>
 1698                 ... ... ...
 1699     
 1700     The meshes, volumes, and surfaces  are not created for complete complex in
 1701     each input file by default. A word to the wise: The creation of these surface, volume,
 1702     and mesh objects may slow down loading of PML file and generation of PSE file,
 1703     based on the size of input complex and map files. The generation of PSE file
 1704     may also fail.
 1705 
 1706 Options:
 1707     -a, --align <yes or no>  [default: no]
 1708         Align input files to a reference file before visualization along with
 1709         available electron density map files.
 1710     --alignMethod <align, cealign, super>  [default: super]
 1711         Alignment methodology to use for aligning input files to a
 1712         reference file.
 1713     --alignMode <FirstChain or Complex>  [default: FirstChain]
 1714         Portion of input and reference files to use for spatial alignment of
 1715         input files against reference file.  Possible values: FirstChain or
 1716         Complex.
 1717         
 1718         The FirstChain mode allows alignment of the first chain in each input
 1719         file to the first chain in the reference file along with moving the rest
 1720         of the complex to coordinate space of the reference file. The complete
 1721         complex in each input file is aligned to the complete complex in reference
 1722         file for the Complex mode.
 1723     --alignRefFile <filename>  [default: FirstInputFile]
 1724         Reference input file name. The default is to use the first input file
 1725         name specified using '-i, --infiles' option.
 1726     --allowEmptyObjects <yes or no>  [default: no]
 1727         Allow creation of empty PyMOL objects corresponding to solvent and
 1728         inorganic atom selections across chains, ligands, and ligand binding pockets
 1729         in input file(s).
 1730     -c, --chainIDs <First, All or ID1,ID2...>  [default: First]
 1731         List of chain IDs to use for visualizing electron density. Possible values:
 1732         First, All, or a comma delimited list of chain IDs. The default is to use the
 1733         chain ID for the first chain in each input file.
 1734     -b, --BFactorChainCartoonPutty <yes or no>  [default: yes]
 1735         A cartoon putty around individual chains colored by B factors. The minimum
 1736         and maximum values for B factors are automatically detected. These values
 1737         indicate spread of electron density around atoms. The 'blue_white_red' color
 1738         palette is deployed for coloring the cartoon putty.
 1739     --BFactorColorPalette <text>  [default: blue_white_red]
 1740         Color palette for coloring cartoon putty around chains generated using B
 1741         factors. Any valid PyMOL color palette name is allowed. No validation is
 1742         performed. The complete list of valid color palette names is a available
 1743         at: pymolwiki.org/index.php/Spectrum. Examples: blue_white_red,
 1744         blue_white_magenta, blue_red, green_white_red, green_red.
 1745     -e, --examples
 1746         Print examples.
 1747     --EDMapFiles <file1,file1,file3...>  [default: auto]
 1748         Pairwise comma delimited list of composite and difference electron
 1749         density map files corresponding to input files. By default, the names
 1750         of electron density files are automatically generated using a combination
 1751         of input file names and file suffixes '--EDMapSuffixes'.
 1752         
 1753         The first file with in each pairs of filenames correspond to composite
 1754         electron density map. A composite file must be present for each input
 1755         file. The second file corresponds to difference electron density map. The
 1756         difference map file is optional. A value of 'None' must be used to represent
 1757         a missing difference map file. 
 1758         
 1759         The number of specified files must be twice the number of input files.
 1760     --EDMapSuffixes <CompositeMap,None,...>  [default: auto]
 1761         Electron density map file suffixes for generating names of map files from
 1762         the root of input files. It is a pairwise comma delimited list of 'EDMapType'
 1763         and file suffix.
 1764         
 1765         This option is ignored during explicit specification of electron density
 1766         map files using '--EDMapFiles'.
 1767         
 1768         Supported values for 'EDMapType': 'CompositeMap, DifferenceMap'.
 1769         Supported value for file suffix: Any valid string.
 1770         
 1771         Default value: 'CompositeMap,None,DifferenceMap,_diff'
 1772         
 1773         This option is only used for 'Auto' value of '--EDMapFilesMode' option.
 1774         
 1775         The default names of the map files, generated form a combination of
 1776         'InfileRoot' and 'EDSMapType' are shown below:
 1777             
 1778             CompositeMap (2Fobs - Fcalc) - <InfileRoot>.ccp4
 1779             DifferenceMap (Fobs - Fcalc) - <InfileRoot>_diff.ccp4
 1780             
 1781         The composite map files must be present. The difference map files are
 1782         optional.
 1783     -h, --help
 1784         Print this help message.
 1785     -i, --infiles <infile1,infile2,infile3...>
 1786         Input file names.
 1787     -l, --ligandIDs <Largest, All or ID1,ID2...>  [default: Largest]
 1788         List of ligand IDs present in chains for visualizing electron density across
 1789         ligands and ligand binding pockets. Possible values: Largest, All, or a comma
 1790         delimited list of ligand IDs. The default is to use the largest ligand present
 1791         in all or specified chains in each input file.
 1792         
 1793         Ligands are identified using organic selection operator available in PyMOL.
 1794         It'll also  identify buffer molecules as ligands. The largest ligand contains
 1795         the highest number of heavy atoms.
 1796     --labelFontID <number>  [default: 7]
 1797         Font ID for drawing labels. Default: 7 (Sans Bold). Valid values: 5 to 16.
 1798         The specified value must be a valid PyMOL font ID. No validation is
 1799         performed. The complete lists of valid font IDs is available at:
 1800         pymolwiki.org/index.php/Label_font_id. Examples: 5 - Sans;
 1801         7 - Sans Bold; 9 - Serif; 10 - Serif Bold.
 1802     --meshCarveRadius <number>  [default: 1.6]
 1803         Radius in Angstroms around atoms for including electron density.
 1804     --meshComplex <yes or no>  [default: no]
 1805         Create meshes for complete complex in each input file using corresponding
 1806         composite and difference maps. A total of three meshes, one for composite
 1807         map and two for difference map, are created for the complete complex.
 1808         
 1809         The composite and difference maps are always loaded for the complex.
 1810     --meshChainComplex <yes, no, or auto>  [default: auto]
 1811         Create meshes for individual chain complex in each input file using corresponding
 1812         composite and difference maps. A total of three meshes, one for composite map
 1813         map and two for difference map, are created for each chain complex. By default,
 1814         the meshes are automatically created for chain complexes without any ligands. 
 1815     --meshColorCompositeMap <text>  [default: blue]
 1816         Line color for meshes corresponding to composite maps. The specified value
 1817         must be valid color. No validation is performed.
 1818     --meshLevelCompositeMap <number>  [default: 1.0]
 1819         Contour level in sigma units for generating meshes corresponding to composite
 1820         maps.
 1821     --meshWidth <number>  [default: 0.5]
 1822         Line width for mesh lines corresponding to composite and difference maps.
 1823     --mesh1ColorDiffMap <text>  [default: green]
 1824         Line color for first mesh corresponding to difference maps at contour level
 1825         specified by '--mesh1LevelDiffMap'. The specified value must be valid color.
 1826         No validation is performed.
 1827     --mesh1LevelDiffMap <number>  [default: 3.0]
 1828         Contour level in sigma units for generating first mesh corresponding to 
 1829         to  difference maps.
 1830     --mesh2ColorDiffMap <text>  [default: red]
 1831         Line color for second mesh corresponding to difference maps at contour level
 1832         specified by '--mesh2LevelDiffMap'. The specified value must be valid color.
 1833         No validation is performed.
 1834     --mesh2LevelDiffMap <number>  [default: -3.0]
 1835         Contour level in sigma units for generating second mesh corresponding to
 1836         difference maps.
 1837     -o, --outfile <outfile>
 1838         Output file name.
 1839     -p, --PMLOut <yes or no>  [default: yes]
 1840         Save PML file during generation of PSE file.
 1841     --pocketContactsLigandColor <text>  [default: orange]
 1842         Color for drawing polar contacts between ligand and pocket residues.
 1843         The specified value must be valid color. No validation is performed.
 1844     --pocketContactsLigandHydrophobicColor <text>  [default: purpleblue]
 1845         Color for drawing hydrophobic contacts between ligand and pocket residues.
 1846         The specified value must be valid color. No validation is performed. The
 1847         hydrophobic contacts are shown between pairs of carbon atoms not
 1848         connected to hydrogen bond donor or acceptors atoms as identified
 1849         by PyMOL.
 1850     --pocketContactsSolventColor <text>  [default: marine]
 1851         Color for drawing polar contacts between solvent and pocket residues.
 1852         The specified value must be valid color. No validation is performed.
 1853     --pocketContactsInorganicColor <text>  [default: deepsalmon]
 1854         Color for drawing polar contacts between inorganic and pocket residues.
 1855         The specified value must be valid color. No validation is performed.
 1856     --pocketContactsCutoff <number>  [default: 4.0]
 1857         Distance in Angstroms for identifying polar and hyrdophobic contacts
 1858         between atoms in pocket residues and ligands.
 1859     --pocketDistanceCutoff <number>  [default: 5.0]
 1860         Distance in Angstroms for identifying pocket residues around ligands.
 1861     --pocketLabelColor <text>  [default: magenta]
 1862         Color for drawing residue or atom level labels for a pocket. The specified
 1863         value must be valid color. No validation is performed.
 1864     --pocketSurface <yes or no>  [default: yes]
 1865         Hydrophobic surface around pocket. The pocket surface is colored by
 1866         hydrophobicity. It is only valid for proteins. The color of amino acids is
 1867         set using the Eisenberg hydrophobicity scale. The color varies from red
 1868         to white, red being the most hydrophobic amino acid.
 1869     --surfaceComplex <yes or no>  [default: no]
 1870         Create surfaces for complete complex in each input file using corresponding
 1871         composite and difference maps. A total of three surfaces, one for composite
 1872         map and two for difference map, are created for the complete complex.
 1873         
 1874         The composite and difference maps are always loaded for the complex.
 1875     --surfaceChainComplex <yes, no or auto>  [default: auto]
 1876         Create surfaces for individual chain complexes in each input file using corresponding
 1877         composite and difference maps. A total of three surfaces, one for composite
 1878         map and two for difference map, are created for each chain complex. By default,
 1879         the surfaces are automatically created for chain complexes without any ligands. 
 1880     --surfaceTransparency <number>  [default: 0.25]
 1881         Surface transparency for molecular and electron density surfaces.
 1882     --volumeCarveRadius <number>  [default: 1.6]
 1883         Radius in Angstroms around atoms for including electron density during
 1884         generation of volume objects.
 1885     --volumeComplex <yes or no>  [default: no]
 1886         Create volumes for complete complex in input file using corresponding
 1887         composite and difference maps. A total of two volumes, one each for
 1888         composite and difference maps, are created for the complete complex.
 1889     --volumeChainComplex <yes, no, or auto>  [default: auto]
 1890         Create volumes for individual chain complex in each input file using corresponding
 1891         composite and difference maps. A total of two volumes, one each for composite
 1892         and difference maps, are created for each chain complex. By default, the
 1893         volumes are automatically created for chain complexes without any ligands.
 1894     --volumeColorRampCompositeMap <text>  [default: 2fofc]
 1895         Name of volume color ramp for composite maps. The specified value must
 1896         be a valid name. No validation is performed. The following volume color ramps
 1897         are currently available in PyMOL: default, 2fofc, fofc, rainbow, and rainbow2.
 1898     --volumeColorRampDiffMap <text>  [default: fofc]
 1899         Name of volume color ramp for difference maps. The specified value must
 1900         be a valid name. No validation is performed. The following volume color ramps
 1901         are currently available in PyMOL: default, 2fofc, fofc, rainbow, and rainbow2.
 1902     --overwrite
 1903         Overwrite existing files.
 1904     -w, --workingdir <dir>
 1905         Location of working directory which defaults to the current directory.
 1906 
 1907 Examples:
 1908     To visualize electron density for the largest ligand in the first chain, and
 1909     ligand binding pockets to highlight ligand interactions with pockect residues,
 1910     solvents and inorganics, in a PDB file by using default map files, and generate a
 1911     PML file, type:
 1912 
 1913         % PyMOLVisualizeElectronDensity.py -i Sample3.pdb -o Sample3.pml
 1914 
 1915     To visualize electron density for all ligands in all chains, and ligand binding
 1916     pockets to highlight ligand interactions with pockect residues, solvents
 1917     and inorganics, in a PDB file by using default map files, and generate a
 1918     PML file, type:
 1919 
 1920         % PyMOLVisualizeElectronDensity.py -i Sample3.pdb -o Sample3.pml
 1921           -c All -l All
 1922 
 1923     To visualize electron density for all chains and ligands, along with displaying
 1924     meshes, volumes, and surfaces for complete complex and individual chains,
 1925     in a PDB file by using  default map files, and generate a PML file, type:
 1926 
 1927         % PyMOLVisualizeElectronDensity.py -i Sample3.pdb -o Sample3.pml
 1928           --chainIDs All --ligandIDs All --meshComplex yes --surfaceComplex yes
 1929           --volumeComplex yes --meshChainComplex yes --surfaceChainComplex yes
 1930           --volumeChainComplex yes
 1931 
 1932     To visualize electron density for ligand ADP in chain E along with ligand binding
 1933     pocket, in a PDB file by using  default map files, and generate a PSE file, type:
 1934 
 1935         % PyMOLVisualizeElectronDensity.py -i Sample3.pdb -o Sample3.pse
 1936           --chainIDs E --ligandIDs ADP
 1937 
 1938     To visualize electron density for all igands in all chains along with their binding
 1939     pockets in a PDB file and using explicit file name suffixes for map files, and
 1940     generate a PML file, type:
 1941 
 1942         % PyMOLVisualizeElectronDensity.py -i Sample3.pdb -o Sample3.pml
 1943           --chainIDs All --ligandIDs All --EDMapSuffixes "CompositeMap,None,
 1944           DifferenceMap,_diff"
 1945 
 1946     To visualize electron density for all ligands in all chains along with their binding
 1947     pockets in a PDB file by using explicit file names for map files, and generate
 1948     a PML file, type:
 1949 
 1950         % PyMOLVisualizeElectronDensity.py -i Sample3.pdb -o Sample3.pml
 1951           --chainIDs All --ligandIDs All --EDMapFiles "Sample3.ccp4,
 1952           Sample3_diff.ccp4"
 1953 
 1954     To align and visualize electron density for all ligands in all chains along with their
 1955     binding pockets in PDB files by using explicit file names for map files, and generate
 1956     a PML file, type:
 1957 
 1958         % PyMOLVisualizeElectronDensity.py -a yes -i "Sample3.pdb,Sample4.pdb"
 1959           -o SampleOut.pml --chainIDs All --ligandIDs All --EDMapFiles
 1960          "Sample3.ccp4,Sample3_diff.ccp4,Sample4.ccp4,Sample4_diff.ccp4"
 1961 
 1962 Author:
 1963     Manish Sud(msud@san.rr.com)
 1964 
 1965 See also:
 1966     DownloadPDBFiles.pl, PyMOLVisualizeCavities.py,
 1967     PyMOLVisualizeCryoEMDensity.py, PyMOLVisualizeInterfaces.py,
 1968     PyMOLVisualizeMacromolecules.py, PyMOLVisualizeSurfaceAndBuriedResidues.py
 1969 
 1970 Copyright:
 1971     Copyright (C) 2019 Manish Sud. All rights reserved.
 1972 
 1973     The functionality available in this script is implemented using PyMOL, a
 1974     molecular visualization system on an open source foundation originally
 1975     developed by Warren DeLano.
 1976 
 1977     This file is part of MayaChemTools.
 1978 
 1979     MayaChemTools is free software; you can redistribute it and/or modify it under
 1980     the terms of the GNU Lesser General Public License as published by the Free
 1981     Software Foundation; either version 3 of the License, or (at your option) any
 1982     later version.
 1983 
 1984 """
 1985 
 1986 if __name__ == "__main__":
 1987     main()