MayaChemTools

    1 #!/bin/env python
    2 #
    3 # File: PyMOLVisualizeMacromolecules.py
    4 # Author: Manish Sud <msud@san.rr.com>
    5 #
    6 # Copyright (C) 2024 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; MayaChemTools v%s; %s): Starting...\n" % (ScriptName, pymol.cmd.get_version()[0], MiscUtil.GetMayaChemToolsVersion(), 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     GenerateMacromolecularVisualization()
   79     
   80     MiscUtil.PrintInfo("\n%s: Done...\n" % ScriptName)
   81     MiscUtil.PrintInfo("Total time: %s" % MiscUtil.GetFormattedElapsedTime(WallClockTime, ProcessorTime))
   82 
   83 def GenerateMacromolecularVisualization():
   84     """Generate macromolecular 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         # Setup trajectories views...
  112         if GetTrajectoriesStatus(FileIndex):
  113             WriteTrajectoriesView(OutFH, FileIndex, PyMOLObjectNames)
  114         
  115         SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
  116         FirstChain = True
  117         for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
  118             if FirstComplex and FirstChain:
  119                 FirstComplexFirstChainName = PyMOLObjectNames["Chains"][ChainID]["ChainAlone"]
  120                 
  121             WriteChainView(OutFH, FileIndex, PyMOLObjectNames, ChainID)
  122             
  123             # Setup ligand views...
  124             FirstLigand = True
  125             for LigandID in SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]:
  126                 WriteChainLigandView(OutFH, FileIndex, PyMOLObjectNames, ChainID, LigandID)
  127                 
  128                 # Set up ligand level group...
  129                 Enable, Action = [False, "close"]
  130                 if FirstLigand:
  131                     FirstLigand = False
  132                     Enable, Action = [True, "open"]
  133                 GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Ligands"][ChainID][LigandID]["ChainLigandGroup"], PyMOLObjectNames["Ligands"][ChainID][LigandID]["ChainLigandGroupMembers"], Enable, Action)
  134 
  135             # Setup docked poses views...
  136             if  GetChainAloneDockedPosesStatus(FileIndex, ChainID):
  137                 WriteChainDockedPosesView(OutFH, FileIndex, PyMOLObjectNames, ChainID)
  138             
  139             # Setup Chain level group...
  140             Enable, Action = [False, "close"]
  141             if FirstChain:
  142                 FirstChain = False
  143                 Enable, Action = [True, "open"]
  144             GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"], Enable, Action)
  145 
  146         # Set up complex level group...
  147         Enable, Action = [False, "close"]
  148         if FirstComplex:
  149             FirstComplex = False
  150             Enable, Action = [True, "open"]
  151         GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["PDBGroup"], PyMOLObjectNames["PDBGroupMembers"], Enable, Action)
  152         
  153         # Delete empty PyMOL objects...
  154         DeleteEmptyPyMOLObjects(OutFH, FileIndex, PyMOLObjectNames)
  155         
  156     if OptionsInfo["Align"]:
  157         DeleteAlignReference(OutFH)
  158 
  159     if FirstComplexFirstChainName is not None:
  160         OutFH.write("""\ncmd.orient("%s", animate = -1)\n""" % FirstComplexFirstChainName)
  161     else:
  162         OutFH.write("""\ncmd.orient("visible", animate = -1)\n""")
  163     
  164     OutFH.close()
  165 
  166     # Generate PSE file as needed...
  167     if OptionsInfo["PSEOut"]:
  168         GeneratePyMOLSessionFile()
  169 
  170 def WritePMLHeader(OutFH, ScriptName):
  171     """Write out PML header."""
  172 
  173     HeaderInfo = PyMOLUtil.SetupPMLHeaderInfo(ScriptName)
  174     OutFH.write("%s\n" % HeaderInfo)
  175 
  176 def WritePyMOLParameters(OutFH):
  177     """Write out PyMOL global parameters."""
  178 
  179     PMLCmds = []
  180     PMLCmds.append("""cmd.set("transparency", %.2f, "", 0)""" % (OptionsInfo["SurfaceTransparency"]))
  181     PMLCmds.append("""cmd.set("label_font_id", %s)""" % (OptionsInfo["LabelFontID"]))
  182     PML = "\n".join(PMLCmds)
  183     
  184     OutFH.write("""\n""\n"Setting up PyMOL gobal parameters..."\n""\n""")
  185     OutFH.write("%s\n" % PML)
  186     
  187 def WriteAlignReference(OutFH):
  188     """Setup object for alignment reference."""
  189 
  190     RefFileInfo = OptionsInfo["RefFileInfo"]
  191     RefFile = RefFileInfo["RefFileName"]
  192     RefName = RefFileInfo["PyMOLObjectName"]
  193     
  194     PMLCmds = []
  195     PMLCmds.append("""cmd.load("%s", "%s")""" % (RefFile, RefName))
  196     PMLCmds.append("""cmd.hide("everything", "%s")""" % (RefName))
  197     PMLCmds.append("""cmd.disable("%s")""" % (RefName))
  198     PML = "\n".join(PMLCmds)
  199     
  200     OutFH.write("""\n""\n"Loading %s and setting up view for align reference..."\n""\n""" % RefFile)
  201     OutFH.write("%s\n" % PML)
  202     
  203 def WriteAlignComplex(OutFH, FileIndex, PyMOLObjectNames):
  204     """Setup alignment of complex to reference."""
  205 
  206     RefFileInfo = OptionsInfo["RefFileInfo"]
  207     RefName = RefFileInfo["PyMOLObjectName"]
  208     
  209     ComplexName = PyMOLObjectNames["Complex"]
  210     
  211     if re.match("^FirstChain$", OptionsInfo["AlignMode"], re.I):
  212         RefFirstChainID = RefFileInfo["ChainsAndLigandsInfo"]["ChainIDs"][0]
  213         RefAlignSelection = "%s and chain %s" % (RefName, RefFirstChainID)
  214         
  215         ComplexFirstChainID = RetrieveFirstChainID(FileIndex)
  216         ComplexAlignSelection = "%s and chain %s" % (ComplexName, ComplexFirstChainID)
  217     else:
  218         RefAlignSelection = RefName
  219         ComplexAlignSelection = ComplexName
  220 
  221     PML = PyMOLUtil.SetupPMLForAlignment(OptionsInfo["AlignMethod"], RefAlignSelection, ComplexAlignSelection)
  222     OutFH.write("""\n""\n"Aligning %s against reference %s ..."\n""\n""" % (ComplexAlignSelection, RefAlignSelection))
  223     OutFH.write("%s\n" % PML)
  224     
  225 def DeleteAlignReference(OutFH):
  226     """Delete alignment reference object."""
  227     
  228     RefName = OptionsInfo["RefFileInfo"]["PyMOLObjectName"]
  229     OutFH.write("""\n""\n"Deleting alignment reference object %s..."\n""\n""" % RefName)
  230     OutFH.write("""cmd.delete("%s")\n""" % RefName)
  231 
  232 def WriteComplexView(OutFH, FileIndex, PyMOLObjectNames, FirstComplex):
  233     """Write out PML for viewing polymer complex."""
  234 
  235     # Setup complex...
  236     Infile = OptionsInfo["InfilesInfo"]["InfilesNames"][FileIndex]
  237     PML = PyMOLUtil.SetupPMLForPolymerComplexView(PyMOLObjectNames["Complex"], Infile, True)
  238     OutFH.write("""\n""\n"Loading %s and setting up view for complex..."\n""\n""" % Infile)
  239     OutFH.write("%s\n" % PML)
  240 
  241     if OptionsInfo["Align"]:
  242         # No need to align complex on to itself...
  243         if not (re.match("^FirstInputFile$", OptionsInfo["AlignRefFile"], re.I) and FirstComplex):
  244             WriteAlignComplex(OutFH, FileIndex, PyMOLObjectNames)
  245     
  246     if OptionsInfo["SurfaceComplex"]:
  247         # Setup hydrophobic surface...
  248         PML = PyMOLUtil.SetupPMLForHydrophobicSurfaceView(PyMOLObjectNames["ComplexHydrophobicSurface"], PyMOLObjectNames["Complex"], ColorPalette = OptionsInfo["SurfaceColorPalette"], Enable = False)
  249         OutFH.write("\n%s\n" % PML)
  250     
  251     # Setup complex group...
  252     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["ComplexGroup"], PyMOLObjectNames["ComplexGroupMembers"], False, "close")
  253 
  254 def WriteChainView(OutFH, FileIndex, PyMOLObjectNames, ChainID):
  255     """Write out PML for viewing chain."""
  256     
  257     OutFH.write("""\n""\n"Setting up views for chain %s..."\n""\n""" % ChainID)
  258     
  259     ChainComplexName = PyMOLObjectNames["Chains"][ChainID]["ChainComplex"]
  260     
  261     # Setup chain complex group view...
  262     WriteChainComplexViews(OutFH, FileIndex, PyMOLObjectNames, ChainID)
  263 
  264     # Setup chain view...
  265     WriteChainAloneViews(OutFH, FileIndex, PyMOLObjectNames, ChainID)
  266     
  267     # Setup chain solvent view...
  268     PML = PyMOLUtil.SetupPMLForSolventView(PyMOLObjectNames["Chains"][ChainID]["Solvent"], ChainComplexName, False)
  269     OutFH.write("\n%s\n" % PML)
  270 
  271     # Setup chain inorganic view...
  272     PML = PyMOLUtil.SetupPMLForInorganicView(PyMOLObjectNames["Chains"][ChainID]["Inorganic"], ChainComplexName, False)
  273     OutFH.write("\n%s\n" % PML)
  274 
  275 def WriteChainComplexViews(OutFH, FileIndex, PyMOLObjectNames, ChainID):
  276     """Write chain complex views."""
  277     
  278     # Setup chain complex...
  279     ChainComplexName = PyMOLObjectNames["Chains"][ChainID]["ChainComplex"]
  280     PML = PyMOLUtil.SetupPMLForPolymerChainComplexView(ChainComplexName, PyMOLObjectNames["Complex"], ChainID, True)
  281     OutFH.write("%s\n" % PML)
  282 
  283     if OptionsInfo["SurfaceChainComplex"]:
  284         # Setup hydrophobic surface...
  285         PML = PyMOLUtil.SetupPMLForHydrophobicSurfaceView(PyMOLObjectNames["Chains"][ChainID]["ChainComplexHydrophobicSurface"], ChainComplexName, ColorPalette = OptionsInfo["SurfaceColorPalette"], Enable = False)
  286         OutFH.write("\n%s\n" % PML)
  287     
  288     # Setup chain complex group...
  289     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroupMembers"], False, "close")
  290     
  291 def WriteChainAloneViews(OutFH, FileIndex, PyMOLObjectNames, ChainID):
  292     """Write individual chain views."""
  293 
  294     ChainComplexName = PyMOLObjectNames["Chains"][ChainID]["ChainComplex"]
  295     
  296     # Setup chain view...
  297     ChainName = PyMOLObjectNames["Chains"][ChainID]["ChainAlone"]
  298     PML = PyMOLUtil.SetupPMLForPolymerChainView(ChainName, ChainComplexName, True)
  299     OutFH.write("\n%s\n" % PML)
  300     
  301     WriteChainAloneBFactorViews(OutFH,  FileIndex, PyMOLObjectNames, ChainID)
  302     
  303     WriteChainAloneChainSelectionsView(OutFH,  FileIndex, PyMOLObjectNames, ChainID)
  304     WriteChainAloneResidueTypesView(OutFH,  FileIndex, PyMOLObjectNames, ChainID)
  305         
  306     if GetChainAloneContainsSurfacesStatus(FileIndex, ChainID):
  307         # Setup a generic color surface...
  308         PML = PyMOLUtil.SetupPMLForSurfaceView(PyMOLObjectNames["Chains"][ChainID]["ChainAloneSurface"], ChainName,  Enable = False, Color = OptionsInfo["SurfaceColor"])
  309         OutFH.write("\n%s\n" % PML)
  310         
  311         if GetChainAloneSurfaceChainStatus(FileIndex, ChainID):
  312             # Setup surface colored by hydrophobicity...
  313             PML = PyMOLUtil.SetupPMLForHydrophobicSurfaceView(PyMOLObjectNames["Chains"][ChainID]["ChainAloneHydrophobicSurface"], ChainName, ColorPalette = OptionsInfo["SurfaceColorPalette"], Enable = False)
  314             OutFH.write("\n%s\n" % PML)
  315             
  316             # Setup surface colored by hyrdophobicity and charge...
  317             PML = PyMOLUtil.SetupPMLForHydrophobicAndChargeSurfaceView(PyMOLObjectNames["Chains"][ChainID]["ChainAloneHydrophobicChargeSurface"], ChainName, OptionsInfo["AtomTypesColorNames"]["HydrophobicAtomsColor"], OptionsInfo["AtomTypesColorNames"]["NegativelyChargedAtomsColor"], OptionsInfo["AtomTypesColorNames"]["PositivelyChargedAtomsColor"], OptionsInfo["AtomTypesColorNames"]["OtherAtomsColor"], Enable = False, DisplayAs = None)
  318             OutFH.write("\n%s\n" % PML)
  319         
  320         if GetChainAloneSurfaceChainElectrostaticsStatus(FileIndex, ChainID):
  321             # Setup electrostatics surface...
  322             SelectionObjectName = ChainName
  323             ElectrostaticsGroupName = PyMOLObjectNames["Chains"][ChainID]["ChainAloneElectrostaticsGroup"]
  324             ElectrostaticsGroupMembers = PyMOLObjectNames["Chains"][ChainID]["ChainAloneElectrostaticsGroupMembers"]
  325             WriteSurfaceElectrostaticsView("Surface", OutFH, SelectionObjectName, ElectrostaticsGroupName, ElectrostaticsGroupMembers, DisplayAs = "cartoon")
  326 
  327         # Setup surface group...
  328         GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainAloneSurfaceGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainAloneSurfaceGroupMembers"], True, "open")
  329         
  330         # Setup disulfide group...
  331         WriteChainAloneDisulfideBondsView(OutFH,  FileIndex, PyMOLObjectNames, ChainID)
  332         
  333         # Setup salt bridges group...
  334         WriteChainAloneSaltBridgesView(OutFH,  FileIndex, PyMOLObjectNames, ChainID)
  335         
  336     # Setup chain group...
  337     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"], True, "close")
  338     
  339 def WriteChainLigandView(OutFH, FileIndex, PyMOLObjectNames, ChainID, LigandID):
  340     """Write out PML for viewing ligand in a chain."""
  341     
  342     for GroupID in ["Ligand", "Pocket", "PocketSolvent", "PocketInorganic"]:
  343         ComplexName = PyMOLObjectNames["Chains"][ChainID]["ChainComplex"]
  344         LigandName = PyMOLObjectNames["Ligands"][ChainID][LigandID]["Ligand"]
  345         
  346         # Setup main object...
  347         GroupTypeObjectID = "%s" % (GroupID)
  348         GroupTypeObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupTypeObjectID]
  349         
  350         if re.match("^Ligand$", GroupID, re.I):
  351             OutFH.write("""\n""\n"Setting up views for ligand %s in chain %s..."\n""\n""" % (LigandID, ChainID))
  352             PML = PyMOLUtil.SetupPMLForLigandView(GroupTypeObjectName, ComplexName, LigandID, Enable = True, IgnoreHydrogens = OptionsInfo["IgnoreHydrogens"])
  353             OutFH.write("%s\n" % PML)
  354         elif re.match("^Pocket$", GroupID, re.I):
  355             OutFH.write("""\n""\n"Setting up views for pocket around ligand %s in chain %s..."\n""\n""" % (LigandID, ChainID))
  356             PML = PyMOLUtil.SetupPMLForLigandPocketView(GroupTypeObjectName, ComplexName, LigandName, OptionsInfo["PocketDistanceCutoff"], Enable = True, IgnoreHydrogens = OptionsInfo["IgnoreHydrogens"])
  357             OutFH.write("%s\n" % PML)
  358             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (OptionsInfo["PocketLabelColor"], GroupTypeObjectName))
  359         elif re.match("^PocketSolvent$", GroupID, re.I):
  360             OutFH.write("""\n""\n"Setting up views for solvent in pockect around ligand %s in chain %s..."\n""\n""" % (LigandID, ChainID))
  361             PML = PyMOLUtil.SetupPMLForLigandPocketSolventView(GroupTypeObjectName, ComplexName, LigandName, OptionsInfo["PocketDistanceCutoff"], Enable = True)
  362             OutFH.write("%s\n" % PML)
  363         elif re.match("^PocketInorganic$", GroupID, re.I):
  364             OutFH.write("""\n""\n"Setting up views for inorganic in pockect around ligand %s in chain %s..."\n""\n""" % (LigandID, ChainID))
  365             PML = PyMOLUtil.SetupPMLForLigandPocketInorganicView(GroupTypeObjectName, ComplexName, LigandName, OptionsInfo["PocketDistanceCutoff"], Enable = True)
  366             OutFH.write("%s\n" % PML)
  367         
  368         # Set up polar contacts...
  369         if re.match("^(Pocket|PocketSolvent|PocketInorganic)$", GroupID, re.I):
  370             PolarContactsID = "%sPolarContacts" % (GroupID)
  371             PolarContactsName = PyMOLObjectNames["Ligands"][ChainID][LigandID][PolarContactsID]
  372             
  373             PolarContactsColor = OptionsInfo["PocketContactsLigandColor"]
  374             if re.match("^PocketSolvent$", GroupID, re.I):
  375                 PolarContactsColor = OptionsInfo["PocketContactsSolventColor"]
  376             elif re.match("^PocketInorganic$", GroupID, re.I):
  377                 PolarContactsColor = OptionsInfo["PocketContactsInorganicColor"]
  378 
  379             PML = PyMOLUtil.SetupPMLForPolarContactsView(PolarContactsName, LigandName, GroupTypeObjectName, Enable = False, Color = PolarContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  380             OutFH.write("\n%s\n" % PML)
  381             
  382             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (PolarContactsColor, PolarContactsName))
  383             
  384         if re.match("^PocketInorganic$", GroupID, re.I):
  385             # Setup pi cation contacts...
  386             PiCationContactsID = "%sPiCationContacts" % (GroupID)
  387             PiCationContactsName = PyMOLObjectNames["Ligands"][ChainID][LigandID][PiCationContactsID]
  388             PiCationContactsColor = OptionsInfo["PocketContactsInorganicPiCationColor"]
  389 
  390             PML = PyMOLUtil.SetupPMLForPiCationContactsView(PiCationContactsName, LigandName, GroupTypeObjectName, Enable = False, Color = PiCationContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  391             OutFH.write("\n%s\n" % PML)
  392             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (PiCationContactsColor, PiCationContactsName))
  393             
  394         if re.match("^Pocket$", GroupID, re.I):
  395             # Setup hydrophobic contacts...
  396             HydrophobicContactsID = "%sHydrophobicContacts" % (GroupID)
  397             HydrophobicContactsName = PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicContactsID]
  398             HydrophobicContactsColor = OptionsInfo["PocketContactsLigandHydrophobicColor"]
  399             
  400             PML = PyMOLUtil.SetupPMLForHydrophobicContactsView(HydrophobicContactsName, LigandName, GroupTypeObjectName, Enable = False, Color = HydrophobicContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  401             OutFH.write("\n%s\n" % PML)
  402             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (HydrophobicContactsColor, HydrophobicContactsName))
  403 
  404             # Setup pi pi contacts...
  405             PiPiContactsID = "%sPiPiContacts" % (GroupID)
  406             PiPiContactsName = PyMOLObjectNames["Ligands"][ChainID][LigandID][PiPiContactsID]
  407             PiPiContactsColor = OptionsInfo["PocketContactsLigandPiPiColor"]
  408 
  409             PML = PyMOLUtil.SetupPMLForPiPiContactsView(PiPiContactsName, LigandName, GroupTypeObjectName, Enable = False, Color = PiPiContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  410             OutFH.write("\n%s\n" % PML)
  411             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (PiPiContactsColor, PiPiContactsName))
  412             
  413             # Setup pi cation contacts...
  414             PiCationContactsID = "%sPiCationContacts" % (GroupID)
  415             PiCationContactsName = PyMOLObjectNames["Ligands"][ChainID][LigandID][PiCationContactsID]
  416             PiCationContactsColor = OptionsInfo["PocketContactsLigandPiCationColor"]
  417 
  418             PML = PyMOLUtil.SetupPMLForPiCationContactsView(PiCationContactsName, LigandName, GroupTypeObjectName, Enable = False, Color = PiCationContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  419             OutFH.write("\n%s\n" % PML)
  420             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (PiCationContactsColor, PiCationContactsName))
  421 
  422             # Setup halogen contacts...
  423             HalogenContactsID = "%sHalogenContacts" % (GroupID)
  424             HalogenContactsName = PyMOLObjectNames["Ligands"][ChainID][LigandID][HalogenContactsID]
  425             HalogenContactsColor = OptionsInfo["PocketContactsLigandHalogenColor"]
  426 
  427             PML = PyMOLUtil.SetupPMLForHalogenContactsView(HalogenContactsName, LigandName, GroupTypeObjectName, Enable = False, Color = HalogenContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  428             OutFH.write("\n%s\n" % PML)
  429             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (HalogenContactsColor, HalogenContactsName))
  430 
  431             # Setup pocket selections...
  432             WritePocketSelectionsView(OutFH,  FileIndex, PyMOLObjectNames, ChainID, LigandID, GroupTypeObjectID)
  433             
  434             # Setup pocket residues...
  435             WritePocketResidueTypesView(OutFH,  FileIndex, PyMOLObjectNames, ChainID, LigandID, GroupTypeObjectID)
  436             WritePocketSurfacesTypesView(OutFH,  FileIndex, PyMOLObjectNames, ChainID, LigandID, GroupTypeObjectID)
  437         
  438         if re.match("^Ligand$", GroupID, re.I):
  439             # Setup ball and stick view...
  440             BallAndStickNameID = "%sBallAndStick" % (GroupID)
  441             BallAndStickName = PyMOLObjectNames["Ligands"][ChainID][LigandID][BallAndStickNameID]
  442             PML = PyMOLUtil.SetupPMLForBallAndStickView(BallAndStickName, GroupTypeObjectName, Enable = False)
  443             OutFH.write("\n%s\n" % PML)
  444             
  445         # Setup group...
  446         GroupNameID = "%sGroup" % (GroupID)
  447         GroupMembersID = "%sGroupMembers" % (GroupID)
  448         GroupName = PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupNameID]
  449         GroupMembers = PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID]
  450 
  451         Action = "close"
  452         Enable = False
  453         if  re.match("^(Ligand|Pocket)$", GroupID, re.I):
  454             Action = "open"
  455             Enable = True
  456         GenerateAndWritePMLForGroup(OutFH, GroupName, GroupMembers, Enable, Action)
  457 
  458 def WriteChainDockedPosesView(OutFH, FileIndex, PyMOLObjectNames, ChainID):
  459     """Write out PML for viewing docked poses for input files in a chain."""
  460 
  461     if not GetChainAloneDockedPosesStatus(FileIndex, ChainID):
  462         return
  463     
  464     SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
  465     for InputFileIndex, InputFile in enumerate(SpecifiedChainsAndLigandsInfo["DockedPosesInputFiles"][ChainID]):
  466         WriteChainDockedPosesViewForInputFile(OutFH, FileIndex, PyMOLObjectNames, ChainID, InputFileIndex)
  467 
  468     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["DockedPosesGroup"], PyMOLObjectNames["Chains"][ChainID]["DockedPosesGroupMembers"], False, "close")
  469     
  470 def WriteChainDockedPosesViewForInputFile(OutFH, PDBFileIndex, PyMOLObjectNames, ChainID, InputFileIndex):
  471     """Write out PML for viewing docked poses for an input file in a chain."""
  472 
  473     DockedPosesInfo = OptionsInfo["DockedPosesInfo"]
  474     DockedPosesDistanceContactsInfo = OptionsInfo["DockedPosesDistanceContactsInfo"]
  475     
  476     LigandID = DockedPosesInfo["LigandID"][PDBFileIndex]
  477     UseInputFileAsLigandID = DockedPosesInfo["UseInputFileAsLigandID"][PDBFileIndex]
  478     InputFile = DockedPosesInfo["InputFiles"][PDBFileIndex][InputFileIndex]
  479     InputFileID = DockedPosesInfo["InputFilesIDs"][PDBFileIndex][InputFileIndex]
  480 
  481     OutFH.write("""\n""\n"Setting up views for docked poses in input file ID %s for chain %s..."\n""\n""" % (InputFileID, ChainID))
  482     
  483     # Setup poses view...
  484     PosesName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID]["Poses"]
  485     PML = PyMOLUtil.SetupPMLForLigandsInputFileView(PosesName, InputFile, Enable = True, IgnoreHydrogens = OptionsInfo["IgnoreHydrogens"])
  486     OutFH.write("%s\n" % PML)
  487 
  488     for GroupID in ["Pocket", "PocketSolvent", "PocketInorganic"]:
  489         ComplexName = PyMOLObjectNames["Chains"][ChainID]["ChainComplex"]
  490         LigandName = PosesName if UseInputFileAsLigandID else PyMOLObjectNames["Ligands"][ChainID][LigandID]["Ligand"]
  491         
  492         # Setup  pocket object...
  493         PocketID = "%sPocket" % (GroupID)
  494         PocketName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][PocketID]
  495         
  496         if re.match("^Pocket$", GroupID, re.I):
  497             PML = PyMOLUtil.SetupPMLForLigandPocketView(PocketName, ComplexName, LigandName, OptionsInfo["PocketDistanceCutoff"], Enable = True, IgnoreHydrogens = OptionsInfo["IgnoreHydrogens"])
  498             OutFH.write("%s\n" % PML)
  499             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (OptionsInfo["PocketLabelColor"], PocketName))
  500         elif re.match("^PocketSolvent$", GroupID, re.I):
  501             PML = PyMOLUtil.SetupPMLForLigandPocketSolventView(PocketName, ComplexName, LigandName, OptionsInfo["PocketDistanceCutoff"], Enable = True)
  502             OutFH.write("%s\n" % PML)
  503         elif re.match("^PocketInorganic$", GroupID, re.I):
  504             PML = PyMOLUtil.SetupPMLForLigandPocketInorganicView(PocketName, ComplexName, LigandName, OptionsInfo["PocketDistanceCutoff"], Enable = True)
  505             OutFH.write("%s\n" % PML)
  506 
  507         if DockedPosesInfo["DistanceContacts"] and re.match("^Pocket$", GroupID, re.I):
  508             # Setup distance contacts...
  509             for ContactIndex, ContactID in enumerate(DockedPosesDistanceContactsInfo["ContactIDs"]):
  510                 ContactCutoff = DockedPosesDistanceContactsInfo["ContactCutoff"][ContactID]
  511                 
  512                 DistanceContactID = "%sPocketDistanceContacts%s" % (GroupID, ContactID)
  513                 DistanceContactName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][DistanceContactID]
  514                 
  515                 DistanceContactsColor = OptionsInfo["DockedPosesDistanceContactsColor"]
  516                 EnableContact = True if ContactIndex == 0 else False
  517                 PML = PyMOLUtil.SetupPMLForDistanceContactsView(DistanceContactName, PosesName, PocketName, Enable = EnableContact, Color = DistanceContactsColor, Cutoff = ContactCutoff, IgnoreHydrogens = True)
  518                 OutFH.write("\n%s\n" % PML)
  519                 
  520                 OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (DistanceContactsColor, DistanceContactName))
  521             
  522             # Setup distance conatcts group...
  523             DistanceContactGroupNameID = "%sDistanceContactsGroup" % GroupID
  524             DistanceContactGroupMembersID = "%sDistanceContactsGroupMembers" % GroupID
  525             
  526             GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][DistanceContactGroupNameID], PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][DistanceContactGroupMembersID], True, "open")
  527         
  528         # Setup polar contacts...
  529         if re.match("^(Pocket|PocketSolvent|PocketInorganic)$", GroupID, re.I):
  530             PolarContactsID = "%sPolarContacts" % (GroupID)
  531             PolarContactsName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][PolarContactsID]
  532             
  533             PolarContactsColor = OptionsInfo["PocketContactsLigandColor"]
  534             if re.match("^PocketSolvent$", GroupID, re.I):
  535                 PolarContactsColor = OptionsInfo["PocketContactsSolventColor"]
  536             elif re.match("^PocketInorganic$", GroupID, re.I):
  537                 PolarContactsColor = OptionsInfo["PocketContactsInorganicColor"]
  538             
  539             PML = PyMOLUtil.SetupPMLForPolarContactsView(PolarContactsName, PosesName, PocketName, Enable = False, Color = PolarContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  540             OutFH.write("\n%s\n" % PML)
  541             
  542             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (PolarContactsColor, PolarContactsName))
  543         
  544         if re.match("^PocketInorganic$", GroupID, re.I):
  545             # Setup pi cation contacts...
  546             PiCationContactsID = "%sPiCationContacts" % (GroupID)
  547             PiCationContactsName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][PiCationContactsID]
  548             PiCationContactsColor = OptionsInfo["PocketContactsInorganicPiCationColor"]
  549 
  550             PML = PyMOLUtil.SetupPMLForPiCationContactsView(PiCationContactsName, PosesName, PocketName, Enable = False, Color = PiCationContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  551             OutFH.write("\n%s\n" % PML)
  552             
  553             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (PiCationContactsColor, PiCationContactsName))
  554         
  555         if re.match("^Pocket$", GroupID, re.I):
  556             # Setup hydrophobic contacts...
  557             HydrophobicContactsID = "%sHydrophobicContacts" % (GroupID)
  558             HydrophobicContactsName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][HydrophobicContactsID]
  559             HydrophobicContactsColor = OptionsInfo["PocketContactsLigandHydrophobicColor"]
  560             
  561             PML = PyMOLUtil.SetupPMLForHydrophobicContactsView(HydrophobicContactsName, PosesName, PocketName, Enable = False, Color = HydrophobicContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  562             OutFH.write("\n%s\n" % PML)
  563             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (HydrophobicContactsColor, HydrophobicContactsName))
  564 
  565             # Setup pi pi contacts...
  566             PiPiContactsID = "%sPiPiContacts" % (GroupID)
  567             PiPiContactsName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][PiPiContactsID]
  568             PiPiContactsColor = OptionsInfo["PocketContactsLigandPiPiColor"]
  569             
  570             PML = PyMOLUtil.SetupPMLForPiPiContactsView(PiPiContactsName, PosesName, PocketName, Enable = False, Color = PiPiContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  571             OutFH.write("\n%s\n" % PML)
  572             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (PiPiContactsColor, PiPiContactsName))
  573             
  574             # Setup pi cation contacts...
  575             PiCationContactsID = "%sPiCationContacts" % (GroupID)
  576             PiCationContactsName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][PiCationContactsID]
  577             PiCationContactsColor = OptionsInfo["PocketContactsLigandPiCationColor"]
  578             
  579             PML = PyMOLUtil.SetupPMLForPiCationContactsView(PiCationContactsName, PosesName, PocketName, Enable = False, Color = PiCationContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  580             OutFH.write("\n%s\n" % PML)
  581             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (PiCationContactsColor, PiCationContactsName))
  582             
  583             # Setup halogen contacts...
  584             HalogenContactsID = "%sHalogenContacts" % (GroupID)
  585             HalogenContactsName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][HalogenContactsID]
  586             HalogenContactsColor = OptionsInfo["PocketContactsLigandHalogenColor"]
  587 
  588             PML = PyMOLUtil.SetupPMLForHalogenContactsView(HalogenContactsName, LigandName, PocketName, Enable = False, Color = HalogenContactsColor, Cutoff = OptionsInfo["PocketContactsCutoff"])
  589             OutFH.write("\n%s\n" % PML)
  590             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (HalogenContactsColor, HalogenContactsName))
  591         
  592         
  593         # Setup group for an input file...
  594         GroupNameID = "%sGroup" % (GroupID)
  595         GroupMembersID = "%sGroupMembers" % (GroupID)
  596         Enable = True if re.match("^Pocket$", GroupID, re.I) else False
  597         Action = "open" if re.match("^Pocket$", GroupID, re.I) else "close"
  598         
  599         GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupNameID], PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupMembersID], Enable, Action)
  600     
  601     # Setup docked poses group for an input file...
  602     Action = "open" if InputFileIndex == 0 else "close"
  603     Enable = True if InputFileIndex == 0 else False
  604     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID]["DockedPosesGroupName"], PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID]["DockedPosesGroupMembers"], Enable, Action)
  605     
  606 def WritePocketSelectionsView(OutFH,  FileIndex, PyMOLObjectNames, ChainID, LigandID, PocketObjectID):
  607     """Write out PML for viewing selections for a lgand pocket."""
  608 
  609     if not GetPocketContainsSelectionsStatus(FileIndex, ChainID, LigandID):
  610         return
  611 
  612     PocketObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][PocketObjectID]
  613     SelectionsGroupIDPrefix = "PocketSelectionsGroup"
  614     
  615     for Index in range(0, len(OptionsInfo["PocketChainSelectionsInfo"]["Names"])):
  616         SelectionName = OptionsInfo["PocketChainSelectionsInfo"]["Names"][Index]
  617         Selection = OptionsInfo["PocketChainSelectionsInfo"]["Selections"][Index]
  618         
  619         SelectionNameGroupID = SelectionName
  620         
  621         # Setup a selection object...
  622         SelectionObjectID = "%s%sSelection" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  623         SelectionObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionObjectID]
  624         SelectionCmd = "(%s and (%s))" % (PocketObjectName, Selection)
  625         PML = PyMOLUtil.SetupPMLForSelectionDisplayView(SelectionObjectName, SelectionCmd, OptionsInfo["SelectionsPocketStyle"], Enable = True, IgnoreHydrogens = OptionsInfo["IgnoreHydrogens"])
  626         OutFH.write("\n%s\n" % PML)
  627         
  628         if GetPocketSelectionSurfaceChainStatus(FileIndex, ChainID, LigandID):
  629             # Display style for selection objects in surfaces...
  630             DisplayStyle = "lines"
  631             
  632             # Setup a generic color surface...
  633             SurfaceID = "%s%s%sSurface" % (SelectionsGroupIDPrefix, SelectionNameGroupID, "Surface")
  634             SurfaceName = PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfaceID]
  635             PML = PyMOLUtil.SetupPMLForSurfaceView(SurfaceName, SelectionObjectName, Enable = False, Color = OptionsInfo["SurfaceColor"], DisplayAs = DisplayStyle)
  636             OutFH.write("\n%s\n" % PML)
  637 
  638             # Setup a surface colored by hydrphobicity...
  639             HydrophobicSurfaceID = "%s%sSurfaceHydrophobicity" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  640             HydrophobicSurfaceName = PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicSurfaceID]
  641             PML = PyMOLUtil.SetupPMLForHydrophobicSurfaceView(HydrophobicSurfaceName, SelectionObjectName, ColorPalette = OptionsInfo["SurfaceColorPalette"], Enable = False, DisplayAs = DisplayStyle)
  642             OutFH.write("\n%s\n" % PML)
  643             
  644             # Setup a surface colored by hydrphobicity and charge...
  645             HydrophobicChargeSurfaceID = "%s%sSurfaceHydrophobicityCharge" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  646             HydrophobicChargeSurfaceName = PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicChargeSurfaceID]
  647             PML = PyMOLUtil.SetupPMLForHydrophobicAndChargeSurfaceView(HydrophobicChargeSurfaceName, SelectionObjectName,  OptionsInfo["AtomTypesColorNames"]["HydrophobicAtomsColor"], OptionsInfo["AtomTypesColorNames"]["NegativelyChargedAtomsColor"], OptionsInfo["AtomTypesColorNames"]["PositivelyChargedAtomsColor"], OptionsInfo["AtomTypesColorNames"]["OtherAtomsColor"], Enable = False, DisplayAs = DisplayStyle)
  648             OutFH.write("\n%s\n" % PML)
  649     
  650             # Setup group for surfaces...
  651             SurfaceGroupID = "%s%sSurfaceGroup" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  652             SurfaceGroupMembersID = "%s%sSurfaceGroupMembers" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  653             GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfaceGroupID], PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfaceGroupMembersID], True, "open")
  654             
  655         # Setup groups for named selections...
  656         SelectionsNameGroupID = "%s%sGroup" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  657         SelectionsNameGroupMembersID = "%s%sGroupMembers" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  658         GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsNameGroupID], PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsNameGroupMembersID], True, "open")
  659 
  660     # Setup a group for selections...
  661     SelectionsGroupID = "%s" % (SelectionsGroupIDPrefix)
  662     SelectionsGroupMembersID = "%sGroupMembers" % (SelectionsGroupIDPrefix)
  663     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsGroupID], PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsGroupMembersID], True, "close")
  664     
  665 def WritePocketSurfacesTypesView(OutFH,  FileIndex, PyMOLObjectNames, ChainID, LigandID, PocketObjectID):
  666     """Write out PML for viewing surfaces for a ligand pocket."""
  667 
  668     if not GetPocketContainsSurfaceStatus(FileIndex, ChainID, LigandID):
  669         return
  670     
  671     PocketObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][PocketObjectID]
  672     
  673     SurfacesGroupID = "%sSurfacesGroup" % (PocketObjectID)
  674     SurfacesGroupMembersID = "%sSurfacesGroupMembers" % (PocketObjectID)
  675 
  676     # Cavity modes: 1 or 2.  1: Cavity surfaces; 2: Culled cavity surfaces...
  677     CavityMode = 2
  678     
  679     # Setup surfaces subgroup and its members...
  680     for SubGroupType in ["Surface", "Cavity"]:
  681         ProcessingCavity = True if re.match("^Cavity$", SubGroupType, re.I) else False
  682         
  683         SubGroupID = re.sub("_", "", SubGroupType)
  684         SurfacesSubGroupID = "%s%sGroup" % (SurfacesGroupID, SubGroupID)
  685         SurfacesSubGroupMembersID = "%sMembers" % (SurfacesSubGroupID)
  686 
  687         # Turn off lines display for cavity surfaces...
  688         DisplayStyle = None if ProcessingCavity else "lines"
  689 
  690         # Setup a generic color surface...
  691         SurfaceID = "%sSurface" % (SurfacesSubGroupID)
  692         SurfaceName = PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfaceID]
  693         PML = PyMOLUtil.SetupPMLForSurfaceView(SurfaceName, PocketObjectName, Enable = False, Color = OptionsInfo["SurfaceColor"], DisplayAs = DisplayStyle)
  694         OutFH.write("\n%s\n" % PML)
  695         
  696         if ProcessingCavity:
  697             OutFH.write("""cmd.set("surface_cavity_mode", %d, "%s")\n""" % (CavityMode, SurfaceName))
  698         
  699         OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (OptionsInfo["PocketLabelColor"], SurfaceName))
  700         
  701         if GetPocketSurfaceChainStatus(FileIndex, ChainID, LigandID):
  702             # Setup a surface colored by hydrphobicity...
  703             HydrophobicSurfaceID = "%sHydrophobicSurface" % (SurfacesSubGroupID)
  704             HydrophobicSurfaceName = PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicSurfaceID]
  705             PML = PyMOLUtil.SetupPMLForHydrophobicSurfaceView(HydrophobicSurfaceName, PocketObjectName, ColorPalette = OptionsInfo["SurfaceColorPalette"], Enable = False, DisplayAs = DisplayStyle)
  706             OutFH.write("\n%s\n" % PML)
  707             
  708             if ProcessingCavity:
  709                 OutFH.write("""cmd.set("surface_cavity_mode", %d, "%s")\n""" % (CavityMode, HydrophobicSurfaceName))
  710             
  711             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (OptionsInfo["PocketLabelColor"], HydrophobicSurfaceName))
  712             
  713             # Setup a surface colored by hydrphobicity and charge...
  714             HydrophobicChargeSurfaceID = "%sHydrophobicChargeSurface" % (SurfacesSubGroupID)
  715             HydrophobicChargeSurfaceName = PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicChargeSurfaceID]
  716             PML = PyMOLUtil.SetupPMLForHydrophobicAndChargeSurfaceView(HydrophobicChargeSurfaceName, PocketObjectName,  OptionsInfo["AtomTypesColorNames"]["HydrophobicAtomsColor"], OptionsInfo["AtomTypesColorNames"]["NegativelyChargedAtomsColor"], OptionsInfo["AtomTypesColorNames"]["PositivelyChargedAtomsColor"], OptionsInfo["AtomTypesColorNames"]["OtherAtomsColor"], Enable = False, DisplayAs = DisplayStyle)
  717             OutFH.write("\n%s\n" % PML)
  718             
  719             if ProcessingCavity:
  720                 OutFH.write("""cmd.set("surface_cavity_mode", %d, "%s")\n""" % (CavityMode, HydrophobicChargeSurfaceName))
  721             
  722             OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (OptionsInfo["PocketLabelColor"], HydrophobicChargeSurfaceName))
  723             
  724             if GetPocketSurfaceChainElectrostaticsStatus(FileIndex, ChainID, LigandID):
  725                 # Set up a electrostatics surface...
  726                 ElectrostaticsGroupID = "%sElectrostaticsGroup" % (SurfacesSubGroupID)
  727                 ElectrostaticsGroupMembersID = "%sElectrostaticsGroupMembers" % (SurfacesSubGroupID)
  728                 ElectrostaticsGroupName = PyMOLObjectNames["Ligands"][ChainID][LigandID][ElectrostaticsGroupID]
  729                 ElectrostaticsGroupMembers = PyMOLObjectNames["Ligands"][ChainID][LigandID][ElectrostaticsGroupMembersID]
  730                 WriteSurfaceElectrostaticsView(SubGroupType, OutFH, PocketObjectName, ElectrostaticsGroupName, ElectrostaticsGroupMembers, DisplayAs = DisplayStyle, SurfaceCavityMode = CavityMode)
  731                 
  732             # Setup surfaces sub group...
  733             GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesSubGroupID], PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesSubGroupMembersID], True, "open")
  734         
  735     # Setup surface group...
  736     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesGroupID], PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesGroupMembersID], True, "open")
  737     
  738 def WritePocketResidueTypesView(OutFH,  FileIndex, PyMOLObjectNames, ChainID, LigandID, PocketObjectID):
  739     """Write out PML for viewing residue types for a ligand pocket."""
  740     
  741     if not GetPocketResidueTypesStatus(FileIndex, ChainID, LigandID):
  742         return
  743 
  744     PocketObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][PocketObjectID]
  745     
  746     ResiduesGroupID = "%sResiduesGroup" % (PocketObjectID)
  747     ResiduesGroupMembersID = "%sMembers" % (ResiduesGroupID)
  748     
  749     # Setup residue types objects...
  750     for SubGroupType in ["Aromatic", "Hydrophobic", "Polar", "Positively_Charged", "Negatively_Charged", "Other"]:
  751         SubGroupID = re.sub("_", "", SubGroupType)
  752         
  753         ResiduesSubGroupID = "%s%sGroup" % (ResiduesGroupID, SubGroupID)
  754         ResiduesSubMembersGroupID = "%sMembers" % (ResiduesSubGroupID)
  755     
  756         SubGroupMemberID = "%sResidues" % (ResiduesSubGroupID)
  757         ResiduesObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][SubGroupMemberID]
  758 
  759         SubGroupMemberID = "%sSurface" % (ResiduesSubGroupID)
  760         ResiduesSurfaceObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][SubGroupMemberID]
  761 
  762         ResiduesColor = OptionsInfo["ResidueTypesParams"][SubGroupType]["Color"] 
  763         ResiduesNames = OptionsInfo["ResidueTypesParams"][SubGroupType]["Residues"]
  764 
  765         NegateResidueNames = True if re.match("^Other$", SubGroupType, re.I) else False
  766         WriteResidueTypesResiduesAndSurfaceView(OutFH, PocketObjectName, ResiduesObjectName, ResiduesSurfaceObjectName, ResiduesColor, ResiduesNames, NegateResidueNames)
  767         
  768         # Setup residue type sub groups...
  769         GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesSubGroupID], PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesSubMembersGroupID], True, "close")
  770     
  771     # Setup residue types group...
  772     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesGroupID], PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesGroupMembersID], False, "close")
  773 
  774 def WriteChainAloneChainSelectionsView(OutFH,  FileIndex, PyMOLObjectNames, ChainID):
  775     """Write out PML for viewing selections for a chain."""
  776 
  777     if not GetChainAloneContainsSelectionsStatus(FileIndex, ChainID):
  778         return
  779     
  780     ChainName = PyMOLObjectNames["Chains"][ChainID]["ChainAlone"]
  781     SelectionsGroupIDPrefix = "ChainAloneSelections"
  782     
  783     for Index in range(0, len(OptionsInfo["ChainSelectionsInfo"]["Names"])):
  784         SelectionName = OptionsInfo["ChainSelectionsInfo"]["Names"][Index]
  785         Selection = OptionsInfo["ChainSelectionsInfo"]["Selections"][Index]
  786         
  787         SelectionNameGroupID = SelectionName
  788         
  789         # Setup a selection object...
  790         SelectionObjectID = "%s%sSelection" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  791         SelectionObjectName = PyMOLObjectNames["Chains"][ChainID][SelectionObjectID]
  792         SelectionCmd = "(%s and (%s))" % (ChainName, Selection)
  793         PML = PyMOLUtil.SetupPMLForSelectionDisplayView(SelectionObjectName, SelectionCmd, OptionsInfo["SelectionsChainStyle"], Enable = True, IgnoreHydrogens = OptionsInfo["IgnoreHydrogens"])
  794         OutFH.write("\n%s\n" % PML)
  795         
  796         if GetChainAloneContainsChainSelectionSurfacesStatus(FileIndex, ChainID):
  797             # Display style for selection objects in surfaces...
  798             DisplayStyle = "lines"
  799             
  800             # Setup a generic color surface...
  801             SurfaceID = "%s%s%sSurface" % (SelectionsGroupIDPrefix, SelectionNameGroupID, "Surface")
  802             SurfaceName = PyMOLObjectNames["Chains"][ChainID][SurfaceID]
  803             PML = PyMOLUtil.SetupPMLForSurfaceView(SurfaceName, SelectionObjectName, Enable = False, Color = OptionsInfo["SurfaceColor"], DisplayAs = DisplayStyle)
  804             OutFH.write("\n%s\n" % PML)
  805             
  806             if GetChainAloneSurfaceChainSelectionStatus(FileIndex, ChainID):
  807                 # Setup a surface colored by hydrphobicity...
  808                 HydrophobicSurfaceID = "%s%sSurfaceHydrophobicity" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  809                 HydrophobicSurfaceName = PyMOLObjectNames["Chains"][ChainID][HydrophobicSurfaceID]
  810                 PML = PyMOLUtil.SetupPMLForHydrophobicSurfaceView(HydrophobicSurfaceName, SelectionObjectName, ColorPalette = OptionsInfo["SurfaceColorPalette"], Enable = False, DisplayAs = DisplayStyle)
  811                 OutFH.write("\n%s\n" % PML)
  812                 
  813                 # Setup a surface colored by hydrphobicity and charge...
  814                 HydrophobicChargeSurfaceID = "%s%sSurfaceHydrophobicityCharge" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  815                 HydrophobicChargeSurfaceName = PyMOLObjectNames["Chains"][ChainID][HydrophobicChargeSurfaceID]
  816                 PML = PyMOLUtil.SetupPMLForHydrophobicAndChargeSurfaceView(HydrophobicChargeSurfaceName, SelectionObjectName,  OptionsInfo["AtomTypesColorNames"]["HydrophobicAtomsColor"], OptionsInfo["AtomTypesColorNames"]["NegativelyChargedAtomsColor"], OptionsInfo["AtomTypesColorNames"]["PositivelyChargedAtomsColor"], OptionsInfo["AtomTypesColorNames"]["OtherAtomsColor"], Enable = False, DisplayAs = DisplayStyle)
  817                 OutFH.write("\n%s\n" % PML)
  818 
  819             # Setup group for surfaces...
  820             SurfaceGroupID = "%s%sSurfaceGroup" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  821             SurfaceGroupMembersID = "%s%sSurfaceGroupMembers" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  822             GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID][SurfaceGroupID], PyMOLObjectNames["Chains"][ChainID][SurfaceGroupMembersID], True, "close")
  823 
  824         # Setup groups for named selections...
  825         SelectionsNameGroupID = "%s%sGroup" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  826         SelectionsNameGroupMembersID = "%s%sGroupMembers" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
  827         GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID][SelectionsNameGroupID], PyMOLObjectNames["Chains"][ChainID][SelectionsNameGroupMembersID], True, "open")
  828 
  829     # Setup a group for selections...
  830     SelectionsGroupID = "%sGroup" % (SelectionsGroupIDPrefix)
  831     SelectionsGroupMembersID = "%sGroupMembers" % (SelectionsGroupIDPrefix)
  832     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID][SelectionsGroupID], PyMOLObjectNames["Chains"][ChainID][SelectionsGroupMembersID], False, "close")
  833     
  834 def WriteChainAloneResidueTypesView(OutFH,  FileIndex, PyMOLObjectNames, ChainID):
  835     """Write out PML for viewing residue types for a chain."""
  836 
  837     if not GetChainAloneResidueTypesStatus(FileIndex, ChainID):
  838         return
  839     
  840     ChainName = PyMOLObjectNames["Chains"][ChainID]["ChainAlone"]
  841     
  842     # Setup residue types objects...
  843     ResiduesGroupIDPrefix = "ChainAloneResidues"
  844     for SubGroupType in ["Aromatic", "Hydrophobic", "Polar", "Positively_Charged", "Negatively_Charged", "Other"]:
  845         SubGroupID = re.sub("_", "", SubGroupType)
  846 
  847         ResiduesObjectID = "%s%sResidues" % (ResiduesGroupIDPrefix, SubGroupID)
  848         ResiduesObjectName = PyMOLObjectNames["Chains"][ChainID][ResiduesObjectID]
  849 
  850         ResiduesSurfaceObjectID = "%s%sSurface" % (ResiduesGroupIDPrefix, SubGroupID)
  851         ResiduesSurfaceObjectName = PyMOLObjectNames["Chains"][ChainID][ResiduesSurfaceObjectID]
  852 
  853         ResiduesColor = OptionsInfo["ResidueTypesParams"][SubGroupType]["Color"] 
  854         ResiduesNames = OptionsInfo["ResidueTypesParams"][SubGroupType]["Residues"]
  855 
  856         NegateResidueNames = True if re.match("^Other$", SubGroupType, re.I) else False
  857         WriteResidueTypesResiduesAndSurfaceView(OutFH, ChainName, ResiduesObjectName, ResiduesSurfaceObjectName, ResiduesColor, ResiduesNames, NegateResidueNames)
  858 
  859         # Setup sub groups for residue types..
  860         ResiduesSubGroupID = "%s%sGroup" % (ResiduesGroupIDPrefix, SubGroupID)
  861         ResiduesSubGroupMembersID = "%s%sGroupMembers" % (ResiduesGroupIDPrefix, SubGroupID)
  862 
  863         # Setup residue type sub groups...
  864         GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID][ResiduesSubGroupID], PyMOLObjectNames["Chains"][ChainID][ResiduesSubGroupMembersID], True, "close")
  865         
  866     # Setup residue types group...
  867     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainAloneResiduesGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainAloneResiduesGroupMembers"], False, "close")
  868 
  869 def WriteChainAloneBFactorViews(OutFH,  FileIndex, PyMOLObjectNames, ChainID):
  870     """Write out PML for viewing B factor values for a chain."""
  871 
  872     if not GetChainAloneBFactorStatus(FileIndex, ChainID):
  873         return
  874     
  875     ChainName = PyMOLObjectNames["Chains"][ChainID]["ChainAlone"]
  876 
  877     # Setup cartoon...
  878     Name = PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorCartoon"]
  879     PML = PyMOLUtil.SetupPMLForBFactorCartoonView(Name, ChainName, ColorPalette = OptionsInfo["BFactorColorPalette"], Enable = False)
  880     OutFH.write("\n%s\n" % PML)
  881     
  882     # Setup putty...
  883     Name = PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorPutty"]
  884     PML = PyMOLUtil.SetupPMLForBFactorPuttyView(Name, ChainName, ColorPalette = OptionsInfo["BFactorColorPalette"], Enable = True)
  885     OutFH.write("\n%s\n" % PML)
  886 
  887     # Setup B factor group...
  888     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorGroupMembers"], False, "close")
  889     
  890 
  891 def WriteChainAloneDisulfideBondsView(OutFH,  FileIndex, PyMOLObjectNames, ChainID):
  892     """Write out PML for viewing disulfide bonds for a chain."""
  893 
  894     if not GetChainAloneDisulfideBondsStatus(FileIndex, ChainID):
  895         return
  896 
  897     ChainName = PyMOLObjectNames["Chains"][ChainID]["ChainAlone"]
  898     Name = PyMOLObjectNames["Chains"][ChainID]["ChainAloneDisulfideBondsResidues"]
  899     
  900     PML = PyMOLUtil.SetupPMLForDisulfideBondsView(Name, ChainName, "sticks", Enable = True)
  901     OutFH.write("\n%s\n" % PML)
  902     
  903     # Setup disulfide bonds group...
  904     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainAloneDisulfideBondsGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainAloneDisulfideBondsGroupMembers"], True, "close")
  905 
  906 def WriteChainAloneSaltBridgesView(OutFH,  FileIndex, PyMOLObjectNames, ChainID):
  907     """Write out PML for viewing salt bridges for a chain."""
  908 
  909     if not GetChainAloneSaltBridgesStatus(FileIndex, ChainID):
  910         return
  911 
  912     ChainName = PyMOLObjectNames["Chains"][ChainID]["ChainAlone"]
  913 
  914     # Seup salt bridges resiudes group...
  915     PositivelyChargedResiduesName = PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesPositivelyCharged"]
  916     PML = PyMOLUtil.SetupPMLForSaltBridgesResiduesView(PositivelyChargedResiduesName, ChainName, OptionsInfo["SaltBridgesChainResiduesInfo"]["Positively_Charged"], "lines", Enable = True)
  917     OutFH.write("\n%s\n" % PML)
  918     
  919     NegativelyChargedResiduesName = PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesNegativelyCharged"]
  920     PML = PyMOLUtil.SetupPMLForSaltBridgesResiduesView(NegativelyChargedResiduesName, ChainName, OptionsInfo["SaltBridgesChainResiduesInfo"]["Negatively_Charged"], "lines", Enable = True)
  921     OutFH.write("\n%s\n" % PML)
  922     
  923     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesGroupMembers"], True, "open")
  924 
  925     # Setup salt bridges contacts...
  926     ContactsColor = OptionsInfo["SaltBridgesChainContactsColor"]
  927     ContactsName = PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesContacts"]
  928     PML = PyMOLUtil.SetupPMLForPolarContactsView(ContactsName, PositivelyChargedResiduesName, NegativelyChargedResiduesName, Enable = True, Color = ContactsColor, Cutoff = OptionsInfo["SaltBridgesChainCutoff"])
  929     OutFH.write("\n%s\n" % PML)
  930     
  931     OutFH.write("""cmd.set("label_color", "%s", "%s")\n""" % (ContactsColor, ContactsName))
  932     
  933     # Setup salt bridges group...
  934     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesGroup"], PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesGroupMembers"], False, "close")
  935 
  936 def WriteResidueTypesResiduesAndSurfaceView(OutFH, SelectionObjectName, Name, SurfaceName, ResiduesColor, ResiduesNames, NegateResidueNames):
  937     """Write residue types residues and surface view."""
  938 
  939     ResidueNamesSelection = "+".join(ResiduesNames)
  940     if NegateResidueNames:
  941         Selection = "%s and (not resn %s)" % (SelectionObjectName, ResidueNamesSelection)
  942     else:
  943         Selection = "%s and (resn %s)" % (SelectionObjectName, ResidueNamesSelection)
  944 
  945     # Setup residues...
  946     PML = PyMOLUtil.SetupPMLForSelectionDisplayView(Name, Selection, "lines", ResiduesColor, True, IgnoreHydrogens = OptionsInfo["IgnoreHydrogens"])
  947     OutFH.write("\n%s\n" % PML)
  948 
  949     # Setup surface...
  950     PML = PyMOLUtil.SetupPMLForSelectionDisplayView(SurfaceName, Selection, "surface", ResiduesColor, True, IgnoreHydrogens = OptionsInfo["IgnoreHydrogens"])
  951     OutFH.write("\n%s\n" % PML)
  952     
  953 def WriteSurfaceElectrostaticsView(Mode, OutFH, SelectionObjectName, ElectrostaticsGroupName, ElectrostaticsGroupMembers, DisplayAs = None, SurfaceCavityMode = 2):
  954     """Write out PML for viewing surface electrostatics."""
  955 
  956     if len(ElectrostaticsGroupMembers) == 5:
  957         Name, ContactPotentialName, MapName, LegendName, VolumeName = ElectrostaticsGroupMembers
  958     else:
  959         Name, ContactPotentialName, MapName, LegendName = ElectrostaticsGroupMembers
  960         VolumeName = None
  961 
  962     PMLCmds = []
  963 
  964     # Setup chain...
  965     PMLCmds.append("""cmd.create("%s", "(%s)")""" % (Name, SelectionObjectName))
  966 
  967     # Setup vacuum electrostatics surface along with associated objects...
  968     PMLCmds.append("""util.protein_vacuum_esp("%s", mode=2, quiet=0, _self=cmd)""" % (Name))
  969     PMLCmds.append("""cmd.set_name("%s_e_chg", "%s")""" % (Name, ContactPotentialName))
  970     
  971     if DisplayAs is not None:
  972         PMLCmds.append("""cmd.show("%s", "(%s)")""" % (DisplayAs, ContactPotentialName))
  973 
  974     if re.match("^Cavity$", Mode, re.I):
  975         if SurfaceCavityMode is not None:
  976             PMLCmds.append("""cmd.set("surface_cavity_mode", %d, "%s")\n""" % (SurfaceCavityMode, ContactPotentialName))
  977         
  978     PMLCmds.append(PyMOLUtil.SetupPMLForEnableDisable(ContactPotentialName, Enable = True))
  979     
  980     PMLCmds.append("""cmd.set_name("%s_e_map", "%s")""" % (Name, MapName))
  981     PMLCmds.append(PyMOLUtil.SetupPMLForEnableDisable(MapName, Enable = False))
  982     
  983     PMLCmds.append("""cmd.set_name("%s_e_pot", "%s")""" % (Name, LegendName))
  984     PMLCmds.append(PyMOLUtil.SetupPMLForEnableDisable(LegendName, Enable = False))
  985 
  986     if VolumeName is not None:
  987         PMLCmds.append("""cmd.volume("%s", "%s", "%s", "(%s)")""" % (VolumeName, MapName, "esp", Name))
  988         PMLCmds.append(PyMOLUtil.SetupPMLForEnableDisable(VolumeName, Enable = False))
  989     
  990     # Delete name and take it out from the group membership. It is
  991     # is already part of ContactPotential object.
  992     PMLCmds.append("""cmd.delete("%s")""" % (Name))
  993     ElectrostaticsGroupMembers.pop(0)
  994     
  995     PML = "\n".join(PMLCmds)
  996     
  997     OutFH.write("\n%s\n" % PML)
  998     
  999     # Setup group...
 1000     GenerateAndWritePMLForGroup(OutFH, ElectrostaticsGroupName, ElectrostaticsGroupMembers, False, "close")
 1001 
 1002 def GenerateAndWritePMLForGroup(OutFH, GroupName, GroupMembers, Enable = False, Action = "close"):
 1003     """Generate and write PML for group."""
 1004     
 1005     PML = PyMOLUtil.SetupPMLForGroup(GroupName, GroupMembers, Enable, Action)
 1006     OutFH.write("""\n""\n"Setting up group %s..."\n""\n""" % GroupName)
 1007     OutFH.write("%s\n" % PML)
 1008 
 1009 def WriteTrajectoriesView(OutFH, FileIndex, PyMOLObjectNames):
 1010     """Write out PML for viewing trajectories for a PDB file."""
 1011     
 1012     if not GetTrajectoriesStatus(FileIndex):
 1013         return
 1014     
 1015     # Setup topology view...
 1016     Name = PyMOLObjectNames["Trajectories"]["Topology"]
 1017     
 1018     PMLCmds = []
 1019     PMLCmds.append("""cmd.load("%s", "%s")""" % (OptionsInfo["InfilesInfo"]["InfilesNames"][FileIndex], Name))
 1020     PMLCmds.append("""cmd.hide("everything", "%s")""" % (Name))
 1021     PMLCmds.append("""cmd.show("cartoon", "%s")""" % (Name))
 1022     PMLCmds.append("""util.cba(33, "%s", _self = cmd)""" % (Name))
 1023     PMLCmds.append("""cmd.show("sticks", "(organic and (%s))")""" % (Name))
 1024     PMLCmds.append("""cmd.hide("(%s and hydro)")""" % (Name))
 1025     PMLCmds.append(PyMOLUtil.SetupPMLForEnableDisable(Name, Enable = False))
 1026     
 1027     PML = "\n".join(PMLCmds)
 1028     OutFH.write("\n%s\n" % PML)
 1029     
 1030     # Write view for each trajectory file...
 1031     for TrajFileIndex, TrajFile in enumerate(OptionsInfo["TrajectoriesInfo"]["TrajFiles"][FileIndex]):
 1032         WriteTrajectoryViewTrajectoryFile(OutFH, FileIndex, PyMOLObjectNames, TrajFileIndex)
 1033     
 1034     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Trajectories"]["TrajectoriesGroup"], PyMOLObjectNames["Trajectories"]["TrajectoriesGroupMembers"], False, "close")
 1035     
 1036 def WriteTrajectoryViewTrajectoryFile(OutFH, PDBFileIndex, PyMOLObjectNames, TrajFileIndex):
 1037     """Write out PML for viewing a trajectory file."""
 1038 
 1039     TrajFile = OptionsInfo["TrajectoriesInfo"]["TrajFiles"][PDBFileIndex][TrajFileIndex]
 1040     TrajFileID = OptionsInfo["TrajectoriesInfo"]["TrajFilesIDs"][PDBFileIndex][TrajFileIndex]
 1041 
 1042     OutFH.write("""\n""\n"Setting up views for trajectory file ID %s..."\n""\n""" % (TrajFileID))
 1043     
 1044     # Setup trajectory view...
 1045     Name = PyMOLObjectNames["Trajectories"][TrajFileID]["Trajectory"]
 1046     PDBFile = OptionsInfo["InfilesInfo"]["InfilesNames"][PDBFileIndex]
 1047     
 1048     PMLCmds = []
 1049     PMLCmds.append("""cmd.load("%s", "%s")""" % (PDBFile, Name))
 1050     PMLCmds.append("""cmd.load_traj("%s", "%s", state = 1)""" % (TrajFile, Name))
 1051     PMLCmds.append("""cmd.hide("everything", "%s")""" % (Name))
 1052     PMLCmds.append("""cmd.show("cartoon", "%s")""" % (Name))
 1053     PMLCmds.append("""util.cba(33, "%s", _self = cmd)""" % (Name))
 1054     PMLCmds.append("""cmd.show("sticks", "(organic and (%s))")""" % (Name))
 1055     PMLCmds.append("""cmd.hide("(%s and hydro)")""" % (Name))
 1056     PMLCmds.append(PyMOLUtil.SetupPMLForEnableDisable(Name, Enable = True))
 1057     
 1058     PML = "\n".join(PMLCmds)
 1059     OutFH.write("%s\n" % PML)
 1060 
 1061     # Setup group for a trajectory file...
 1062     Action = "open" if TrajFileIndex == 0 else "close"
 1063     Enable = True if TrajFileIndex == 0 else False
 1064     GenerateAndWritePMLForGroup(OutFH, PyMOLObjectNames["Trajectories"][TrajFileID]["TrajectoryGroup"], PyMOLObjectNames["Trajectories"][TrajFileID]["TrajectoryGroupMembers"], Enable, Action)
 1065 
 1066 def GeneratePyMOLSessionFile():
 1067     """Generate PME file from PML file."""
 1068 
 1069     PSEOutfile = OptionsInfo["PSEOutfile"]
 1070     PMLOutfile = OptionsInfo["PMLOutfile"]
 1071     
 1072     MiscUtil.PrintInfo("\nGenerating file %s..." % PSEOutfile)
 1073     
 1074     PyMOLUtil.ConvertPMLFileToPSEFile(PMLOutfile, PSEOutfile)
 1075     
 1076     if not os.path.exists(PSEOutfile):
 1077         MiscUtil.PrintWarning("Failed to generate PSE file, %s..." % (PSEOutfile))
 1078     
 1079     if not OptionsInfo["PMLOut"]:
 1080         MiscUtil.PrintInfo("Deleting file %s..." % PMLOutfile)
 1081         os.remove(PMLOutfile)
 1082 
 1083 def DeleteEmptyPyMOLObjects(OutFH, FileIndex, PyMOLObjectNames):
 1084     """Delete empty PyMOL objects."""
 1085     
 1086     if OptionsInfo["AllowEmptyObjects"]:
 1087         return
 1088     
 1089     SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
 1090     for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
 1091         OutFH.write("""\n""\n"Checking and deleting empty objects for chain %s..."\n""\n""" % (ChainID))
 1092         
 1093         # Delete any chain level objects...
 1094         WritePMLToCheckAndDeleteEmptyObjects(OutFH, PyMOLObjectNames["Chains"][ChainID]["Solvent"])
 1095         WritePMLToCheckAndDeleteEmptyObjects(OutFH, PyMOLObjectNames["Chains"][ChainID]["Inorganic"])
 1096 
 1097         # Delete chain selection objects...
 1098         DeleteEmptyChainSelectionsObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID)
 1099         
 1100         # Delete residue type objects...
 1101         DeleteEmptyChainResidueTypesObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID)
 1102         
 1103         # Delete disulfide bonds objects...
 1104         DeleteEmptyChainDisulfideBondsObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID)
 1105         
 1106         # Delete salt bridges objects...
 1107         DeleteEmptyChainSaltBridgesObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID)
 1108 
 1109         # Delete ligand objects...
 1110         for LigandID in SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]:
 1111             # Delete ligand level objects...
 1112             for GroupID in ["Pocket", "PocketSolvent", "PocketInorganic"]:
 1113                 GroupNameID = "%sGroup" % (GroupID)
 1114                 GroupName = PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupNameID]
 1115 
 1116                 GroupTypeObjectID = "%s" % (GroupID)
 1117                 GroupTypeObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupTypeObjectID]
 1118                 
 1119                 WritePMLToCheckAndDeleteEmptyObjects(OutFH, GroupTypeObjectName, GroupName)
 1120                 
 1121                 if re.match("^Pocket$", GroupID, re.I):
 1122                     DeleteEmptyPocketSelectionsObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID, LigandID, GroupTypeObjectID)
 1123                     DeleteEmptyPocketResidueTypesObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID, LigandID, GroupTypeObjectID)
 1124         
 1125         # Delete docked poses objects...
 1126         DeleteEmptyChainDockedPosesObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID)
 1127 
 1128 def DeleteEmptyChainSelectionsObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID):
 1129     """Delete empty chain selection objects """
 1130 
 1131     if not GetChainAloneContainsSelectionsStatus(FileIndex, ChainID):
 1132         return
 1133     
 1134     SelectionsGroupIDPrefix = "ChainAloneSelections"
 1135 
 1136     for SelectionName in OptionsInfo["ChainSelectionsInfo"]["Names"]:
 1137         SelectionNameGroupID = SelectionName
 1138 
 1139         # Delete surface objects and surface group...
 1140         if GetChainAloneContainsChainSelectionSurfacesStatus(FileIndex, ChainID):
 1141             SurfaceGroupID = "%s%sSurfaceGroup" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1142             SurfaceGroupMembersID = "%s%sSurfaceGroupMembers" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1143             WritePMLToCheckAndDeleteEmptyObjects(OutFH, ",".join(PyMOLObjectNames["Chains"][ChainID][SurfaceGroupMembersID]), PyMOLObjectNames["Chains"][ChainID][SurfaceGroupID])
 1144         
 1145         # Delete Selection object and selection name group...
 1146         SelectionObjectID = "%s%sSelection" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1147         SelectionsGroupID = "%s%sGroup" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1148         WritePMLToCheckAndDeleteEmptyObjects(OutFH, PyMOLObjectNames["Chains"][ChainID][SelectionObjectID], PyMOLObjectNames["Chains"][ChainID][SelectionsGroupID])
 1149 
 1150 def DeleteEmptyChainResidueTypesObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID):
 1151     """Delete empty chain residue objects."""
 1152     
 1153     if not GetChainAloneResidueTypesStatus(FileIndex, ChainID):
 1154         return
 1155     
 1156     ResiduesGroupIDPrefix = "ChainAloneResidues"
 1157     for GroupType in ["Aromatic", "Hydrophobic", "Polar", "Positively_Charged", "Negatively_Charged", "Other"]:
 1158         GroupID = re.sub("_", "", GroupType)
 1159         
 1160         ResiduesGroupID = "%s%sGroup" % (ResiduesGroupIDPrefix, GroupID)
 1161         GroupName = PyMOLObjectNames["Chains"][ChainID][ResiduesGroupID]
 1162         
 1163         GroupObjectNamesList = []
 1164         
 1165         ResiduesObjectID = "%s%sResidues" % (ResiduesGroupIDPrefix, GroupID)
 1166         ResiduesObjectName = PyMOLObjectNames["Chains"][ChainID][ResiduesObjectID]
 1167         GroupObjectNamesList.append(ResiduesObjectName)
 1168         
 1169         ResiduesSurfaceObjectID = "%s%sSurface" % (ResiduesGroupIDPrefix, GroupID)
 1170         ResiduesSurfaceObjectName = PyMOLObjectNames["Chains"][ChainID][ResiduesSurfaceObjectID]
 1171         GroupObjectNamesList.append(ResiduesSurfaceObjectName)
 1172         
 1173         GroupObjectNames = ",".join(GroupObjectNamesList)
 1174         WritePMLToCheckAndDeleteEmptyObjects(OutFH, GroupObjectNames, GroupName)
 1175 
 1176 def DeleteEmptyChainDisulfideBondsObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID):
 1177     """Delete empty chain disulfide bonds objects."""
 1178 
 1179     if not GetChainAloneDisulfideBondsStatus(FileIndex, ChainID):
 1180         return
 1181     
 1182     WritePMLToCheckAndDeleteEmptyObjects(OutFH, PyMOLObjectNames["Chains"][ChainID]["ChainAloneDisulfideBondsResidues"], PyMOLObjectNames["Chains"][ChainID]["ChainAloneDisulfideBondsGroup"])
 1183     
 1184 def DeleteEmptyChainSaltBridgesObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID):
 1185     """Delete empty chain salt bridges objects."""
 1186     
 1187     if not GetChainAloneSaltBridgesStatus(FileIndex, ChainID):
 1188         return
 1189     
 1190     Names = []
 1191     Names.append(PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesPositivelyCharged"])
 1192     Names.append(PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesNegativelyCharged"])
 1193     
 1194     WritePMLToCheckAndDeleteEmptyObjects(OutFH, ",".join(Names), PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesGroup"])
 1195     
 1196 def DeleteEmptyPocketSelectionsObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID, LigandID, PocketObjectID):
 1197     """Delete empty pocket selection objects."""
 1198 
 1199     if not GetPocketContainsSelectionsStatus(FileIndex, ChainID, LigandID):
 1200         return
 1201     
 1202     PocketObjectName = PyMOLObjectNames["Ligands"][ChainID][LigandID][PocketObjectID]
 1203     SelectionsGroupIDPrefix = "PocketSelectionsGroup"
 1204 
 1205     for SelectionName in OptionsInfo["PocketChainSelectionsInfo"]["Names"]:
 1206         SelectionNameGroupID = SelectionName
 1207 
 1208         # Delete surface objects and surface group...
 1209         if GetPocketSelectionSurfaceChainStatus(FileIndex, ChainID, LigandID):
 1210             SurfaceGroupID = "%s%sSurfaceGroup" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1211             SurfaceGroupMembersID = "%s%sSurfaceGroupMembers" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1212             WritePMLToCheckAndDeleteEmptyObjects(OutFH, ",".join(PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfaceGroupMembersID]), PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfaceGroupID])
 1213         
 1214         # Delete Selection object and selection name group...
 1215         SelectionObjectID = "%s%sSelection" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1216         SelectionsGroupID = "%s%sGroup" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1217         WritePMLToCheckAndDeleteEmptyObjects(OutFH, PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionObjectID], PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsGroupID])
 1218 
 1219 def DeleteEmptyPocketResidueTypesObjects(OutFH, FileIndex, PyMOLObjectNames, ChainID, LigandID, PocketObjectID):
 1220     """Delete empty chain residue objects. """
 1221     
 1222     if not GetPocketResidueTypesStatus(FileIndex, ChainID, LigandID):
 1223         return
 1224     
 1225     ResiduesGroupID = "%sResiduesGroup" % (PocketObjectID)
 1226     ResiduesGroupMembersID = "%sMembers" % (ResiduesGroupID)
 1227     
 1228     for SubGroupType in ["Aromatic", "Hydrophobic", "Polar", "Positively_Charged", "Negatively_Charged", "Other"]:
 1229         SubGroupID = re.sub("_", "", SubGroupType)
 1230         
 1231         ResiduesSubGroupID = "%s%sGroup" % (ResiduesGroupID, SubGroupID)
 1232         ResiduesSubMembersGroupID = "%sMembers" % (ResiduesSubGroupID)
 1233 
 1234         SubGroupName = PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesSubGroupID]
 1235         SubGroupObjectNames = ",".join(PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesSubMembersGroupID])
 1236         
 1237         WritePMLToCheckAndDeleteEmptyObjects(OutFH, SubGroupObjectNames, SubGroupName)
 1238 
 1239 def DeleteEmptyChainDockedPosesObjects(OutFH, PDBFileIndex, PyMOLObjectNames, ChainID):
 1240     """Delete empty chain docked poses objest."""
 1241 
 1242     if not GetChainAloneDockedPosesStatus(PDBFileIndex, ChainID):
 1243         return
 1244     
 1245     SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][PDBFileIndex]
 1246     DockedPosesInfo = OptionsInfo["DockedPosesInfo"]
 1247     
 1248     for InputFileIndex, InputFile in enumerate(SpecifiedChainsAndLigandsInfo["DockedPosesInputFiles"][ChainID]):
 1249         InputFileID = DockedPosesInfo["InputFilesIDs"][PDBFileIndex][InputFileIndex]
 1250         for GroupID in ["Pocket", "PocketSolvent", "PocketInorganic"]:
 1251             GroupNameID = "%sGroup" % (GroupID)
 1252             GroupName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupNameID]
 1253             
 1254             GroupTypeObjectID = "%sPocket" % (GroupID)
 1255             GroupTypeObjectName = PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupTypeObjectID]
 1256             
 1257             WritePMLToCheckAndDeleteEmptyObjects(OutFH, GroupTypeObjectName, GroupName)
 1258 
 1259 def WritePMLToCheckAndDeleteEmptyObjects(OutFH, ObjectName, ParentObjectName = None):
 1260     """Write PML to check and delete empty PyMOL objects."""
 1261     
 1262     if ParentObjectName is None:
 1263         PML = """CheckAndDeleteEmptyObjects("%s")""" % (ObjectName)
 1264     else:
 1265         PML = """CheckAndDeleteEmptyObjects("%s", "%s")""" % (ObjectName, ParentObjectName)
 1266     
 1267     OutFH.write("%s\n" % PML)
 1268     
 1269 def SetupPyMOLObjectNames(FileIndex):
 1270     """Setup hierarchy of PyMOL groups and objects for ligand centric views of
 1271     chains and ligands present in input file.
 1272     """
 1273 
 1274     PyMOLObjectNames = {}
 1275     PyMOLObjectNames["Chains"] = {}
 1276     PyMOLObjectNames["Ligands"] = {}
 1277     PyMOLObjectNames["DockedPosesInputFile"] = {}
 1278     PyMOLObjectNames["Trajectories"] = {}
 1279 
 1280     # Setup groups and objects for complex...
 1281     SetupPyMOLObjectNamesForComplex(FileIndex, PyMOLObjectNames)
 1282 
 1283     # Setup groups and object for trajectories...
 1284     if GetTrajectoriesStatus(FileIndex):
 1285         SetupPyMOLObjectNamesForTrajectories(FileIndex, PyMOLObjectNames)
 1286     
 1287     # Setup groups and objects for chain...
 1288     SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
 1289     for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
 1290         SetupPyMOLObjectNamesForChain(FileIndex, PyMOLObjectNames, ChainID)
 1291         
 1292         # Setup groups and objects for ligand...
 1293         for LigandID in SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]:
 1294             SetupPyMOLObjectNamesForLigand(FileIndex, PyMOLObjectNames, ChainID, LigandID)
 1295 
 1296         # Setup group and objects for docked poses...
 1297         if  GetChainAloneDockedPosesStatus(FileIndex, ChainID):
 1298             SetupPyMOLObjectNamesForDockedPoses(FileIndex, PyMOLObjectNames, ChainID)
 1299 
 1300     return PyMOLObjectNames
 1301 
 1302 def SetupPyMOLObjectNamesForComplex(FileIndex, PyMOLObjectNames):
 1303     """Setup groups and objects for complex."""
 1304     
 1305     PDBFileRoot = OptionsInfo["InfilesInfo"]["InfilesRoots"][FileIndex]
 1306     
 1307     PDBGroupName = "%s" % PDBFileRoot
 1308     PyMOLObjectNames["PDBGroup"] = PDBGroupName
 1309     PyMOLObjectNames["PDBGroupMembers"] = []
 1310 
 1311     ComplexGroupName = "%s.Complex" % PyMOLObjectNames["PDBGroup"]
 1312     PyMOLObjectNames["ComplexGroup"] = ComplexGroupName
 1313     PyMOLObjectNames["PDBGroupMembers"].append(ComplexGroupName)
 1314     
 1315     PyMOLObjectNames["Complex"] = "%s.Complex" % ComplexGroupName
 1316     if OptionsInfo["SurfaceComplex"]:
 1317         PyMOLObjectNames["ComplexHydrophobicSurface"] = "%s.Surface" % ComplexGroupName
 1318 
 1319     PyMOLObjectNames["ComplexGroupMembers"] = []
 1320     PyMOLObjectNames["ComplexGroupMembers"].append(PyMOLObjectNames["Complex"])
 1321     if OptionsInfo["SurfaceComplex"]:
 1322         PyMOLObjectNames["ComplexGroupMembers"].append(PyMOLObjectNames["ComplexHydrophobicSurface"])
 1323     
 1324 def SetupPyMOLObjectNamesForTrajectories(FileIndex, PyMOLObjectNames):
 1325     """Setup groups and objects for a PDB file."""
 1326     
 1327     if not GetTrajectoriesStatus(FileIndex):
 1328         return
 1329     
 1330     # Setup a group for trajectories....
 1331     TrajectoriesGroupName = "%s.Trajectories" % PyMOLObjectNames["PDBGroup"]
 1332     PyMOLObjectNames["Trajectories"]["TrajectoriesGroup"] = TrajectoriesGroupName
 1333     PyMOLObjectNames["PDBGroupMembers"].append(TrajectoriesGroupName)
 1334     
 1335     PyMOLObjectNames["Trajectories"]["TrajectoriesGroupMembers"] = []
 1336 
 1337     # Setup a topolgy object...
 1338     TopologyName = "%s.Topology" % TrajectoriesGroupName
 1339     PyMOLObjectNames["Trajectories"]["Topology"] = TopologyName
 1340     PyMOLObjectNames["Trajectories"]["TrajectoriesGroupMembers"].append(TopologyName)
 1341     
 1342     # Setup trajectory objects...
 1343     for TrajFileIndex, TrajFile in enumerate(OptionsInfo["TrajectoriesInfo"]["TrajFiles"][FileIndex]):
 1344         SetupPyMOLObjectNamesForTrajectoryFile(FileIndex, PyMOLObjectNames, TrajFileIndex)
 1345 
 1346 def SetupPyMOLObjectNamesForTrajectoryFile(PDBFileIndex, PyMOLObjectNames, TrajFileIndex):
 1347     """Setup groups and objest for a trajectory file for a PDB file."""
 1348 
 1349     TrajFileID = OptionsInfo["TrajectoriesInfo"]["TrajFilesIDs"][PDBFileIndex][TrajFileIndex]
 1350 
 1351     PyMOLObjectNames["Trajectories"][TrajFileID] = {}
 1352 
 1353     TrajectoriesGroupName = PyMOLObjectNames["Trajectories"]["TrajectoriesGroup"]
 1354 
 1355     # Setup a trajectories level trajectory file group...
 1356     TrajectoryFileGroupName = "%s.%s" % (TrajectoriesGroupName, TrajFileID)
 1357     PyMOLObjectNames["Trajectories"][TrajFileID]["TrajectoryGroup"] = TrajectoryFileGroupName
 1358     PyMOLObjectNames["Trajectories"]["TrajectoriesGroupMembers"].append(TrajectoryFileGroupName)
 1359 
 1360     PyMOLObjectNames["Trajectories"][TrajFileID]["TrajectoryGroupMembers"] = []
 1361 
 1362     # Setup object for a trajectory file...
 1363     TrajectoryName = "%s.Trajectory" % (TrajectoryFileGroupName)
 1364     PyMOLObjectNames["Trajectories"][TrajFileID]["Trajectory"] = TrajectoryName
 1365     PyMOLObjectNames["Trajectories"][TrajFileID]["TrajectoryGroupMembers"].append(TrajectoryName)
 1366 
 1367 def SetupPyMOLObjectNamesForChain(FileIndex, PyMOLObjectNames, ChainID):
 1368     """Setup groups and objects for chain."""
 1369     
 1370     PDBGroupName = PyMOLObjectNames["PDBGroup"]
 1371     
 1372     PyMOLObjectNames["Chains"][ChainID] = {}
 1373     PyMOLObjectNames["Ligands"][ChainID] = {}
 1374     
 1375     # Set up chain group and chain objects...
 1376     ChainGroupName = "%s.Chain%s" % (PDBGroupName, ChainID)
 1377     PyMOLObjectNames["Chains"][ChainID]["ChainGroup"] = ChainGroupName
 1378     PyMOLObjectNames["PDBGroupMembers"].append(ChainGroupName)
 1379     PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"] = []
 1380     
 1381     # Setup chain complex group and objects...
 1382     ChainComplexGroupName = "%s.Complex" % (ChainGroupName)
 1383     PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroup"] = ChainComplexGroupName
 1384     PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"].append(ChainComplexGroupName)
 1385 
 1386     PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroupMembers"] = []
 1387     
 1388     Name = "%s.Complex" % (ChainComplexGroupName)
 1389     PyMOLObjectNames["Chains"][ChainID]["ChainComplex"] = Name
 1390     PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroupMembers"].append(Name)
 1391     
 1392     if OptionsInfo["SurfaceChainComplex"]:
 1393         Name = "%s.Surface" % (ChainComplexGroupName)
 1394         PyMOLObjectNames["Chains"][ChainID]["ChainComplexHydrophobicSurface"] = Name
 1395         PyMOLObjectNames["Chains"][ChainID]["ChainComplexGroupMembers"].append(Name)
 1396 
 1397     # Setup up a group for individual chains...
 1398     ChainAloneGroupName = "%s.Chain" % (ChainGroupName)
 1399     PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroup"] = ChainAloneGroupName
 1400     PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"].append(ChainAloneGroupName)
 1401         
 1402     PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"] = []
 1403         
 1404     Name = "%s.Chain" % (ChainAloneGroupName)
 1405     PyMOLObjectNames["Chains"][ChainID]["ChainAlone"] = Name
 1406     PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"].append(Name)
 1407 
 1408     if GetChainAloneBFactorStatus(FileIndex, ChainID):
 1409         # Setup B factor group and add it to chain alone group...
 1410         BFactorGroupName = "%s.BFactor" % (ChainAloneGroupName)
 1411         PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorGroup"] = BFactorGroupName
 1412         PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"].append(BFactorGroupName)
 1413         
 1414         PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorGroupMembers"] = []
 1415         
 1416         # Setup cartoon...
 1417         Name = "%s.Cartoon" % (BFactorGroupName)
 1418         PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorCartoon"] = Name
 1419         PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorGroupMembers"].append(Name)
 1420 
 1421         # Setup putty...
 1422         Name = "%s.Putty" % (BFactorGroupName)
 1423         PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorPutty"] = Name
 1424         PyMOLObjectNames["Chains"][ChainID]["ChainAloneBFactorGroupMembers"].append(Name)
 1425 
 1426     if GetChainAloneContainsSelectionsStatus(FileIndex, ChainID):
 1427         # Setup selections group and its subgroups..
 1428         SelectionsGroupName = "%s.Selections" % (ChainAloneGroupName)
 1429         
 1430         SelectionsGroupIDPrefix = "ChainAloneSelections"
 1431         SelectionsGroupID = "%sGroup" % SelectionsGroupIDPrefix
 1432         
 1433         # Add selections group to chain alone group...
 1434         PyMOLObjectNames["Chains"][ChainID][SelectionsGroupID] = SelectionsGroupName
 1435         PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"].append(SelectionsGroupName)
 1436         
 1437         # Initialize selections group members...
 1438         SelectionsGroupMembersID = "%sGroupMembers" % SelectionsGroupIDPrefix
 1439         PyMOLObjectNames["Chains"][ChainID][SelectionsGroupMembersID] = []
 1440 
 1441         # Setup selections name sub group and its members...
 1442         for SelectionName in OptionsInfo["ChainSelectionsInfo"]["Names"]:
 1443             SelectionNameGroupID = SelectionName
 1444             
 1445             SelectionsNameGroupName = "%s.%s" % (SelectionsGroupName, SelectionName)
 1446             SelectionsNameGroupID = "%s%sGroup" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1447 
 1448             # Add selections name sub group to selections group...
 1449             PyMOLObjectNames["Chains"][ChainID][SelectionsNameGroupID] = SelectionsNameGroupName
 1450             PyMOLObjectNames["Chains"][ChainID][SelectionsGroupMembersID].append(SelectionsNameGroupName)
 1451             
 1452             # Initialize selections names sub group members...
 1453             SelectionsNameGroupMembersID = "%s%sGroupMembers" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1454             PyMOLObjectNames["Chains"][ChainID][SelectionsNameGroupMembersID] = []
 1455 
 1456             # Add selection member to selections name group...
 1457             SubGroupMemberName = "%s.Selection" % (SelectionsNameGroupName)
 1458             SubGroupMemberID = "%s%sSelection" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1459             
 1460             PyMOLObjectNames["Chains"][ChainID][SubGroupMemberID] = SubGroupMemberName
 1461             PyMOLObjectNames["Chains"][ChainID][SelectionsNameGroupMembersID].append(SubGroupMemberName)
 1462             
 1463             if GetChainAloneContainsChainSelectionSurfacesStatus(FileIndex, ChainID):
 1464                 # Setup a surface sub group and add it to selections name group...
 1465                 
 1466                 SelectionsNameSurfaceGroupName = "%s.Surface" % (SelectionsNameGroupName)
 1467                 SelectionsNameSurfaceGroupID = "%s%sSurfaceGroup" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1468 
 1469                 # Add selection surface group to selection name group...
 1470                 PyMOLObjectNames["Chains"][ChainID][SelectionsNameSurfaceGroupID] = SelectionsNameSurfaceGroupName
 1471                 PyMOLObjectNames["Chains"][ChainID][SelectionsNameGroupMembersID].append(SelectionsNameSurfaceGroupName)
 1472 
 1473                 # Initialize surface names sub group members...
 1474                 SelectionsNameSurfaceGroupMembersID = "%s%sSurfaceGroupMembers" % (SelectionsGroupIDPrefix, SelectionNameGroupID)
 1475                 PyMOLObjectNames["Chains"][ChainID][SelectionsNameSurfaceGroupMembersID] = []
 1476                 
 1477                 # Setup a generic color surface...
 1478                 SubGroupMemberName = "%s.Surface" % (SelectionsNameSurfaceGroupName)
 1479                 SubGroupMemberID = "%s%s%sSurface" % (SelectionsGroupIDPrefix, SelectionNameGroupID, "Surface")
 1480                 PyMOLObjectNames["Chains"][ChainID][SubGroupMemberID] = SubGroupMemberName
 1481                 PyMOLObjectNames["Chains"][ChainID][SelectionsNameSurfaceGroupMembersID].append(SubGroupMemberName)
 1482                 
 1483                 if GetChainAloneSurfaceChainSelectionStatus(FileIndex, ChainID):
 1484                     # Setup surfaces...
 1485                     for MemberType in ["Hydrophobicity", "Hydrophobicity_Charge"]:
 1486                         MemberID = re.sub("_", "", MemberType)
 1487                         
 1488                         SubGroupMemberName = "%s.%s" % (SelectionsNameSurfaceGroupName, MemberType)
 1489                         SubGroupMemberID = "%s%s%s%s" % (SelectionsGroupIDPrefix, SelectionNameGroupID, "Surface", MemberID)
 1490                         
 1491                         PyMOLObjectNames["Chains"][ChainID][SubGroupMemberID] = SubGroupMemberName
 1492                         PyMOLObjectNames["Chains"][ChainID][SelectionsNameSurfaceGroupMembersID].append(SubGroupMemberName)
 1493 
 1494     if GetChainAloneResidueTypesStatus(FileIndex, ChainID):
 1495         # Setup residue type group and its subgroups...
 1496         ResiduesGroupName = "%s.Residues" % (ChainAloneGroupName)
 1497         
 1498         ResiduesGroupIDPrefix = "ChainAloneResidues"
 1499         ResiduesGroupID = "%sGroup" % ResiduesGroupIDPrefix
 1500 
 1501         # Add residue group to chain alone group...
 1502         PyMOLObjectNames["Chains"][ChainID][ResiduesGroupID] = ResiduesGroupName
 1503         PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"].append(ResiduesGroupName)
 1504         
 1505         # Initialize residue group members...
 1506         ResiduesGroupMembersID = "%sGroupMembers" % ResiduesGroupIDPrefix
 1507         PyMOLObjectNames["Chains"][ChainID][ResiduesGroupMembersID] = []
 1508 
 1509         # Setup residues sub groups and its members...
 1510         for SubGroupType in ["Aromatic", "Hydrophobic", "Polar", "Positively_Charged", "Negatively_Charged", "Other"]:
 1511             SubGroupID = re.sub("_", "", SubGroupType)
 1512 
 1513             ResiduesSubGroupName = "%s.%s" % (ResiduesGroupName, SubGroupType)
 1514             ResiduesSubGroupID = "%s%sGroup" % (ResiduesGroupIDPrefix, SubGroupID)
 1515 
 1516             # Add sub group to residues group...
 1517             PyMOLObjectNames["Chains"][ChainID][ResiduesSubGroupID] = ResiduesSubGroupName
 1518             PyMOLObjectNames["Chains"][ChainID][ResiduesGroupMembersID].append(ResiduesSubGroupName)
 1519 
 1520             # Initialize sub group members...
 1521             ResiduesSubGroupMembersID = "%s%sGroupMembers" % (ResiduesGroupIDPrefix, SubGroupID)
 1522             PyMOLObjectNames["Chains"][ChainID][ResiduesSubGroupMembersID] = []
 1523             
 1524             # Add sub group members to subgroup...
 1525             for MemberType in ["Residues", "Surface"]:
 1526                 MemberID = re.sub("_", "", MemberType)
 1527 
 1528                 SubGroupMemberName = "%s.%s" % (ResiduesSubGroupName, MemberType)
 1529                 SubGroupMemberID = "%s%s%s" % (ResiduesGroupIDPrefix, SubGroupID, MemberID)
 1530                 
 1531                 PyMOLObjectNames["Chains"][ChainID][SubGroupMemberID] = SubGroupMemberName
 1532                 PyMOLObjectNames["Chains"][ChainID][ResiduesSubGroupMembersID].append(SubGroupMemberName)
 1533 
 1534     if GetChainAloneContainsSurfacesStatus(FileIndex, ChainID):
 1535         # Setup a surface group and add it to chain alone group...
 1536         SurfaceGroupName = "%s.Surface" % (ChainAloneGroupName)
 1537         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSurfaceGroup"] = SurfaceGroupName
 1538         PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"].append(SurfaceGroupName)
 1539         
 1540         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSurfaceGroupMembers"] = []
 1541 
 1542         # Setup a generic color surface...
 1543         Name = "%s.Surface" % (SurfaceGroupName)
 1544         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSurface"] = Name
 1545         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSurfaceGroupMembers"].append(Name)
 1546         
 1547         if GetChainAloneSurfaceChainStatus(FileIndex, ChainID):
 1548             # Setup hydrophobicity surface...
 1549             Name = "%s.Hydrophobicity" % (SurfaceGroupName)
 1550             PyMOLObjectNames["Chains"][ChainID]["ChainAloneHydrophobicSurface"] = Name
 1551             PyMOLObjectNames["Chains"][ChainID]["ChainAloneSurfaceGroupMembers"].append(Name)
 1552             
 1553             # Setup hydrophobicity and charge surface...
 1554             Name = "%s.Hydrophobicity_Charge" % (SurfaceGroupName)
 1555             PyMOLObjectNames["Chains"][ChainID]["ChainAloneHydrophobicChargeSurface"] = Name
 1556             PyMOLObjectNames["Chains"][ChainID]["ChainAloneSurfaceGroupMembers"].append(Name)
 1557     
 1558         if GetChainAloneSurfaceChainElectrostaticsStatus(FileIndex, ChainID):
 1559             # Setup electrostatics group...
 1560             GroupName = "%s.Vacuum_Electrostatics" % (SurfaceGroupName)
 1561             PyMOLObjectNames["Chains"][ChainID]["ChainAloneElectrostaticsGroup"] = GroupName
 1562             PyMOLObjectNames["Chains"][ChainID]["ChainAloneSurfaceGroupMembers"].append(GroupName)
 1563             
 1564             # Setup electrostatics group members...
 1565             PyMOLObjectNames["Chains"][ChainID]["ChainAloneElectrostaticsGroupMembers"] = []
 1566             
 1567             for MemberType in ["Chain", "Contact_Potential", "Map", "Legend", "Volume"]:
 1568                 MemberID = re.sub("_", "", MemberType)
 1569                 
 1570                 Name = "%s.%s" % (GroupName, MemberType)
 1571                 NameID = "ChainAloneElectrostaticsSurface%s" % MemberID
 1572                 
 1573                 PyMOLObjectNames["Chains"][ChainID][NameID] = Name
 1574                 PyMOLObjectNames["Chains"][ChainID]["ChainAloneElectrostaticsGroupMembers"].append(Name)
 1575 
 1576     if GetChainAloneDisulfideBondsStatus(FileIndex, ChainID):
 1577         # Setup disulfide bonds group and add it to chain alone group...
 1578         DisulfideBondsGroupName = "%s.Disulfide_Bonds" % (ChainAloneGroupName)
 1579         PyMOLObjectNames["Chains"][ChainID]["ChainAloneDisulfideBondsGroup"] = DisulfideBondsGroupName
 1580         PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"].append(DisulfideBondsGroupName)
 1581         
 1582         PyMOLObjectNames["Chains"][ChainID]["ChainAloneDisulfideBondsGroupMembers"] = []
 1583 
 1584         # Setup a residues object for disulfide bonds...
 1585         Name = "%s.Residues" % (DisulfideBondsGroupName)
 1586         PyMOLObjectNames["Chains"][ChainID]["ChainAloneDisulfideBondsResidues"] = Name
 1587         PyMOLObjectNames["Chains"][ChainID]["ChainAloneDisulfideBondsGroupMembers"].append(Name)
 1588         
 1589     if GetChainAloneSaltBridgesStatus(FileIndex, ChainID):
 1590         # Setup salt bridges group and add it to chain alone group...
 1591         SaltBridgesGroupName = "%s.Salt_Bridges" % (ChainAloneGroupName)
 1592         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesGroup"] = SaltBridgesGroupName
 1593         PyMOLObjectNames["Chains"][ChainID]["ChainAloneGroupMembers"].append(SaltBridgesGroupName)
 1594     
 1595         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesGroupMembers"] = []
 1596 
 1597         # Setup residues group and add it to salt bridges group...
 1598         ResiduesGroupName = "%s.Residues" % (SaltBridgesGroupName)
 1599         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesGroup"] = ResiduesGroupName
 1600         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesGroupMembers"].append(ResiduesGroupName)
 1601         
 1602         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesGroupMembers"] = []
 1603 
 1604         # Setup objects for residues group...
 1605         Name = "%s.Positively_Charged" % (ResiduesGroupName)
 1606         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesPositivelyCharged"] = Name
 1607         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesGroupMembers"].append(Name)
 1608         
 1609         Name = "%s.Negatively_Charged" % (ResiduesGroupName)
 1610         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesNegativelyCharged"] = Name
 1611         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesResiduesGroupMembers"].append(Name)
 1612 
 1613         # Add contacts object to salt bridges group...
 1614         Name = "%s.Contacts" % (SaltBridgesGroupName)
 1615         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesContacts"] = Name
 1616         PyMOLObjectNames["Chains"][ChainID]["ChainAloneSaltBridgesGroupMembers"].append(Name)
 1617     
 1618     # Setup solvent and inorganic objects for chain...
 1619     for NameID in ["Solvent", "Inorganic"]:
 1620         Name = "%s.%s" % (ChainGroupName, NameID)
 1621         PyMOLObjectNames["Chains"][ChainID][NameID] = Name
 1622         PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"].append(Name)
 1623 
 1624 def SetupPyMOLObjectNamesForLigand(FileIndex, PyMOLObjectNames, ChainID, LigandID):
 1625     """Stetup groups and objects for ligand."""
 1626 
 1627     PyMOLObjectNames["Ligands"][ChainID][LigandID] = {}
 1628     
 1629     ChainGroupName = PyMOLObjectNames["Chains"][ChainID]["ChainGroup"]
 1630     
 1631     # Setup a chain level ligand group...
 1632     ChainLigandGroupName = "%s.Ligand%s" % (ChainGroupName, LigandID)
 1633     PyMOLObjectNames["Ligands"][ChainID][LigandID]["ChainLigandGroup"] = ChainLigandGroupName
 1634     PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"].append(ChainLigandGroupName)
 1635     
 1636     PyMOLObjectNames["Ligands"][ChainID][LigandID]["ChainLigandGroupMembers"] = []
 1637 
 1638     # Set up groups and objects for a specific ligand group...
 1639     for GroupType in ["Ligand", "Pocket", "Pocket_Solvent", "Pocket_Inorganic"]:
 1640         GroupID = re.sub("_", "", GroupType)
 1641         GroupName = "%s.%s" % (ChainLigandGroupName, GroupType)
 1642                 
 1643         GroupNameID = "%sGroup" % (GroupID)
 1644         GroupMembersID = "%sGroupMembers" % (GroupID)
 1645         
 1646         PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupNameID] = GroupName
 1647         PyMOLObjectNames["Ligands"][ChainID][LigandID]["ChainLigandGroupMembers"].append(GroupName)
 1648         
 1649         GroupTypeObjectName = "%s.%s" % (GroupName, GroupType)
 1650         GroupTypeObjectID = "%s" % (GroupID)
 1651         PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupTypeObjectID] = GroupTypeObjectName
 1652         
 1653         PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID] = []
 1654         PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(GroupTypeObjectName)
 1655         
 1656         if re.match("^Ligand$", GroupType, re.I):
 1657             # Only need to add ball and stick...
 1658             BallAndStickName = "%s.BallAndStick" % (GroupName)
 1659             BallAndStickID = "%sBallAndStick" % (GroupID)
 1660             PyMOLObjectNames["Ligands"][ChainID][LigandID][BallAndStickID] = BallAndStickName
 1661             PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(BallAndStickName)
 1662         
 1663         if re.match("^(Pocket|Pocket_Solvent|Pocket_Inorganic)$", GroupType, re.I):
 1664             PolarContactsName = "%s.Polar_Contacts" % (GroupName)
 1665             PolarContactsID = "%sPolarContacts" % (GroupID)
 1666             PyMOLObjectNames["Ligands"][ChainID][LigandID][PolarContactsID] = PolarContactsName
 1667             PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(PolarContactsName)
 1668                 
 1669         if re.match("^Pocket_Inorganic$", GroupType, re.I):
 1670             PiCationContactsName = "%s.Pi_Cation_Contacts" % (GroupName)
 1671             PiCationContactsID = "%sPiCationContacts" % (GroupID)
 1672             PyMOLObjectNames["Ligands"][ChainID][LigandID][PiCationContactsID] = PiCationContactsName
 1673             PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(PiCationContactsName)
 1674         
 1675         if re.match("^Pocket$", GroupType, re.I):
 1676             HydrophobicContactsName = "%s.Hydrophobic_Contacts" % (GroupName)
 1677             HydrophobicContactsID = "%sHydrophobicContacts" % (GroupID)
 1678             PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicContactsID] = HydrophobicContactsName
 1679             PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(HydrophobicContactsName)
 1680 
 1681             PiPiContactsName = "%s.Pi_Pi_Contacts" % (GroupName)
 1682             PiPiContactsID = "%sPiPiContacts" % (GroupID)
 1683             PyMOLObjectNames["Ligands"][ChainID][LigandID][PiPiContactsID] = PiPiContactsName
 1684             PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(PiPiContactsName)
 1685             
 1686             PiCationContactsName = "%s.Pi_Cation_Contacts" % (GroupName)
 1687             PiCationContactsID = "%sPiCationContacts" % (GroupID)
 1688             PyMOLObjectNames["Ligands"][ChainID][LigandID][PiCationContactsID] = PiCationContactsName
 1689             PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(PiCationContactsName)
 1690             
 1691             PiCationContactsName = "%s.Pi_Cation_Contacts" % (GroupName)
 1692             PiCationContactsID = "%sPiCationContacts" % (GroupID)
 1693             PyMOLObjectNames["Ligands"][ChainID][LigandID][PiCationContactsID] = PiCationContactsName
 1694             PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(PiCationContactsName)
 1695             
 1696             HalogenContactsName = "%s.Halogen_Contacts" % (GroupName)
 1697             HalogenContactsID = "%sHalogenContacts" % (GroupID)
 1698             PyMOLObjectNames["Ligands"][ChainID][LigandID][HalogenContactsID] = HalogenContactsName
 1699             PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(HalogenContactsName)
 1700             
 1701             if GetPocketContainsSelectionsStatus(FileIndex, ChainID, LigandID):
 1702                 # Setup selections group and its subgroups..
 1703                 SelectionsGroupName = "%s.Selections" % (GroupName)
 1704                 SelectionsGroupID = "%sSelectionsGroup" % (GroupID)
 1705                 SelectionsGroupMembersID = "%sGroupMembers" % (SelectionsGroupID)
 1706                 
 1707                 PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsGroupID] = SelectionsGroupName
 1708                 PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(SelectionsGroupName)
 1709                 
 1710                 PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsGroupMembersID] = []
 1711 
 1712                 # Setup selections name sub group and its members...
 1713                 for SelectionName in OptionsInfo["PocketChainSelectionsInfo"]["Names"]:
 1714                     SelectionNameGroupID = SelectionName
 1715                     
 1716                     SelectionsNameGroupName = "%s.%s" % (SelectionsGroupName, SelectionName)
 1717                     SelectionsNameGroupID = "%s%sGroup" % (SelectionsGroupID, SelectionNameGroupID)
 1718                     SelectionsNameGroupMembersID = "%s%sGroupMembers" % (SelectionsGroupID, SelectionNameGroupID)
 1719 
 1720                     # Add selections name sub group to selections group...
 1721                     PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsNameGroupID] = SelectionsNameGroupName
 1722                     PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsGroupMembersID].append(SelectionsNameGroupName)
 1723                     
 1724                     # Initialize selections names sub group members...
 1725                     PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsNameGroupMembersID] = []
 1726                     
 1727                     # Add selection member to selections name group...
 1728                     SubGroupMemberName = "%s.Selection" % (SelectionsNameGroupName)
 1729                     SubGroupMemberID = "%s%sSelection" % (SelectionsGroupID, SelectionNameGroupID)
 1730                     
 1731                     PyMOLObjectNames["Ligands"][ChainID][LigandID][SubGroupMemberID] = SubGroupMemberName
 1732                     PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsNameGroupMembersID].append(SubGroupMemberName)
 1733                     
 1734                     if GetPocketSelectionSurfaceChainStatus(FileIndex, ChainID, LigandID):
 1735                         # Setup a surface sub group and add it to selections name group...
 1736                         SelectionsNameSurfaceGroupName = "%s.Surface" % (SelectionsNameGroupName)
 1737                         SelectionsNameSurfaceGroupID = "%s%sSurfaceGroup" % (SelectionsGroupID, SelectionNameGroupID)
 1738                         
 1739                         # Add selection surface group to selection name group...
 1740                         PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsNameSurfaceGroupID] = SelectionsNameSurfaceGroupName
 1741                         PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsNameGroupMembersID].append(SelectionsNameSurfaceGroupName)
 1742                         
 1743                         # Initialize surface names sub group members...
 1744                         SelectionsNameSurfaceGroupMembersID = "%s%sSurfaceGroupMembers" % (SelectionsGroupID, SelectionNameGroupID)
 1745                         PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsNameSurfaceGroupMembersID] = []
 1746                         
 1747                         # Setup surfaces...
 1748                         for MemberType in ["Surface", "Hydrophobicity", "Hydrophobicity_Charge"]:
 1749                             MemberID = re.sub("_", "", MemberType)
 1750                             
 1751                             SubGroupMemberName = "%s.%s" % (SelectionsNameSurfaceGroupName, MemberType)
 1752                             SubGroupMemberID = "%s%s%s%s" % (SelectionsGroupID, SelectionNameGroupID, "Surface", MemberID)
 1753                             
 1754                             PyMOLObjectNames["Ligands"][ChainID][LigandID][SubGroupMemberID] = SubGroupMemberName
 1755                             PyMOLObjectNames["Ligands"][ChainID][LigandID][SelectionsNameSurfaceGroupMembersID].append(SubGroupMemberName)
 1756 
 1757             if GetPocketResidueTypesStatus(FileIndex, ChainID, LigandID):
 1758                 # Setup residue type group and add to pocket group...
 1759                 ResiduesGroupName = "%s.Residues" % (GroupName)
 1760                 ResiduesGroupID = "%sResiduesGroup" % (GroupID)
 1761                 ResiduesGroupMembersID = "%sMembers" % (ResiduesGroupID)
 1762 
 1763                 PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesGroupID] = ResiduesGroupName
 1764                 PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(ResiduesGroupName)
 1765                 PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesGroupMembersID] = []
 1766                 
 1767                 # Setup residue group subgroup and its members...
 1768                 for SubGroupType in ["Aromatic", "Hydrophobic", "Polar", "Positively_Charged", "Negatively_Charged", "Other"]:
 1769                     SubGroupID = re.sub("_", "", SubGroupType)
 1770                     ResiduesSubGroupName = "%s.%s" % (ResiduesGroupName, SubGroupType)
 1771                     ResiduesSubGroupID = "%s%sGroup" % (ResiduesGroupID, SubGroupID)
 1772                     ResiduesSubMembersGroupID = "%sMembers" % (ResiduesSubGroupID)
 1773                     
 1774                     # Add sub group to residues group...
 1775                     PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesSubGroupID] = ResiduesSubGroupName
 1776                     PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesGroupMembersID].append(ResiduesSubGroupName)
 1777                     PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesSubMembersGroupID] = []
 1778                     
 1779                     # Add sub group members to subgroup...
 1780                     for MemberType in ["Residues", "Surface"]:
 1781                         MemberID = re.sub("_", "", MemberType)
 1782                         SubGroupMemberName = "%s.%s" % (ResiduesSubGroupName, MemberType)
 1783                         SubGroupMemberID = "%s%s" % (ResiduesSubGroupID, MemberID)
 1784                         
 1785                         PyMOLObjectNames["Ligands"][ChainID][LigandID][SubGroupMemberID] = SubGroupMemberName
 1786                         PyMOLObjectNames["Ligands"][ChainID][LigandID][ResiduesSubMembersGroupID].append(SubGroupMemberName)
 1787 
 1788             if GetPocketContainsSurfaceStatus(FileIndex, ChainID, LigandID):
 1789                 # Setup a surfaces group and add it to pocket group...
 1790                 SurfacesGroupName = "%s.Surfaces" % (GroupName)
 1791                 SurfacesGroupID = "%sSurfacesGroup" % (GroupID)
 1792                 SurfacesGroupMembersID = "%sMembers" % (SurfacesGroupID)
 1793 
 1794                 PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesGroupID] = SurfacesGroupName
 1795                 PyMOLObjectNames["Ligands"][ChainID][LigandID][GroupMembersID].append(SurfacesGroupName)
 1796                 PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesGroupMembersID] = []
 1797 
 1798                 # Setup surfaces subgroup and its members...
 1799                 for SubGroupType in ["Surface", "Cavity"]:
 1800                     SubGroupID = re.sub("_", "", SubGroupType)
 1801                     SurfacesSubGroupName = "%s.%s" % (SurfacesGroupName, SubGroupType)
 1802                     SurfacesSubGroupID = "%s%sGroup" % (SurfacesGroupID, SubGroupID)
 1803                     SurfacesSubGroupMembersID = "%sMembers" % (SurfacesSubGroupID)
 1804                     
 1805                     # Add sub group to surfaces group...
 1806                     PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesSubGroupID] = SurfacesSubGroupName
 1807                     PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesGroupMembersID].append(SurfacesSubGroupName)
 1808                     PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesSubGroupMembersID] = []
 1809                     
 1810                     # Setup a generic color surface...
 1811                     SurfaceName = "%s.Surface" % (SurfacesSubGroupName)
 1812                     SurfaceID = "%sSurface" % (SurfacesSubGroupID)
 1813                     PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfaceID] = SurfaceName
 1814                     PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesSubGroupMembersID].append(SurfaceName)
 1815                     
 1816                     if GetPocketSurfaceChainStatus(FileIndex, ChainID, LigandID):
 1817                         # Surface colored by hydrophobicity...
 1818                         HydrophobicSurfaceName = "%s.Hydrophobicity" % (SurfacesSubGroupName)
 1819                         HydrophobicSurfaceID = "%sHydrophobicSurface" % (SurfacesSubGroupID)
 1820                         PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicSurfaceID] = HydrophobicSurfaceName
 1821                         PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesSubGroupMembersID].append(HydrophobicSurfaceName)
 1822                         
 1823                         # Surface colored by hydrophobicity and charge...
 1824                         HydrophobicChargeSurfaceName = "%s.Hydrophobicity_Charge" % (SurfacesSubGroupName)
 1825                         HydrophobicChargeSurfaceID = "%sHydrophobicChargeSurface" % (SurfacesSubGroupID)
 1826                         PyMOLObjectNames["Ligands"][ChainID][LigandID][HydrophobicChargeSurfaceID] = HydrophobicChargeSurfaceName
 1827                         PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesSubGroupMembersID].append(HydrophobicChargeSurfaceName)
 1828                 
 1829                     if GetPocketSurfaceChainElectrostaticsStatus(FileIndex, ChainID, LigandID):
 1830                         ElectrostaticsGroupName = "%s.Vacuum_Electrostatics" % (SurfacesSubGroupName)
 1831                         ElectrostaticsGroupID = "%sElectrostaticsGroup" % (SurfacesSubGroupID)
 1832                         ElectrostaticsGroupMembersID = "%sElectrostaticsGroupMembers" % (SurfacesSubGroupID)
 1833                         
 1834                         PyMOLObjectNames["Ligands"][ChainID][LigandID][ElectrostaticsGroupID] = ElectrostaticsGroupName
 1835                         PyMOLObjectNames["Ligands"][ChainID][LigandID][SurfacesSubGroupMembersID].append(ElectrostaticsGroupName)
 1836                         
 1837                         # Setup electrostatics group members without the volume object...
 1838                         PyMOLObjectNames["Ligands"][ChainID][LigandID][ElectrostaticsGroupMembersID] = []
 1839                         
 1840                         for MemberType in ["Pocket", "Contact_Potential", "Map", "Legend"]:
 1841                             MemberID = re.sub("_", "", MemberType)
 1842                             
 1843                             Name = "%s.%s" % (ElectrostaticsGroupName, MemberType)
 1844                             NameID = "%s%s" % (ElectrostaticsGroupID, MemberID)
 1845                             
 1846                             PyMOLObjectNames["Ligands"][ChainID][LigandID][NameID] = Name
 1847                             PyMOLObjectNames["Ligands"][ChainID][LigandID][ElectrostaticsGroupMembersID].append(Name)
 1848     
 1849 def SetupPyMOLObjectNamesForDockedPoses(FileIndex, PyMOLObjectNames, ChainID):
 1850     """Stetup groups and objects for docked poses in input files for a chain."""
 1851 
 1852     PyMOLObjectNames["DockedPosesInputFile"][ChainID] = {}
 1853     
 1854     if not GetChainAloneDockedPosesStatus(FileIndex, ChainID):
 1855         return
 1856     
 1857     # Setup group for docked poses...
 1858     if "DockedPosesGroup" not in PyMOLObjectNames["Chains"][ChainID]:
 1859         # Setup docked poses group at a chain level...
 1860         ChainGroupName = PyMOLObjectNames["Chains"][ChainID]["ChainGroup"]
 1861         DockedPosesGroupName = "%s.%s" % (ChainGroupName, OptionsInfo["DockedPosesGroupName"])
 1862         
 1863         PyMOLObjectNames["Chains"][ChainID]["DockedPosesGroup"] = DockedPosesGroupName
 1864         PyMOLObjectNames["Chains"][ChainID]["ChainGroupMembers"].append(DockedPosesGroupName)
 1865         PyMOLObjectNames["Chains"][ChainID]["DockedPosesGroupMembers"] = []
 1866     
 1867     SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
 1868     for InputFileIndex, InputFile in enumerate(SpecifiedChainsAndLigandsInfo["DockedPosesInputFiles"][ChainID]):
 1869         SetupPyMOLObjectNamesForDockedPosesInputFile(FileIndex, PyMOLObjectNames, ChainID, InputFileIndex)
 1870     
 1871 def SetupPyMOLObjectNamesForDockedPosesInputFile(PDBFileIndex, PyMOLObjectNames, ChainID, InputFileIndex):
 1872     """Stetup groups and objects for docked poses in an input file for a chain."""
 1873     
 1874     DockedPosesInfo = OptionsInfo["DockedPosesInfo"]
 1875     DockedPosesDistanceContactsInfo = OptionsInfo["DockedPosesDistanceContactsInfo"]
 1876     
 1877     InputFileID = DockedPosesInfo["InputFilesIDs"][PDBFileIndex][InputFileIndex]
 1878     
 1879     PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID] = {}
 1880     
 1881     DockedPosesGroupName = PyMOLObjectNames["Chains"][ChainID]["DockedPosesGroup"]
 1882 
 1883     # Setup a docked poses level InputFile group...
 1884     DockedPosesInputFileGroupName = "%s.%s" % (DockedPosesGroupName, InputFileID)
 1885     PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID]["DockedPosesGroupName"] = DockedPosesInputFileGroupName
 1886     PyMOLObjectNames["Chains"][ChainID]["DockedPosesGroupMembers"].append(DockedPosesInputFileGroupName)
 1887 
 1888     PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID]["DockedPosesGroupMembers"] = []
 1889 
 1890     # Setup objects for docked poses...
 1891     PosesName = "%s.%s" % (DockedPosesInputFileGroupName, OptionsInfo["DockedPosesName"])
 1892     PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID]["Poses"] = PosesName
 1893     PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID]["DockedPosesGroupMembers"].append(PosesName)
 1894 
 1895     for GroupType in ["Pocket", "Pocket_Solvent", "Pocket_Inorganic"]:
 1896         GroupID = re.sub("_", "", GroupType)
 1897         GroupName = "%s.%s" % (DockedPosesInputFileGroupName, GroupType)
 1898         
 1899         GroupNameID = "%sGroup" % (GroupID)
 1900         GroupMembersID = "%sGroupMembers" % (GroupID)
 1901         
 1902         PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupNameID] = GroupName
 1903         PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID]["DockedPosesGroupMembers"].append(GroupName)
 1904     
 1905         PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupMembersID] = []
 1906         
 1907         PocketID = "%sPocket" % GroupID
 1908         PocketName = "%s.Pocket" % GroupName
 1909         PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][PocketID] = PocketName
 1910         PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupMembersID].append(PocketName)
 1911 
 1912         if DockedPosesInfo["DistanceContacts"] and re.match("^Pocket$", GroupType, re.I):
 1913             # Setup distance contacts group and add it to pocket group...
 1914             DistanceContactGroupName = "%s.Distance_Contacts" % GroupName
 1915             
 1916             DistanceContactGroupNameID = "%sDistanceContactsGroup" % GroupID
 1917             DistanceContactGroupMembersID = "%sDistanceContactsGroupMembers" % GroupID
 1918             
 1919             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][DistanceContactGroupNameID] = DistanceContactGroupName
 1920             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupMembersID].append(DistanceContactGroupName)
 1921 
 1922             # Setup distance contacts group members...
 1923             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][DistanceContactGroupMembersID] = []
 1924 
 1925             for ContactID in DockedPosesDistanceContactsInfo["ContactIDs"]:
 1926                 DistanceContactID = "%sPocketDistanceContacts%s" % (GroupID, ContactID)
 1927                 DistanceContactName = "%s.Distance_Contacts.%s" % (GroupName, ContactID)
 1928                 
 1929                 PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][DistanceContactID] = DistanceContactName
 1930                 PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][DistanceContactGroupMembersID].append(DistanceContactName)
 1931         
 1932         PolarContactsID = "%sPolarContacts" % GroupID
 1933         PolarContactsName = "%s.Polar_Contacts" % GroupName
 1934         PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][PolarContactsID] = PolarContactsName
 1935         PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupMembersID].append(PolarContactsName)
 1936         
 1937         if re.match("^Pocket_Inorganic$", GroupType, re.I):
 1938             PiCationContactsID = "%sPiCationContacts" % GroupID
 1939             PiCationContactsName = "%s.Pi_Cation_Contacts" % GroupName
 1940             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][PiCationContactsID] = PiCationContactsName
 1941             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupMembersID].append(PiCationContactsName)
 1942         
 1943         if re.match("^Pocket$", GroupType, re.I):
 1944             HydrophobicContactsID = "%sHydrophobicContacts" % GroupID
 1945             HydrophobicContactsName = "%s.Hydrophobic_Contacts" % GroupName
 1946             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][HydrophobicContactsID] = HydrophobicContactsName
 1947             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupMembersID].append(HydrophobicContactsName)
 1948             
 1949             PiPiContactsID = "%sPiPiContacts" % GroupID
 1950             PiPiContactsName = "%s.Pi_Pi_Contacts" % GroupName
 1951             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][PiPiContactsID] = PiPiContactsName
 1952             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupMembersID].append(PiPiContactsName)
 1953             
 1954             PiCationContactsID = "%sPiCationContacts" % GroupID
 1955             PiCationContactsName = "%s.Pi_Cation_Contacts" % GroupName
 1956             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][PiCationContactsID] = PiCationContactsName
 1957             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupMembersID].append(PiCationContactsName)
 1958             
 1959             HalogenContactsID = "%sHalogenContacts" % GroupID
 1960             HalogenContactsName = "%s.Halogen_Contacts" % GroupName
 1961             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][HalogenContactsID] = HalogenContactsName
 1962             PyMOLObjectNames["DockedPosesInputFile"][ChainID][InputFileID][GroupMembersID].append(HalogenContactsName)
 1963 
 1964 def RetrieveInfilesInfo():
 1965     """Retrieve information for input files."""
 1966 
 1967     InfilesInfo = {}
 1968     
 1969     InfilesInfo["InfilesNames"] = []
 1970     InfilesInfo["InfilesRoots"] = []
 1971     InfilesInfo["ChainsAndLigandsInfo"] = []
 1972     
 1973     for Infile in OptionsInfo["InfilesNames"]:
 1974         FileDir, FileName, FileExt = MiscUtil.ParseFileName(Infile)
 1975         InfileRoot = FileName
 1976         
 1977         ChainsAndLigandInfo = PyMOLUtil.GetChainsAndLigandsInfo(Infile, InfileRoot)
 1978         
 1979         InfilesInfo["InfilesNames"].append(Infile)
 1980         InfilesInfo["InfilesRoots"].append(InfileRoot)
 1981         InfilesInfo["ChainsAndLigandsInfo"].append(ChainsAndLigandInfo)
 1982     
 1983     OptionsInfo["InfilesInfo"] = InfilesInfo
 1984 
 1985 def RetrieveRefFileInfo():
 1986     """Retrieve information for ref file."""
 1987 
 1988     RefFileInfo = {}
 1989     if not OptionsInfo["Align"]:
 1990         OptionsInfo["RefFileInfo"] = RefFileInfo
 1991         return
 1992 
 1993     RefFile = OptionsInfo["RefFileName"]
 1994     
 1995     FileDir, FileName, FileExt = MiscUtil.ParseFileName(RefFile)
 1996     RefFileRoot = FileName
 1997     
 1998     if re.match("^FirstInputFile$", OptionsInfo["AlignRefFile"], re.I):
 1999         ChainsAndLigandInfo = OptionsInfo["InfilesInfo"]["ChainsAndLigandsInfo"][0]
 2000     else:
 2001         MiscUtil.PrintInfo("\nRetrieving chain and ligand information for alignment reference file %s..." % RefFile)
 2002         ChainsAndLigandInfo = PyMOLUtil.GetChainsAndLigandsInfo(RefFile, RefFileRoot)
 2003 
 2004     RefFileInfo["RefFileName"] = RefFile
 2005     RefFileInfo["RefFileRoot"] = RefFileRoot
 2006     RefFileInfo["PyMOLObjectName"] = "AlignRef_%s" % RefFileRoot
 2007     RefFileInfo["ChainsAndLigandsInfo"] = ChainsAndLigandInfo
 2008     
 2009     OptionsInfo["RefFileInfo"] = RefFileInfo
 2010 
 2011 def ProcessChainAndLigandIDs():
 2012     """Process specified chain and ligand IDs for infiles."""
 2013     
 2014     OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"] = []
 2015     
 2016     for FileIndex in range(0, len(OptionsInfo["InfilesInfo"]["InfilesNames"])):
 2017         MiscUtil.PrintInfo("\nProcessing specified chain and ligand IDs for input file %s..." % OptionsInfo["InfilesInfo"]["InfilesNames"][FileIndex])
 2018         
 2019         ChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["ChainsAndLigandsInfo"][FileIndex]
 2020         SpecifiedChainsAndLigandsInfo = PyMOLUtil.ProcessChainsAndLigandsOptionsInfo(ChainsAndLigandsInfo, "-c, --chainIDs", OptionsInfo["ChainIDs"], "-l, --ligandIDs", OptionsInfo["LigandIDs"])
 2021         ProcessResidueTypesAndSurfaceAndChainSelectionsOptions(FileIndex, SpecifiedChainsAndLigandsInfo)
 2022         
 2023         OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"].append(SpecifiedChainsAndLigandsInfo)
 2024         
 2025         CheckPresenceOfValidLigandIDs(ChainsAndLigandsInfo, SpecifiedChainsAndLigandsInfo)
 2026         
 2027 def ProcessResidueTypesAndSurfaceAndChainSelectionsOptions(FileIndex, SpecifiedChainsAndLigandsInfo):
 2028     """Process residue types, surface, and chian selections options for chains and pockets."""
 2029 
 2030     SpecifiedChainsAndLigandsInfo["ChainSurfaces"] = {}
 2031     SpecifiedChainsAndLigandsInfo["SurfaceChain"] = {}
 2032     SpecifiedChainsAndLigandsInfo["SurfaceChainElectrostatics"] = {}
 2033 
 2034     SpecifiedChainsAndLigandsInfo["PocketChainSelections"] = {}
 2035     SpecifiedChainsAndLigandsInfo["PocketChainSelectionsSurfaces"] = {}
 2036     SpecifiedChainsAndLigandsInfo["SurfacePocketChainSelections"] = {}
 2037     
 2038     SpecifiedChainsAndLigandsInfo["PocketSurfaces"] = {}
 2039     SpecifiedChainsAndLigandsInfo["SurfacePocket"] = {}
 2040     SpecifiedChainsAndLigandsInfo["SurfacePocketElectrostatics"] = {}
 2041     
 2042     SpecifiedChainsAndLigandsInfo["ResidueTypesChain"] = {}
 2043     SpecifiedChainsAndLigandsInfo["ResidueTypesPocket"] = {}
 2044 
 2045     SpecifiedChainsAndLigandsInfo["ChainSelections"] = {}
 2046     SpecifiedChainsAndLigandsInfo["ChainSelectionsSurfaces"] = {}
 2047     SpecifiedChainsAndLigandsInfo["SurfaceChainSelections"] = {}
 2048     
 2049     SpecifiedChainsAndLigandsInfo["DisulfideBondsChain"] = {}
 2050     SpecifiedChainsAndLigandsInfo["SaltBridgesChain"] = {}
 2051     
 2052     SpecifiedChainsAndLigandsInfo["BFactorChain"] = {}
 2053     
 2054     # Load infile...
 2055     Infile = OptionsInfo["InfilesInfo"]["InfilesNames"][FileIndex]
 2056     MolName = OptionsInfo["InfilesInfo"]["InfilesRoots"][FileIndex]
 2057     pymol.cmd.load(Infile, MolName)
 2058     
 2059     for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
 2060         AminoAcidsPresent = PyMOLUtil.AreAminoAcidResiduesPresent(MolName, ChainID)
 2061 
 2062         # Process BFactors for chains...
 2063         BFactorChain = True if re.match("^yes$", OptionsInfo["BFactorChain"], re.I) else False
 2064         SpecifiedChainsAndLigandsInfo["BFactorChain"][ChainID] = BFactorChain
 2065 
 2066         # Process surfaces for chains...
 2067         if re.match("^auto$", OptionsInfo["SurfaceChain"], re.I):
 2068             SurfaceChain = True if AminoAcidsPresent else False
 2069         else:
 2070             SurfaceChain = True if re.match("^yes$", OptionsInfo["SurfaceChain"], re.I) else False
 2071         SpecifiedChainsAndLigandsInfo["SurfaceChain"][ChainID] = SurfaceChain
 2072 
 2073         if re.match("^auto$", OptionsInfo["SurfaceChainElectrostatics"], re.I):
 2074             SurfaceChainElectrostatics = True if AminoAcidsPresent else False
 2075         else:
 2076             SurfaceChainElectrostatics = True if re.match("^yes$", OptionsInfo["SurfaceChainElectrostatics"], re.I) else False
 2077         SpecifiedChainsAndLigandsInfo["SurfaceChainElectrostatics"][ChainID] = SurfaceChainElectrostatics
 2078 
 2079         SpecifiedChainsAndLigandsInfo["ChainSurfaces"][ChainID] = SurfaceChain
 2080         
 2081         # Process disulfide bonds for chains...
 2082         if re.match("^auto$", OptionsInfo["DisulfideBondsChain"], re.I):
 2083             DisulfideBondsChain = True if AminoAcidsPresent else False
 2084         else:
 2085             DisulfideBondsChain = True if re.match("^yes$", OptionsInfo["DisulfideBondsChain"], re.I) else False
 2086         SpecifiedChainsAndLigandsInfo["DisulfideBondsChain"][ChainID] = DisulfideBondsChain
 2087 
 2088         # Process salt bridges bonds for chains...
 2089         if re.match("^auto$", OptionsInfo["SaltBridgesChain"], re.I):
 2090             SaltBridgesChain = True if AminoAcidsPresent else False
 2091         else:
 2092             SaltBridgesChain = True if re.match("^yes$", OptionsInfo["SaltBridgesChain"], re.I) else False
 2093         SpecifiedChainsAndLigandsInfo["SaltBridgesChain"][ChainID] = SaltBridgesChain
 2094 
 2095         # Process residue types for chains...
 2096         if re.match("^auto$", OptionsInfo["ResidueTypesChain"], re.I):
 2097             ResidueTypesChain = True if AminoAcidsPresent else False
 2098         else:
 2099             ResidueTypesChain = True if re.match("^yes$", OptionsInfo["ResidueTypesChain"], re.I) else False
 2100         SpecifiedChainsAndLigandsInfo["ResidueTypesChain"][ChainID] = ResidueTypesChain
 2101 
 2102         # Process chain selections...
 2103         ChainSelections = True if len(OptionsInfo["ChainSelectionsInfo"]["Names"]) else False
 2104         SpecifiedChainsAndLigandsInfo["ChainSelections"][ChainID] = ChainSelections
 2105         
 2106         # Process surfaces for chain selections...
 2107         if re.match("^auto$", OptionsInfo["SelectionsChainSurface"], re.I):
 2108             SurfaceChainSelections = True if AminoAcidsPresent else False
 2109         else:
 2110             SurfaceChainSelections = True if re.match("^yes$", OptionsInfo["SelectionsChainSurface"], re.I) else False
 2111         SpecifiedChainsAndLigandsInfo["SurfaceChainSelections"][ChainID] = SurfaceChainSelections
 2112         
 2113         SpecifiedChainsAndLigandsInfo["ChainSelectionsSurfaces"][ChainID] = SurfaceChainSelections
 2114 
 2115         # Process selections, residue types and surfaces for pockets...
 2116         SpecifiedChainsAndLigandsInfo["PocketChainSelections"][ChainID] = {}
 2117         SpecifiedChainsAndLigandsInfo["PocketChainSelectionsSurfaces"][ChainID] = {}
 2118         SpecifiedChainsAndLigandsInfo["SurfacePocketChainSelections"][ChainID] = {}
 2119         
 2120         SpecifiedChainsAndLigandsInfo["PocketSurfaces"][ChainID] = {}
 2121         SpecifiedChainsAndLigandsInfo["SurfacePocket"][ChainID] = {}
 2122         SpecifiedChainsAndLigandsInfo["SurfacePocketElectrostatics"][ChainID] = {}
 2123         
 2124         SpecifiedChainsAndLigandsInfo["ResidueTypesPocket"][ChainID] = {}
 2125         
 2126         for LigandID in SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]:
 2127             #Process pocket chain selections and surfaces...
 2128             PocketChainSelections = True if len(OptionsInfo["PocketChainSelectionsInfo"]["Names"]) else False
 2129             SpecifiedChainsAndLigandsInfo["PocketChainSelections"][ChainID][LigandID] = PocketChainSelections
 2130             
 2131             # Process surfaces for chain selections...
 2132             if re.match("^auto$", OptionsInfo["SelectionsPocketSurface"], re.I):
 2133                 PocketChainSelectionsSurface = True if AminoAcidsPresent else False
 2134             else:
 2135                 PocketChainSelectionsSurface = True if re.match("^yes$", OptionsInfo["SelectionsPocketSurface"], re.I) else False
 2136             
 2137             SpecifiedChainsAndLigandsInfo["PocketChainSelectionsSurfaces"][ChainID][LigandID] = PocketChainSelectionsSurface
 2138             
 2139             SpecifiedChainsAndLigandsInfo["SurfacePocketChainSelections"][ChainID][LigandID] = PocketChainSelectionsSurface
 2140             
 2141             #Process pocket surfaces...
 2142             if re.match("^auto$", OptionsInfo["PocketSurface"], re.I):
 2143                 PocketSurface = True if AminoAcidsPresent else False
 2144             else:
 2145                 PocketSurface = True if re.match("^yes$", OptionsInfo["PocketSurface"], re.I) else False
 2146             SpecifiedChainsAndLigandsInfo["SurfacePocket"][ChainID][LigandID] = PocketSurface
 2147             
 2148             if re.match("^auto$", OptionsInfo["PocketSurfaceElectrostatics"], re.I):
 2149                 PocketSurfaceElectrostatics = True if AminoAcidsPresent else False
 2150             else:
 2151                 PocketSurfaceElectrostatics = True if re.match("^yes$", OptionsInfo["PocketSurfaceElectrostatics"], re.I) else False
 2152             SpecifiedChainsAndLigandsInfo["SurfacePocketElectrostatics"][ChainID][LigandID] = PocketSurfaceElectrostatics
 2153 
 2154             #Process pocket residue types...
 2155             SpecifiedChainsAndLigandsInfo["PocketSurfaces"][ChainID][LigandID] = PocketSurface
 2156         
 2157             if re.match("^auto$", OptionsInfo["PocketResidueTypes"], re.I):
 2158                 PocketResidueTypes = True if AminoAcidsPresent else False
 2159             else:
 2160                 PocketResidueTypes = True if re.match("^yes$", OptionsInfo["PocketResidueTypes"], re.I) else False
 2161             SpecifiedChainsAndLigandsInfo["ResidueTypesPocket"][ChainID][LigandID] = PocketResidueTypes
 2162     
 2163     # Delete loaded object...
 2164     pymol.cmd.delete(MolName)
 2165 
 2166 def GetChainAloneResidueTypesStatus(FileIndex, ChainID):
 2167     """Get status of residue types for chain alone object."""
 2168 
 2169     Status = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["ResidueTypesChain"][ChainID]
 2170     
 2171     return Status
 2172 
 2173 def GetChainAloneBFactorStatus(FileIndex, ChainID):
 2174     """Get status of B factors for chain alone object."""
 2175 
 2176     Status = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["BFactorChain"][ChainID]
 2177     
 2178     return Status
 2179 
 2180 def GetChainAloneDisulfideBondsStatus(FileIndex, ChainID):
 2181     """Get status of disulfide bonds for chain alone object."""
 2182     
 2183     Status = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["DisulfideBondsChain"][ChainID]
 2184     
 2185     return Status
 2186 
 2187 def GetChainAloneSaltBridgesStatus(FileIndex, ChainID):
 2188     """Get status of salt bridges for chain alone object."""
 2189     
 2190     Status = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["SaltBridgesChain"][ChainID]
 2191     
 2192     return Status
 2193 
 2194 def GetChainAloneDockedPosesStatus(FileIndex, ChainID):
 2195     """Get status of docked for chain alone object."""
 2196     
 2197     Status = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["DockedPoses"][ChainID]
 2198     
 2199     return Status
 2200 
 2201 def GetTrajectoriesStatus(FileIndex):
 2202     """Get status of trajectories for a PDB object."""
 2203 
 2204     if OptionsInfo["TrajectoriesInfo"] is None:
 2205         return False
 2206     
 2207     Status = True if FileIndex in OptionsInfo["TrajectoriesInfo"]["PDBFileIndices"] else False
 2208     
 2209     return Status
 2210     
 2211 def GetPocketResidueTypesStatus(FileIndex, ChainID, LigandID):
 2212     """Get status of residue types for a pocket."""
 2213 
 2214     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["ResidueTypesPocket"][ChainID][LigandID]
 2215 
 2216 def GetChainAloneContainsSurfacesStatus(FileIndex, ChainID):
 2217     """Get status of surfaces present in chain alone object."""
 2218 
 2219     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["ChainSurfaces"][ChainID]
 2220 
 2221 def GetPocketContainsSelectionsStatus(FileIndex, ChainID, LigandID):
 2222     """Get status of selections present in a pocket."""
 2223 
 2224     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["PocketChainSelections"][ChainID][LigandID]
 2225 
 2226 def GetPocketContainsSurfaceStatus(FileIndex, ChainID, LigandID):
 2227     """Get status of surfaces present in a pocket."""
 2228 
 2229     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["PocketSurfaces"][ChainID][LigandID]
 2230 
 2231 def GetChainAloneSurfaceChainStatus(FileIndex, ChainID):
 2232     """Get status of hydrophobic surfaces for chain alone object."""
 2233 
 2234     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["SurfaceChain"][ChainID]
 2235 
 2236 def GetChainAloneSurfaceChainElectrostaticsStatus(FileIndex, ChainID):
 2237     """Get status of electrostatics surfaces for chain alone object."""
 2238 
 2239     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["SurfaceChainElectrostatics"][ChainID]
 2240 
 2241 def GetPocketSelectionSurfaceChainStatus(FileIndex, ChainID, LigandID):
 2242     """Get status of surfaces for a pocket selection in a chain."""
 2243 
 2244     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["SurfacePocketChainSelections"][ChainID][LigandID]
 2245 
 2246 def GetPocketSurfaceChainStatus(FileIndex, ChainID, LigandID):
 2247     """Get status of hydrophobic surfaces for a pocket."""
 2248 
 2249     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["SurfacePocket"][ChainID][LigandID]
 2250 
 2251 def GetPocketSurfaceChainElectrostaticsStatus(FileIndex, ChainID, LigandID):
 2252     """Get status of hydrophobic surfaces for a pocket."""
 2253 
 2254     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["SurfacePocketElectrostatics"][ChainID][LigandID]
 2255 
 2256 def GetChainAloneContainsSelectionsStatus(FileIndex, ChainID):
 2257     """Get status of selections present in chain alone object."""
 2258     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["ChainSelections"][ChainID]
 2259 
 2260 def GetChainAloneContainsChainSelectionSurfacesStatus(FileIndex, ChainID):
 2261     """Get status of chain selections surfaces present in chain alone object."""
 2262     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["ChainSelectionsSurfaces"][ChainID]
 2263 
 2264 def GetChainAloneSurfaceChainSelectionStatus(FileIndex, ChainID):
 2265     """Get status of hydrophobic surfaces for chain alone object."""
 2266     return OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]["SurfaceChainSelections"][ChainID]
 2267 
 2268 def CheckPresenceOfValidLigandIDs(ChainsAndLigandsInfo, SpecifiedChainsAndLigandsInfo):
 2269     """Check presence of valid ligand IDs."""
 2270 
 2271     MiscUtil.PrintInfo("\nSpecified chain IDs: %s" % (", ".join(SpecifiedChainsAndLigandsInfo["ChainIDs"])))
 2272     
 2273     for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
 2274         if len (SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]):
 2275             MiscUtil.PrintInfo("Chain ID: %s; Specified LigandIDs: %s" % (ChainID, ", ".join(SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID])))
 2276         else:
 2277             MiscUtil.PrintInfo("Chain IDs: %s; Specified LigandIDs: None" % (ChainID))
 2278             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))
 2279 
 2280 def RetrieveFirstChainID(FileIndex):
 2281     """Get first chain ID."""
 2282     
 2283     ChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["ChainsAndLigandsInfo"][FileIndex]
 2284     
 2285     FirstChainID = None
 2286     if len(ChainsAndLigandsInfo["ChainIDs"]):
 2287         FirstChainID = ChainsAndLigandsInfo["ChainIDs"][0]
 2288     
 2289     return FirstChainID
 2290 
 2291 def ProcessDockedPoses():
 2292     """Process docked poses."""
 2293 
 2294     OptionsInfo["DockedPosesGroupName"] = Options["--dockedPosesGroupName"]
 2295     OptionsInfo["DockedPosesName"] = Options["--dockedPosesName"]
 2296     
 2297     DockedPosesInfo = ProcessDockedPosesOptionsInfo("--dockedPoses", OptionsInfo["DockedPoses"])
 2298     OptionsInfo["DockedPosesInfo"] = DockedPosesInfo
 2299     
 2300     ProcessDockedPosesInfoForInfiles()
 2301     
 2302     OptionsInfo["DockedPosesDistanceContactsCutoffs"] = Options["--dockedPosesDistanceContactsCutoffs"]
 2303     OptionsInfo["DockedPosesDistanceContactsColor"] = Options["--dockedPosesDistanceContactsColor"]
 2304     
 2305     DockedPosesDistanceContactsInfo = ProcessDockedPosesDistanceContactsOptionsInfo()
 2306     OptionsInfo["DockedPosesDistanceContactsInfo"] = DockedPosesDistanceContactsInfo
 2307 
 2308     # Setup distance conatcts status for dockes poses...
 2309     if DockedPosesInfo is not None:
 2310         DockedPosesInfo["DistanceContacts"] = False
 2311         if DockedPosesDistanceContactsInfo is not None:
 2312             if len(DockedPosesDistanceContactsInfo["ContactIDs"]):
 2313                 DockedPosesInfo["DistanceContacts"] = True
 2314 
 2315 def ProcessDockedPosesInfoForInfiles():
 2316     """Process docked poses info for infiles."""
 2317 
 2318     DockedPosesInfo = OptionsInfo["DockedPosesInfo"]
 2319     for FileIndex in range(0, len(OptionsInfo["InfilesInfo"]["InfilesNames"])):
 2320         SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][FileIndex]
 2321         ProcessDockedPosesInfoForInfileAndChains(FileIndex, SpecifiedChainsAndLigandsInfo, DockedPosesInfo)
 2322 
 2323 def ProcessDockedPosesInfoForInfileAndChains(FileIndex, SpecifiedChainsAndLigandsInfo, DockedPosesInfo):
 2324     """Process docked poses info for a specific infile."""
 2325     
 2326     SpecifiedChainsAndLigandsInfo["DockedPoses"] = {}
 2327     SpecifiedChainsAndLigandsInfo["DockedPosesInputFiles"] = {}
 2328     
 2329     for ChainID in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
 2330         DockedPoses = False
 2331         if DockedPosesInfo is not None:
 2332             if FileIndex in DockedPosesInfo["PDBFileIndices"]:
 2333                 if ChainID == DockedPosesInfo['ChainID'][FileIndex]:
 2334                     DockedPoses = True
 2335         
 2336         SpecifiedChainsAndLigandsInfo["DockedPoses"][ChainID] = DockedPoses
 2337         
 2338         SpecifiedChainsAndLigandsInfo["DockedPosesInputFiles"][ChainID] = []
 2339         if DockedPoses:
 2340             SpecifiedChainsAndLigandsInfo["DockedPosesInputFiles"][ChainID].extend(DockedPosesInfo['InputFiles'][FileIndex])
 2341 
 2342 def ProcessDockedPosesOptionsInfo(DockedPosesOptionName, DockedPosesOptionValue):
 2343     """Process docked poses options info."""
 2344 
 2345     DockedPoses = DockedPosesOptionValue
 2346     if re.match("^none$", DockedPoses, re.I):
 2347         return None
 2348 
 2349     MiscUtil.PrintInfo("\nProcessing docked poses...")
 2350     
 2351     # Initialize docked poses info...
 2352     DockedPosesInfo = {}
 2353     DockedPosesInfo["PDBFileIndices"] = []
 2354     
 2355     DockedPosesInfo["PDBFile"] = {}
 2356     DockedPosesInfo["ChainID"] = {}
 2357     DockedPosesInfo["LigandID"] = {}
 2358     DockedPosesInfo["UseInputFileAsLigandID"] = {}
 2359     DockedPosesInfo["InputFiles"] = {}
 2360     DockedPosesInfo["InputFilesRoots"] = {}
 2361     DockedPosesInfo["InputFilesIDs"] = {}
 2362     
 2363     # Parse docked poses values...
 2364     DockedPosesWords = DockedPoses.split(",")
 2365     if len(DockedPosesWords) % 4:
 2366         MiscUtil.PrintError("The number of comma delimited docked poses values, %d, specified using \"%s\" option must be a multple of 4." % (len(DockedPosesWords), DockedPosesOptionName))
 2367     
 2368     # Validate and process specified values...
 2369     for Index in range(0, len(DockedPosesWords), 4):
 2370         PDBFile = DockedPosesWords[Index].strip()
 2371         ChainID = DockedPosesWords[Index + 1].strip()
 2372         LigandID = DockedPosesWords[Index + 2].strip()
 2373         InputFiles = DockedPosesWords[Index + 3].strip()
 2374         
 2375         InputFiles = re.sub("[ ]+", " ", InputFiles)
 2376         InputFiles = InputFiles.split(" ")
 2377 
 2378         # Process PDB file...
 2379         MiscUtil.ValidateOptionFilePath("--dockedPoses", PDBFile)
 2380         
 2381         PDBFileIndex = None
 2382         for FileIndex in range(0, len(OptionsInfo["InfilesInfo"]["InfilesNames"])):
 2383             PDBInfile = OptionsInfo["InfilesInfo"]["InfilesNames"][FileIndex]
 2384             if PDBFile == PDBInfile:
 2385                 PDBFileIndex = FileIndex
 2386                 break
 2387         if PDBFileIndex is None:
 2388             MiscUtil.PrintError("The PDB file specified, %s, using option \"--dockedPoses\" is not valid. It must be specified as an input file." % (PDBFile))
 2389 
 2390         if PDBFileIndex in DockedPosesInfo['PDBFileIndices']:
 2391             MiscUtil.PrintError("The PDB file specified, %s, using option \"--dockedPoses\" is not valid. It is a duplicate and has already been specified." % (PDBFile))
 2392 
 2393         # Process chain ID...
 2394         SpecifiedChainsAndLigandsInfo = OptionsInfo["InfilesInfo"]["SpecifiedChainsAndLigandsInfo"][PDBFileIndex]
 2395         if ChainID not in SpecifiedChainsAndLigandsInfo["ChainIDs"]:
 2396             MiscUtil.PrintError("The chain ID, %s, specified for PDB file, %s, using option \"--dockedPoses\" is not valid. It must be present in valid chain IDs corresponding to option \"-c, --chainIDs\" ." % (ChainID, PDBFile))
 2397 
 2398         # Process ligand ID...
 2399         UseInputFileAsLigandID = True if re.match("^UseInputFile$", LigandID, re.I) else False
 2400         if not UseInputFileAsLigandID:
 2401             if LigandID not in SpecifiedChainsAndLigandsInfo["LigandIDs"][ChainID]:
 2402                 MiscUtil.PrintError("The ligand ID, %s, specified for chain ID, %s, and PDB file, %s, using option \"--dockedPoses\" is not valid. It must be present in valid ligand IDs corresponding to option \"-l, --ligandIDs\" ." % (LigandID, ChainID, PDBFile))
 2403 
 2404         # Process input files...
 2405         InputFilesRoots = []
 2406         InputFilesIDs = []
 2407         for InputFile in InputFiles:
 2408             MiscUtil.ValidateOptionFilePath("--dockedPoses", InputFile)
 2409             MiscUtil.ValidateOptionFileExt("--dockedPoses", InputFile, "sdf sd")
 2410             
 2411             FileDir, FileName, FileExt = MiscUtil.ParseFileName(InputFile)
 2412             InputFileRoot = FileName
 2413             
 2414             # Clean up input file names for generating PyMOL object names...
 2415             InputFileID = re.sub("[^a-zA-Z0-9]", "_", FileName)
 2416             
 2417             if InputFileRoot in InputFilesRoots:
 2418                 MiscUtil.PrintError("The input file specified, %s, using option \"--dockedPoses\" is not valid. It is a duplicate and has already been specified for a PDB file." % (InputFile))
 2419             
 2420             InputFilesRoots.append(InputFileRoot)
 2421             InputFilesIDs.append(InputFileID)
 2422         
 2423         # Track values...
 2424         DockedPosesInfo['PDBFileIndices'].append(PDBFileIndex)
 2425 
 2426         DockedPosesInfo["PDBFile"][PDBFileIndex] = PDBFile
 2427         DockedPosesInfo["ChainID"][PDBFileIndex] = ChainID
 2428         
 2429         DockedPosesInfo["LigandID"][PDBFileIndex] = LigandID
 2430         DockedPosesInfo["UseInputFileAsLigandID"][PDBFileIndex] = UseInputFileAsLigandID
 2431         
 2432         DockedPosesInfo["InputFiles"][PDBFileIndex] = InputFiles
 2433         DockedPosesInfo["InputFilesRoots"][PDBFileIndex] = InputFilesRoots
 2434         DockedPosesInfo["InputFilesIDs"][PDBFileIndex] = InputFilesIDs
 2435 
 2436     return DockedPosesInfo
 2437 
 2438 def ProcessDockedPosesDistanceContactsOptionsInfo():
 2439     """Process dockes poses distance contacts info. """
 2440 
 2441     DistanceContactsCutoffs = OptionsInfo["DockedPosesDistanceContactsCutoffs"]
 2442     if re.match("^none$", DistanceContactsCutoffs):
 2443         return None
 2444 
 2445     DistanceContactsInfo = {}
 2446     DistanceContactsInfo["ContactIDs"] = []
 2447     DistanceContactsInfo["ContactCutoff"] = {}
 2448     
 2449     DistanceContactsCutoffs = re.sub(" ", "", DistanceContactsCutoffs)
 2450     if not DistanceContactsCutoffs:
 2451         MiscUtil.PrintError("No value specified using \"--dockedPosesDistanceContactsCutoffs\" option.")
 2452     
 2453     ContactCutoffValues = DistanceContactsCutoffs.split(",")
 2454     for Index, ContactCutoff in enumerate(ContactCutoffValues):
 2455         MiscUtil.ValidateOptionFloatValue("--dockedPosesDistanceContactsCutoffs", ContactCutoff, {">" : 0.0, "<=": OptionsInfo["PocketDistanceCutoff"]})
 2456         ContactCutoff = float(ContactCutoff.strip())
 2457         
 2458         ContactID = "Contact%s_At_%s" % ((Index + 1),ContactCutoff)
 2459         ContactID = re.sub("\.", "pt", ContactID)
 2460 
 2461         DistanceContactsInfo["ContactIDs"].append(ContactID)
 2462         DistanceContactsInfo["ContactCutoff"][ContactID] = ContactCutoff
 2463 
 2464     return DistanceContactsInfo
 2465     
 2466 def ProcessTrajectories():
 2467     """Process trajectories."""
 2468 
 2469     TrajectoriesInfo = ProcessTrajectoriesOptionsInfo("--Trajectories", OptionsInfo["Trajectories"])
 2470     OptionsInfo["TrajectoriesInfo"] = TrajectoriesInfo
 2471 
 2472 def ProcessTrajectoriesOptionsInfo(TrajectoriesOptionName, TrajectoriesOptionValue):
 2473     """Process trajectories options info."""
 2474 
 2475     Trajectories = TrajectoriesOptionValue
 2476     if re.match("^none$", Trajectories, re.I):
 2477         return None
 2478 
 2479     MiscUtil.PrintInfo("\nProcessing trajectories...")
 2480     
 2481     # Initialize trajectories info...
 2482     TrajectoriesInfo = {}
 2483     TrajectoriesInfo["PDBFileIndices"] = []
 2484     
 2485     TrajectoriesInfo["PDBFile"] = {}
 2486     TrajectoriesInfo["TrajFiles"] = {}
 2487     TrajectoriesInfo["TrajFilesRoots"] = {}
 2488     TrajectoriesInfo["TrajFilesIDs"] = {}
 2489     
 2490     # Parse trajectories values...
 2491     TrajectoriesWords = Trajectories.split(",")
 2492     if len(TrajectoriesWords) % 2:
 2493         MiscUtil.PrintError("The number of comma delimited trajectories values, %d, specified using \"%s\" option must be a multple of 2." % (len(TrajectoriesWords), TrajectoriesOptionName))
 2494     
 2495     # Validate and process specified values...
 2496     for Index in range(0, len(TrajectoriesWords), 2):
 2497         PDBFile = TrajectoriesWords[Index].strip()
 2498         TrajFiles = TrajectoriesWords[Index + 1].strip()
 2499         
 2500         TrajFiles = re.sub("[ ]+", " ", TrajFiles)
 2501         TrajFiles = TrajFiles.split(" ")
 2502 
 2503         # Process PDB file...
 2504         MiscUtil.ValidateOptionFilePath(TrajectoriesOptionName, PDBFile)
 2505         
 2506         PDBFileIndex = None
 2507         for FileIndex in range(0, len(OptionsInfo["InfilesInfo"]["InfilesNames"])):
 2508             PDBInfile = OptionsInfo["InfilesInfo"]["InfilesNames"][FileIndex]
 2509             if PDBFile == PDBInfile:
 2510                 PDBFileIndex = FileIndex
 2511                 break
 2512         if PDBFileIndex is None:
 2513             MiscUtil.PrintError("The topology PDB file specified, %s, using option \"%s\" is not valid. It must be specified as an input file." % (PDBFile, TrajectoriesOptionName))
 2514 
 2515         if PDBFileIndex in TrajectoriesInfo['PDBFileIndices']:
 2516             MiscUtil.PrintError("The topology PDB file specified, %s, using option \"%s\" is not valid. It is a duplicate and has already been specified." % (PDBFile, TrajectoriesOptionName))
 2517         
 2518         # Process trajectory files...
 2519         TrajFilesRoots = []
 2520         TrajFilesIDs = []
 2521         for TrajFile in TrajFiles:
 2522             MiscUtil.ValidateOptionFilePath(TrajectoriesOptionName, TrajFile)
 2523             
 2524             FileDir, FileName, FileExt = MiscUtil.ParseFileName(TrajFile)
 2525             TrajFileRoot = FileName
 2526             
 2527             # Clean up trajectory file names for generating PyMOL object names...
 2528             TrajFileID = re.sub("[^a-zA-Z0-9]", "_", FileName)
 2529             
 2530             if TrajFileRoot in TrajFilesRoots:
 2531                 MiscUtil.PrintError("The trajectory file specified, %s, using option \"%s\" is not valid. It is a duplicate and has already been specified for a PDB file." % (TrajFile, TrajectoriesOptionName))
 2532             
 2533             TrajFilesRoots.append(TrajFileRoot)
 2534             TrajFilesIDs.append(TrajFileID)
 2535         
 2536         # Track values...
 2537         TrajectoriesInfo['PDBFileIndices'].append(PDBFileIndex)
 2538 
 2539         TrajectoriesInfo["PDBFile"][PDBFileIndex] = PDBFile
 2540         
 2541         TrajectoriesInfo["TrajFiles"][PDBFileIndex] = TrajFiles
 2542         TrajectoriesInfo["TrajFilesRoots"][PDBFileIndex] = TrajFilesRoots
 2543         TrajectoriesInfo["TrajFilesIDs"][PDBFileIndex] = TrajFilesIDs
 2544         
 2545     return TrajectoriesInfo
 2546     
 2547 def ProcessResidueTypes():
 2548     """Process residue types."""
 2549 
 2550     ResidueTypesNamesInfo, ResidueTypesParamsInfo = PyMOLUtil.ProcessResidueTypesOptionsInfo("-r, --residueTypes", OptionsInfo["ResidueTypes"])
 2551     OptionsInfo["ResidueTypesNames"] = ResidueTypesNamesInfo
 2552     OptionsInfo["ResidueTypesParams"] = ResidueTypesParamsInfo
 2553 
 2554 def ProcessSaltBridgesChainResidues():
 2555     """Process salt bridges chain residues."""
 2556 
 2557     SaltBridgesChainResiduesInfo = PyMOLUtil.ProcessSaltBridgesChainResiduesOptionsInfo("--saltBridgesChainResidues", OptionsInfo["SaltBridgesChainResidues"])
 2558     OptionsInfo["SaltBridgesChainResiduesInfo"] = SaltBridgesChainResiduesInfo
 2559 
 2560 def ProcessSurfaceAtomTypesColors():
 2561     """Process surface atom types colors."""
 2562 
 2563     AtomTypesColorNamesInfo = PyMOLUtil.ProcessSurfaceAtomTypesColorsOptionsInfo("--surfaceAtomTypesColors", OptionsInfo["SurfaceAtomTypesColors"])
 2564     OptionsInfo["AtomTypesColorNames"] = AtomTypesColorNamesInfo
 2565 
 2566 def ProcessPockectChainSelections():
 2567     """Process custom selections for pocket chains."""
 2568 
 2569     PocketChainSelectionsInfo = PyMOLUtil.ProcessChainSelectionsOptionsInfo("--selectionsPocket", OptionsInfo["SelectionsPocket"])
 2570     OptionsInfo["PocketChainSelectionsInfo"] = PocketChainSelectionsInfo
 2571 
 2572 def ProcessChainSelections():
 2573     """Process custom selections for chains."""
 2574 
 2575     ChainSelectionsInfo = PyMOLUtil.ProcessChainSelectionsOptionsInfo("--selectionsChain", OptionsInfo["SelectionsChain"])
 2576     OptionsInfo["ChainSelectionsInfo"] = ChainSelectionsInfo
 2577 
 2578 def ProcessOptions():
 2579     """Process and validate command line arguments and options."""
 2580 
 2581     MiscUtil.PrintInfo("Processing options...")
 2582     
 2583     # Validate options...
 2584     ValidateOptions()
 2585     
 2586     OptionsInfo["Align"] = True if re.match("^Yes$", Options["--align"], re.I) else False
 2587     OptionsInfo["AlignMethod"] = Options["--alignMethod"].lower()
 2588     OptionsInfo["AlignMode"] = Options["--alignMode"]
 2589     
 2590     OptionsInfo["AllowEmptyObjects"] = True if re.match("^Yes$", Options["--allowEmptyObjects"], re.I) else False
 2591     
 2592     OptionsInfo["BFactorChain"] = Options["--BFactorChain"]
 2593     OptionsInfo["BFactorColorPalette"] = Options["--BFactorColorPalette"]
 2594     
 2595     OptionsInfo["Infiles"] = Options["--infiles"]
 2596     OptionsInfo["InfilesNames"] =  Options["--infileNames"]
 2597 
 2598     OptionsInfo["AlignRefFile"] = Options["--alignRefFile"]
 2599     if re.match("^FirstInputFile$", Options["--alignRefFile"], re.I):
 2600         OptionsInfo["RefFileName"] = OptionsInfo["InfilesNames"][0]
 2601     else:
 2602         OptionsInfo["RefFileName"] = Options["--alignRefFile"]
 2603     
 2604     OptionsInfo["IgnoreHydrogens"] = True if re.match("^Yes$", Options["--ignoreHydrogens"], re.I) else False
 2605     
 2606     OptionsInfo["Overwrite"] = Options["--overwrite"]
 2607     OptionsInfo["PMLOut"] = True if re.match("^Yes$", Options["--PMLOut"], re.I) else False
 2608     
 2609     OptionsInfo["Outfile"] = Options["--outfile"]
 2610     FileDir, FileName, FileExt = MiscUtil.ParseFileName(OptionsInfo["Outfile"])
 2611     OptionsInfo["PSEOut"] = False 
 2612     if re.match("^pml$", FileExt, re.I):
 2613         OptionsInfo["PMLOutfile"] = OptionsInfo["Outfile"] 
 2614         OptionsInfo["PMEOutfile"] = re.sub(".pml$", ".pme", OptionsInfo["Outfile"]) 
 2615     elif re.match("^pse$", FileExt, re.I):
 2616         OptionsInfo["PSEOut"] = True 
 2617         OptionsInfo["PSEOutfile"] = OptionsInfo["Outfile"] 
 2618         OptionsInfo["PMLOutfile"] = re.sub(".pse$", ".pml", OptionsInfo["Outfile"]) 
 2619         if os.path.exists(OptionsInfo["PMLOutfile"]) and (not OptionsInfo["Overwrite"]):
 2620             MiscUtil.PrintError("The intermediate output file to be generated, %s, already exist. Use option \"--ov\" or \"--overwrite\" and try again." % OptionsInfo["PMLOutfile"] )
 2621 
 2622     OptionsInfo["DisulfideBondsChain"] = Options["--disulfideBondsChain"]
 2623     
 2624     OptionsInfo["LabelFontID"] = int(Options["--labelFontID"])
 2625     
 2626     OptionsInfo["PocketContactsLigandColor"] = Options["--pocketContactsLigandColor"]
 2627     OptionsInfo["PocketContactsLigandHydrophobicColor"] = Options["--pocketContactsLigandHydrophobicColor"]
 2628     OptionsInfo["PocketContactsLigandPiPiColor"] = Options["--pocketContactsLigandPiPiColor"]
 2629     OptionsInfo["PocketContactsLigandPiCationColor"] = Options["--pocketContactsLigandPiCationColor"]
 2630     OptionsInfo["PocketContactsLigandHalogenColor"] = Options["--pocketContactsLigandHalogenColor"]
 2631     
 2632     OptionsInfo["PocketContactsSolventColor"] = Options["--pocketContactsSolventColor"]
 2633     
 2634     OptionsInfo["PocketContactsInorganicColor"] = Options["--pocketContactsInorganicColor"]
 2635     OptionsInfo["PocketContactsInorganicPiCationColor"] = Options["--pocketContactsInorganicPiCationColor"]
 2636 
 2637     OptionsInfo["PocketContactsCutoff"] = float(Options["--pocketContactsCutoff"])
 2638     OptionsInfo["PocketDistanceCutoff"] = float(Options["--pocketDistanceCutoff"])
 2639     
 2640     OptionsInfo["PocketLabelColor"] = Options["--pocketLabelColor"]
 2641     
 2642     OptionsInfo["PocketResidueTypes"] = Options["--pocketResidueTypes"]
 2643     OptionsInfo["PocketSurface"] = Options["--pocketSurface"]
 2644     OptionsInfo["PocketSurfaceElectrostatics"] = Options["--pocketSurfaceElectrostatics"]
 2645     
 2646     OptionsInfo["ResidueTypesChain"] = Options["--residueTypesChain"]
 2647     OptionsInfo["ResidueTypes"] = Options["--residueTypes"]
 2648     ProcessResidueTypes()
 2649 
 2650     OptionsInfo["SaltBridgesChain"] = Options["--saltBridgesChain"]
 2651     OptionsInfo["SaltBridgesChainContactsColor"] = Options["--saltBridgesChainContactsColor"]
 2652     OptionsInfo["SaltBridgesChainCutoff"] = float(Options["--saltBridgesChainCutoff"])
 2653     OptionsInfo["SaltBridgesChainResidues"] = Options["--saltBridgesChainResidues"]
 2654     ProcessSaltBridgesChainResidues()
 2655     
 2656     OptionsInfo["SelectionsChain"] = Options["--selectionsChain"]
 2657     OptionsInfo["SelectionsChainSurface"] = Options["--selectionsChainSurface"]
 2658     OptionsInfo["SelectionsChainStyle"] = Options["--selectionsChainStyle"]
 2659     ProcessChainSelections()
 2660     
 2661     OptionsInfo["SelectionsPocket"] = Options["--selectionsPocket"]
 2662     OptionsInfo["SelectionsPocketSurface"] = Options["--selectionsPocketSurface"]
 2663     OptionsInfo["SelectionsPocketStyle"] = Options["--selectionsPocketStyle"]
 2664     ProcessPockectChainSelections()
 2665     
 2666     OptionsInfo["SurfaceChain"] = Options["--surfaceChain"]
 2667     OptionsInfo["SurfaceChainElectrostatics"] = Options["--surfaceChainElectrostatics"]
 2668     
 2669     OptionsInfo["SurfaceChainComplex"] = True if re.match("^Yes$", Options["--surfaceChainComplex"], re.I) else False
 2670     OptionsInfo["SurfaceComplex"] = True if re.match("^Yes$", Options["--surfaceComplex"], re.I) else False
 2671     
 2672     OptionsInfo["SurfaceColor"] = Options["--surfaceColor"]
 2673     OptionsInfo["SurfaceColorPalette"] = Options["--surfaceColorPalette"]
 2674     OptionsInfo["SurfaceAtomTypesColors"] = Options["--surfaceAtomTypesColors"]
 2675     ProcessSurfaceAtomTypesColors()
 2676     
 2677     OptionsInfo["SurfaceTransparency"] = float(Options["--surfaceTransparency"])
 2678     
 2679     RetrieveInfilesInfo()
 2680     RetrieveRefFileInfo()
 2681     
 2682     OptionsInfo["ChainIDs"] = Options["--chainIDs"]
 2683     OptionsInfo["LigandIDs"] = Options["--ligandIDs"]
 2684     
 2685     ProcessChainAndLigandIDs()
 2686     
 2687     OptionsInfo["DockedPoses"] = Options["--dockedPoses"]
 2688     ProcessDockedPoses()
 2689 
 2690     OptionsInfo["Trajectories"] = Options["--trajectories"]
 2691     ProcessTrajectories()
 2692 
 2693 def RetrieveOptions(): 
 2694     """Retrieve command line arguments and options."""
 2695     
 2696     # Get options...
 2697     global Options
 2698     Options = docopt(_docoptUsage_)
 2699 
 2700     # Set current working directory to the specified directory...
 2701     WorkingDir = Options["--workingdir"]
 2702     if WorkingDir:
 2703         os.chdir(WorkingDir)
 2704     
 2705     # Handle examples option...
 2706     if "--examples" in Options and Options["--examples"]:
 2707         MiscUtil.PrintInfo(MiscUtil.GetExamplesTextFromDocOptText(_docoptUsage_))
 2708         sys.exit(0)
 2709 
 2710 def ValidateOptions():
 2711     """Validate option values."""
 2712     
 2713     MiscUtil.ValidateOptionTextValue("--align", Options["--align"], "yes no")
 2714     MiscUtil.ValidateOptionTextValue("--alignMethod", Options["--alignMethod"], "align cealign super")
 2715     MiscUtil.ValidateOptionTextValue("--alignMode", Options["--alignMode"], "FirstChain Complex")
 2716     
 2717     MiscUtil.ValidateOptionTextValue("--allowEmptyObjects", Options["--allowEmptyObjects"], "yes no")
 2718 
 2719     MiscUtil.ValidateOptionTextValue("--BFactorChain", Options["--BFactorChain"], "yes no")
 2720 
 2721     # Expand infiles to handle presence of multiple input files...
 2722     InfileNames = MiscUtil.ExpandFileNames(Options["--infiles"], ",")
 2723     if not len(InfileNames):
 2724         MiscUtil.PrintError("No input files specified for \"-i, --infiles\" option")
 2725 
 2726     # Validate file extensions...
 2727     for Infile in InfileNames:
 2728         MiscUtil.ValidateOptionFilePath("-i, --infiles", Infile)
 2729         MiscUtil.ValidateOptionFileExt("-i, --infiles", Infile, "pdb cif")
 2730         MiscUtil.ValidateOptionsDistinctFileNames("-i, --infiles", Infile, "-o, --outfile", Options["--outfile"])
 2731     Options["--infileNames"] = InfileNames
 2732     
 2733     MiscUtil.ValidateOptionFileExt("-o, --outfile", Options["--outfile"], "pml pse")
 2734     MiscUtil.ValidateOptionsOutputFileOverwrite("-o, --outfile", Options["--outfile"], "--overwrite", Options["--overwrite"])
 2735 
 2736     if re.match("^yes$", Options["--align"], re.I):
 2737         if not re.match("^FirstInputFile$", Options["--alignRefFile"], re.I):
 2738             AlignRefFile = Options["--alignRefFile"]
 2739             MiscUtil.ValidateOptionFilePath("--alignRefFile", AlignRefFile)
 2740             MiscUtil.ValidateOptionFileExt("--alignRefFile", AlignRefFile, "pdb cif")
 2741             MiscUtil.ValidateOptionsDistinctFileNames("--AlignRefFile", AlignRefFile, "-o, --outfile", Options["--outfile"])
 2742     
 2743     MiscUtil.ValidateOptionTextValue("--disulfideBondsChain", Options["--disulfideBondsChain"], "yes no auto")
 2744     
 2745     MiscUtil.ValidateOptionTextValue("--ignoreHydrogens", Options["--ignoreHydrogens"], "yes no")
 2746     
 2747     MiscUtil.ValidateOptionTextValue("--PMLOut", Options["--PMLOut"], "yes no")
 2748     MiscUtil.ValidateOptionIntegerValue("--labelFontID", Options["--labelFontID"], {})
 2749 
 2750     MiscUtil.ValidateOptionFloatValue("--pocketContactsCutoff", Options["--pocketContactsCutoff"], {">": 0.0})
 2751     MiscUtil.ValidateOptionFloatValue("--pocketDistanceCutoff", Options["--pocketDistanceCutoff"], {">": 0.0})
 2752     if (float(Options["--pocketContactsCutoff"]) > float(Options["--pocketDistanceCutoff"])):
 2753         MiscUtil.PrintError("The value, %s, specified using option \"--pocketContactsCutoff\" must be less than value, %s, specified using \"-pocketDistanceCutoff\" option." % (Options["--pocketContactsCutoff"], Options["--pocketDistanceCutoff"]))
 2754         
 2755     MiscUtil.ValidateOptionTextValue("--pocketResidueTypes", Options["--pocketResidueTypes"], "yes no auto")
 2756     MiscUtil.ValidateOptionTextValue("--pocketSurface", Options["--pocketSurface"], "yes no auto")
 2757     MiscUtil.ValidateOptionTextValue("--pocketSurfaceElectrostatics", Options["--pocketSurfaceElectrostatics"], "yes no auto")
 2758     
 2759     MiscUtil.ValidateOptionTextValue("--residueTypesChain", Options["--residueTypesChain"], "yes no auto")
 2760 
 2761     MiscUtil.ValidateOptionTextValue("--saltBridgesChain", Options["--saltBridgesChain"], "yes no auto")
 2762     MiscUtil.ValidateOptionFloatValue("--saltBridgesChainCutoff", Options["--saltBridgesChainCutoff"], {">": 0.0})
 2763     
 2764     MiscUtil.ValidateOptionTextValue("--selectionsChainSurface", Options["--selectionsChainSurface"], "yes no auto")
 2765     MiscUtil.ValidateOptionTextValue("--selectionsPocketSurface", Options["--selectionsPocketSurface"], "yes no auto")
 2766     
 2767     MiscUtil.ValidateOptionTextValue("--surfaceComplex", Options["--surfaceComplex"], "yes no")
 2768     MiscUtil.ValidateOptionTextValue("--surfaceChainComplex", Options["--surfaceChainComplex"], "yes no")
 2769     MiscUtil.ValidateOptionTextValue("--surfaceChain", Options["--surfaceChain"], "yes no auto")
 2770     MiscUtil.ValidateOptionTextValue("--surfaceChainElectrostatics", Options["--surfaceChainElectrostatics"], "yes no auto")
 2771     
 2772     MiscUtil.ValidateOptionTextValue("--surfaceColorPalette", Options["--surfaceColorPalette"], "RedToWhite WhiteToGreen")
 2773     MiscUtil.ValidateOptionFloatValue("--surfaceTransparency", Options["--surfaceTransparency"], {">=": 0.0, "<=": 1.0})
 2774     
 2775 # Setup a usage string for docopt...
 2776 _docoptUsage_ = """
 2777 PyMOLVisualizeMacromolecules.py - Visualize macromolecules
 2778 
 2779 Usage:
 2780     PyMOLVisualizeMacromolecules.py [--align <yes or no>] [--alignMethod <align, cealign, super>]
 2781                                     [--alignMode <FirstChain or Complex>] [--alignRefFile <filename>]
 2782                                     [--allowEmptyObjects <yes or no>] [--BFactorChain <yes or no>] [--BFactorColorPalette <text>]
 2783                                     [--chainIDs <First, All or ID1,ID2...>] [--disulfideBondsChain <yes or no>]
 2784                                     [--dockedPoses <PDBFile,ChainID,LigandID,InputFiles,...>] [--dockedPosesDistanceContactsCutoffs <number1,number2...>]
 2785                                     [--dockedPosesDistanceContactsColor <text>] [--dockedPosesGroupName <text>]
 2786                                     [--dockedPosesName <text>] [--ignoreHydrogens <yes or no>] [--ligandIDs <Largest, All or ID1,ID2...>]
 2787                                     [--labelFontID <number>] [--PMLOut <yes or no>] [--pocketContactsInorganicColor <text>]
 2788                                     [--pocketContactsInorganicPiCationColor <text>] [--pocketContactsLigandColor <text>]
 2789                                     [--pocketContactsLigandHydrophobicColor <text>] [--pocketContactsLigandHalogenColor <text>]
 2790                                     [--pocketContactsLigandPiCationColor <text>] [--pocketContactsLigandPiPiColor <text>]
 2791                                     [--pocketContactsSolventColor <text>] [--pocketContactsCutoff <number>]
 2792                                     [--pocketDistanceCutoff <number>] [--pocketLabelColor <text>] [--pocketResidueTypes <yes or no>]
 2793                                     [--pocketSurface <yes or no>] [--pocketSurfaceElectrostatics <yes or no>]
 2794                                     [--residueTypes <Type,Color,ResNames,...>] [--residueTypesChain <yes or no>]
 2795                                     [--saltBridgesChain <yes or no>] [--saltBridgesChainContactsColor <text>]
 2796                                     [--saltBridgesChainCutoff <number>] [--saltBridgesChainResidues <Type, ResNames,...>]
 2797                                     [--selectionsChain <ObjectName,SelectionSpec,...>] [--selectionsChainSurface <yes or no>]
 2798                                     [--selectionsChainStyle <DisplayStyle>] [--selectionsPocket <ObjectName,SelectionSpec,...>]
 2799                                     [--selectionsPocketSurface <yes or no>] [--selectionsPocketStyle <DisplayStyle>]
 2800                                     [--surfaceChain <yes or no>] [--surfaceChainElectrostatics <yes or no>]
 2801                                     [--surfaceChainComplex <yes or no>] [--surfaceComplex <yes or no>]
 2802                                     [--surfaceColor <ColorName>] [--surfaceColorPalette <RedToWhite or WhiteToGreen>]
 2803                                     [--surfaceAtomTypesColors <ColorType,ColorSpec,...>]
 2804                                     [--surfaceTransparency <number>] [--trajectories <PDBToplogyFile,TrajFiles,...> ]
 2805                                     [--overwrite] [-w <dir>] -i <infile1,infile2,infile3...> -o <outfile>
 2806     PyMOLVisualizeMacromolecules.py -h | --help | -e | --examples
 2807 
 2808 Description:
 2809     Generate PyMOL visualization files for viewing surfaces, chains, ligands, ligand
 2810     binding pockets, and interactions between ligands and binding pockets in
 2811     macromolecules including proteins and nucleic acids.
 2812 
 2813     The supported input file format are: PDB (.pdb), CIF (.cif)
 2814 
 2815     The supported output file formats are: PyMOL script file (.pml), PyMOL session
 2816     file (.pse)
 2817 
 2818     A variety of PyMOL groups and objects may be  created for visualization of
 2819     macromolecules. These groups and objects correspond to complexes, surfaces,
 2820     chains, ligands, inorganics, ligand binding pockets, pocket, polar interactions,
 2821     and pocket hydrophobic surfaces. A complete hierarchy of all possible PyMOL
 2822     groups and objects is shown below:
 2823     
 2824         <PDBFileRoot>
 2825             .Complex
 2826                 .Complex
 2827                 .Surface
 2828             .Trajectories
 2829                 .Topology
 2830                 .<TrajFileID>
 2831                     .Trajectory
 2832                 .<TrajFileID>
 2833                     ... ... ...
 2834                 .<TrajFileID>
 2835                     ... ... ...
 2836             .Chain<ID>
 2837                 .Complex
 2838                     .Complex
 2839                     .Surface
 2840                 .Chain
 2841                     .Chain
 2842                     .BFactor
 2843                         .Putty
 2844                         .Cartoon
 2845                     .Selections
 2846                         .<Name>
 2847                             .Selection
 2848                             .Surface
 2849                                 .Surface
 2850                                 .Hydrophobicity
 2851                                 .Hydrophobicity_Charge
 2852                         .<Name>
 2853                             ... ... ..
 2854                     .Residues
 2855                         .Aromatic
 2856                             .Residues
 2857                             .Surface
 2858                         .Hydrophobic
 2859                             .Residues
 2860                             .Surface
 2861                         .Polar
 2862                             .Residues
 2863                             .Surface
 2864                         .Positively_Charged
 2865                             .Residues
 2866                             .Surface
 2867                         .Negatively_Charged
 2868                             .Residues
 2869                             .Surface
 2870                         .Other
 2871                             .Residues
 2872                             .Surface
 2873                     .Surface
 2874                         .Surface
 2875                         .Hydrophobicity
 2876                         .Hydrophobicity_Charge
 2877                         .Vacuum_Electrostatics
 2878                             .Contact_Potentials
 2879                             .Map
 2880                             .Legend
 2881                             .Volume
 2882                     .Disulfide_Bonds
 2883                         .Residues
 2884                     .Salt_Bridges
 2885                         .Residues
 2886                             .Positively_Charged
 2887                             .Negatively_Charged
 2888                         .Contacts
 2889                 .Solvent
 2890                 .Inorganic
 2891                 .Ligand<ID>
 2892                     .Ligand
 2893                         .Ligand
 2894                         .BallAndStick
 2895                     .Pocket
 2896                         .Pocket
 2897                         .Polar_Contacts
 2898                         .Hydrophobic_Contacts
 2899                         .Pi_Pi_Contacts
 2900                         .Pi_Cation_Contacts
 2901                         .Halogen_Contacts
 2902                         .Selections
 2903                             .<Name>
 2904                                 .Selection
 2905                                 .Surface
 2906                                     .Surface
 2907                                     .Hydrophobicity
 2908                                     .Hydrophobicity_Charge
 2909                             .<Name>
 2910                                 ... ... ..
 2911                         .Residues
 2912                             .Aromatic
 2913                                 .Residues
 2914                                 .Surface
 2915                             .Hydrophobic
 2916                                 .Residues
 2917                                 .Surface
 2918                             .Polar
 2919                                 .Residues
 2920                                 .Surface
 2921                             .Positively_Charged
 2922                                 .Residues
 2923                                 .Surface
 2924                             .Negatively_Charged
 2925                                 .Residues
 2926                                 .Surface
 2927                             .Other
 2928                                 .Residues
 2929                                 .Surface
 2930                         .Surfaces
 2931                             .Surface
 2932                                 .Surface
 2933                                 .Hydrophobicity
 2934                                 .Hydrophobicity_Charge
 2935                                 .Vacuum_Electrostatics
 2936                                     .Contact_Potentials
 2937                                     .Map
 2938                                     .Legend
 2939                             .Cavity
 2940                                 .Surface
 2941                                 .Hydrophobicity
 2942                                 .Hydrophobicity_Charge
 2943                                 .Vacuum_Electrostatics
 2944                                     .Contact_Potentials
 2945                                     .Map
 2946                                     .Legend
 2947                     .Pocket_Solvent
 2948                         .Pocket_Solvent
 2949                         .Polar_Contacts
 2950                     .Pocket_Inorganic
 2951                         .Pocket_Inorganic
 2952                         .Polar_Contacts
 2953                         .Pi_Cation_Contacts
 2954                 .Ligand<ID>
 2955                     .Ligand
 2956                         ... ... ...
 2957                     .Pocket
 2958                         ... ... ...
 2959                     .Pocket_Solvent
 2960                         ... ... ...
 2961                     .Pocket_Inorganic
 2962                         ... ... ...
 2963                 .Docked_Poses or <CustomLabel>
 2964                     .<InputFileID>
 2965                         .Poses or <CustomLabel>
 2966                         .Pocket
 2967                             .Pocket
 2968                             .Distance_Contacts
 2969                                 .Contact1_At_<Distance>
 2970                                 .Contact1_At_<Distance>
 2971                                 ... ... ...
 2972                             .Polar_Contacts
 2973                             .Hydrophobic_Contacts
 2974                             .Pi_Pi_Contacts
 2975                             .Pi_Cation_Contacts
 2976                             .Halogen_Contacts
 2977                         .Pocket_Solvent
 2978                             .Pocket_Solvent
 2979                             .Polar_Contacts
 2980                         .Pocket_Inorganic
 2981                             .Polar_Contacts
 2982                             .Pi_Cation_Contacts
 2983                     .<InputFileID>
 2984                         ... ... ...
 2985                     .<InputFileID>
 2986                         ... ... ...
 2987             .Chain<ID>
 2988                 ... ... ...
 2989                 .Ligand<ID>
 2990                     ... ... ...
 2991                 .Ligand<ID>
 2992                     ... ... ...
 2993             .Chain<ID>
 2994                 ... ... ...
 2995         <PDBFileRoot>
 2996             .Complex
 2997                 ... ... ...
 2998             .Chain<ID>
 2999                 ... ... ...
 3000                 .Ligand<ID>
 3001                     ... ... ...
 3002                 .Ligand<ID>
 3003                     ... ... ...
 3004             .Chain<ID>
 3005                 ... ... ...
 3006     
 3007     The hydrophobic and electrostatic surfaces are not created for complete complex
 3008     and chain complex in input file(s) by default. A word to the wise: The creation of
 3009     surface objects may slow down loading of PML file and generation of PSE file, based
 3010     on the size of input complexes. The generation of PSE file may also fail.
 3011 
 3012 Options:
 3013     -a, --align <yes or no>  [default: no]
 3014         Align input files to a reference file before visualization. The docked poses
 3015         and trajectories are not aligned.
 3016     --alignMethod <align, cealign, super>  [default: super]
 3017         Alignment methodology to use for aligning input files to a
 3018         reference file.
 3019     --alignMode <FirstChain or Complex>  [default: FirstChain]
 3020         Portion of input and reference files to use for spatial alignment of
 3021         input files against reference file.  Possible values: FirstChain or
 3022         Complex.
 3023         
 3024         The FirstChain mode allows alignment of the first chain in each input
 3025         file to the first chain in the reference file along with moving the rest
 3026         of the complex to coordinate space of the reference file. The complete
 3027         complex in each input file is aligned to the complete complex in reference
 3028         file for the Complex mode.
 3029     --alignRefFile <filename>  [default: FirstInputFile]
 3030         Reference input file name. The default is to use the first input file
 3031         name specified using '-i, --infiles' option.
 3032     --allowEmptyObjects <yes or no>  [default: no]
 3033         Allow creation of empty PyMOL objects corresponding to solvent and
 3034         inorganic atom selections across chains and ligands in input file(s). By
 3035         default, the empty objects are marked for deletion.
 3036     -b, --BFactorChain <yes or no>  [default: yes]
 3037         A cartoon and putty around individual chains colored by an arbitrary set
 3038         of B factor values. The minimum and maximum values for B factors are
 3039         automatically detected. These values may indicate spread of electron
 3040         density around atoms or correspond to any other property mapped to
 3041         B factors in input file.
 3042     --BFactorColorPalette <text>  [default: blue_white_red]
 3043         Color palette for coloring cartoon and putty around chains generated using B
 3044         factor values. Any valid PyMOL color palette name is allowed. No validation is
 3045         performed. The complete list of valid color palette names is a available
 3046         at: pymolwiki.org/index.php/Spectrum. Examples: blue_white_red,
 3047         blue_white_magenta, blue_red, green_white_red, green_red.
 3048     -c, --chainIDs <First, All or ID1,ID2...>  [default: First]
 3049         List of chain IDs to use for visualizing macromolecules. Possible values:
 3050         First, All, or a comma delimited list of chain IDs. The default is to use the
 3051         chain ID for the first chain in each input file.
 3052     -d --disulfideBondsChain <yes or no>  [default: auto]
 3053         Disulfide bonds for chains. By default, the disulfide bonds group is
 3054         automatically created for chains containing amino acids and skipped for
 3055         chains only containing nucleic acids.
 3056     --dockedPoses <PDBFile,ChainID,LigandID,InputFiles,...>  [default: none]
 3057         PDB file name, pocket chain ID, ligand specification, and input files to use
 3058         for creating pockets to visualize docked poses or any arbitrary set of
 3059         molecules. Any valid PyMOL input file format is allowed.
 3060         
 3061         It's a quartet of comma limited values corresponding to PDF file name,
 3062         pocket chain ID, ligand ID, and input files. Multiple input file names are
 3063         delimited by spaces.
 3064         
 3065         The supported values for docked poses are shown below:
 3066              
 3067             PDBFile: A valid PDB file name
 3068             ChainID: A valid Chain ID
 3069             LigandID: A valid Ligand ID or UseInputFile
 3070             InputFiles: A space delimited list of input file names
 3071              
 3072         All docked pose values must be specified. No default values are assigned.
 3073         
 3074         The 'ChainID' and 'LigandID' are used for creating pocket to visualize docked
 3075         poses.
 3076         
 3077         The 'LigandID' must be a valid ligand ID in 'ChainID'. Alternatively, you may use
 3078         input files by specifying 'UseInputFile' to select residues in 'ChainID' for creating
 3079         pockets to visualize docked poses.
 3080     --dockedPosesDistanceContactsCutoffs <number1,number2...>  [default: none]
 3081         A comma delimited list of distances in Angstroms for identifying and displaying
 3082         distance contacts between heavy atoms in pocket residues and docked poses. A
 3083         PyMOL distance contact object is created for each specified distance. You may
 3084         find it helpful for identifying steric clashes between docked poses and pocket
 3085         residues. The maximum distance cutoff value must be less than the specified
 3086         value for '--pocketDistanceCutoff' option.
 3087     --dockedPosesDistanceContactsColor <text>  [default: red]
 3088         Color for drawing distance contacts between docked poses and pocket residues.
 3089         The specified value must be valid color. No validation is performed.
 3090     --dockedPosesGroupName <text>  [default: Docked_Poses]
 3091         PyMOL object name for docked poses group. You may use an artbitray name
 3092         to reflect data in input file(s) specified in '--dockedPoses' option. It must be a valid
 3093         PyMOL object name. No validation is performed.
 3094     --dockedPosesName <text>  [default: Poses]
 3095         PyMOL object name for docked poses object. You may use an artbitray name
 3096         to reflect data in input file(s) specified in '--dockedPoses' option. It must be a
 3097         valid PyMOL object name. No validation is performed.
 3098     -e, --examples
 3099         Print examples.
 3100     -h, --help
 3101         Print this help message.
 3102     -i, --infiles <infile1,infile2,infile3...>
 3103         Input file names.
 3104     --ignoreHydrogens <yes or no>  [default: yes]
 3105         Ignore hydrogens for ligand, pocket, selection, and residue type views.
 3106     -l, --ligandIDs <Largest, All or ID1,ID2...>  [default: Largest]
 3107         List of ligand IDs present in chains for visualizing macromolecules to
 3108         highlight ligand interactions. Possible values: Largest, All, or a comma
 3109         delimited list of ligand IDs. The default is to use the largest ligand present
 3110         in all or specified chains in each input file.
 3111         
 3112         Ligands are identified using organic selection operator available in PyMOL.
 3113         It'll also  identify buffer molecules as ligands. The largest ligand contains
 3114         the highest number of heavy atoms.
 3115     --labelFontID <number>  [default: 7]
 3116         Font ID for drawing labels. Default: 7 (Sans Bold). Valid values: 5 to 16.
 3117         The specified value must be a valid PyMOL font ID. No validation is
 3118         performed. The complete lists of valid font IDs is available at:
 3119         pymolwiki.org/index.php/Label_font_id. Examples: 5 - Sans;
 3120         7 - Sans Bold; 9 - Serif; 10 - Serif Bold.
 3121     -o, --outfile <outfile>
 3122         Output file name.
 3123     -p, --PMLOut <yes or no>  [default: yes]
 3124         Save PML file during generation of PSE file.
 3125     --pocketContactsInorganicColor <text>  [default: deepsalmon]
 3126         Color for drawing polar contacts between inorganic and pocket residues.
 3127         The specified value must be valid color. No validation is performed.
 3128     --pocketContactsInorganicPiCationColor <text>  [default: limon]
 3129         Color for drawing pi cation contacts between inorganic and pocket residues.
 3130         The specified value must be valid color. No validation is performed. The pi
 3131         cation contacts are drawn using PyMOL distance command with support for
 3132         mode 7 and may require incentive version of PyMOL.
 3133     --pocketContactsLigandColor <text>  [default: orange]
 3134         Color for drawing polar contacts between ligand and pocket residues.
 3135         The specified value must be valid color. No validation is performed.
 3136     --pocketContactsLigandHalogenColor <text>  [default: magenta]
 3137         Color for drawing halogen contacts between ligand and pocket residues.
 3138         The specified value must be valid color. No validation is performed.
 3139     --pocketContactsLigandHydrophobicColor <text>  [default: purpleblue]
 3140         Color for drawing hydrophobic contacts between ligand and pocket residues.
 3141         The specified value must be valid color. No validation is performed. The
 3142         hydrophobic contacts are shown between pairs of carbon atoms not
 3143         connected to hydrogen bond donor or acceptors atoms as identified
 3144         by PyMOL.
 3145     --pocketContactsLigandPiCationColor <text>  [default: yelloworange]
 3146         Color for drawing pi cation contacts between ligand and pocket residues.
 3147         The specified value must be valid color. No validation is performed. The pi
 3148         cation contacts are drawn using PyMOL distance command with support for
 3149         mode 7 and may require incentive version of PyMOL.
 3150     --pocketContactsLigandPiPiColor <text>  [default: cyan]
 3151         Color for drawing pi pi contacts between ligand and pocket residues.
 3152         The specified value must be valid color. No validation is performed. The pi
 3153         pi contacts are drawn using PyMOL distance command with support for
 3154         mode 6 and may require incentive version of PyMOL.
 3155     --pocketContactsSolventColor <text>  [default: marine]
 3156         Color for drawing polar contacts between solvent and pocket residues..
 3157         The specified value must be valid color. No validation is performed.
 3158     --pocketContactsCutoff <number>  [default: 4.0]
 3159         Distance in Angstroms for identifying polar, hyrdophobic contacts, pi pi,
 3160         pi cation, and halogen contacts  between atoms in pocket residues and
 3161         ligands.
 3162     --pocketDistanceCutoff <number>  [default: 5.0]
 3163         Distance in Angstroms for identifying pocket residues around ligands.
 3164     --pocketLabelColor <text>  [default: magenta]
 3165         Color for drawing residue or atom level labels for a pocket. The specified
 3166         value must be valid color. No validation is performed.
 3167     --pocketResidueTypes <yes or no>  [default: auto]
 3168         Pocket residue types. The residue groups are generated using residue types,
 3169         colors, and names specified by '--residueTypes' option. It is only valid for
 3170         amino acids.  By default, the residue type groups are automatically created
 3171         for pockets containing amino acids and skipped for chains only containing
 3172         nucleic acids.
 3173     --pocketSurface <yes or no>  [default: auto]
 3174         Surfaces around pocket residues colored by hydrophobicity alone and
 3175         both hydrophobicity and charge. The hydrophobicity surface is colored
 3176         at residue level using Eisenberg hydrophobicity scale for residues and color
 3177         gradient specified by '--surfaceColorPalette' option. The  hydrophobicity and
 3178         charge surface is colored [ Ref 140 ] at atom level using colors specified for
 3179         groups of atoms by '--surfaceAtomTypesColors' option. This scheme allows
 3180         simultaneous mapping of hyrophobicity and charge values on the surfaces.
 3181         
 3182         The cavity surfaces around ligands are also generated. These surfaces are
 3183         colored by hydrophobicity along and both hydrophobicity and charge.
 3184         
 3185         This option is only valid for amino acids. By default, both surfaces are
 3186         automatically created for pockets containing amino acids and skipped for
 3187         pockets containing only nucleic acids.
 3188     --pocketSurfaceElectrostatics <yes or no>  [default: no]
 3189         Vacuum electrostatics contact potential surface around pocket residues.
 3190         A word to the wise from PyMOL documentation: The computed protein
 3191         contact potentials are only qualitatively useful, due to short cutoffs,
 3192         truncation, and lack of solvent "screening".
 3193         
 3194         The cavity surface around ligands is also generated. This surface is
 3195         colored by vacuum electrostatics contact potential.
 3196         
 3197         This option is only valid for amino acids. By default, the electrostatics surface
 3198         is automatically created for chains containing amino acids and skipped for chains
 3199         containing only nucleic acids.
 3200     -r, --residueTypes <Type,Color,ResNames,...>  [default: auto]
 3201         Residue types, colors, and names to generate for residue groups during
 3202         '--pocketResidueTypes' and '--residueTypesChain' option. It is only
 3203         valid for amino acids.
 3204         
 3205         It is a triplet of comma delimited list of amino acid residues type, residues
 3206         color, and a space delimited list three letter residue names. 
 3207         
 3208         The default values for residue type, color, and name triplets  are shown
 3209         below:
 3210             
 3211             Aromatic,brightorange,HIS PHE TRP TYR,
 3212             Hydrophobic,orange,ALA GLY VAL LEU ILE PRO MET,
 3213             Polar,palegreen,ASN GLN SER THR CYS,
 3214             Positively_Charged,marine,ARG LYS,
 3215             Negatively_Charged,red,ASP GLU
 3216             
 3217         The color name must be a valid PyMOL name. No validation is performed.
 3218         An amino acid name may appear across multiple residue types. All other
 3219         residues are grouped under 'Other'.
 3220     --residueTypesChain <yes or no>  [default: auto]
 3221         Chain residue types. The residue groups are generated using residue types,
 3222         colors, and names specified by '--residueTypes' option. It is only valid for
 3223         amino acids.  By default, the residue type groups are automatically created
 3224         for chains containing amino acids and skipped for chains only containing
 3225         nucleic acids.
 3226      --saltBridgesChain <yes or no>  [default: auto]
 3227         Salt bridges for chains. By default, the salt bridges group is automatically
 3228         created for chains containing amino acids and skipped for chains only
 3229         containing nucleic acids. The salt bridges correspond to polar contacts
 3230         between positively and negatively charges residues in a chain.
 3231     --saltBridgesChainContactsColor <text>  [default: brightorange]
 3232         Color for drawing polar contacts between positively and negatively
 3233         charged residues involved in salt bridges. The specified value must
 3234         be valid color. No validation is performed.
 3235     --saltBridgesChainCutoff <number>  [default: 4.0]
 3236         Distance in Angstroms for identifying polar contacts between positively
 3237         and negatively charged residues involved in salt bridges in a chain.
 3238      --saltBridgesChainResidues <Type, ResNames,...>  [default: auto]
 3239         Residue types and names to use for identifying positively and negatively
 3240         charged residues involved in salt bridges.
 3241         
 3242         It is a pair of comma delimited list of amino acid residue types and a space
 3243         delimited list three letter residue names.
 3244         
 3245         The default values for residue type and name pairs  are shown below:
 3246             
 3247             Positively_Charged,ARG LYS HIS HSP
 3248             Negatively_Charged,ASP GLU
 3249             
 3250         The residue names must be valid names. No validation is performed.
 3251     --selectionsChain <ObjectName,SelectionSpec,...>  [default: none]
 3252         Custom selections for chains. It is a pairwise list of comma delimited values
 3253         corresponding to PyMOL object names and selection specifications.  The
 3254         selection specification must be a valid PyMOL specification. No validation is
 3255         performed.
 3256         
 3257         The PyMOL objects are created for each chain corresponding to the
 3258         specified selections. The display style for PyMOL objects is set using
 3259         value of '--selectionsChainStyle' option.
 3260         
 3261         The specified selection specification is automatically appended to appropriate
 3262         chain specification before creating PyMOL objects.
 3263         
 3264         For example, the following specification for '--selectionsChain' option will
 3265         generate PyMOL objects for chains containing Cysteines and Serines:
 3266             
 3267             Cysteines,resn CYS,Serines,resn SER
 3268             
 3269     --selectionsChainSurface <yes or no>  [default: auto]
 3270         Surfaces around individual chain selections colored by hydrophobicity alone
 3271         and both hydrophobicity and charge. This option is similar to '--surfaceChain'
 3272         options for creating surfaces for chain. Additional details are available in the
 3273         documentation section for '--surfaceChain' options.
 3274     --selectionsChainStyle <DisplayStyle>  [default: sticks]
 3275         Display style for PyMOL objects created for '--selectionsChain' option. It
 3276         must be a valid PyMOL display style. No validation is performed.
 3277     --selectionsPocket <ObjectName,SelectionSpec,...>  [default: none]
 3278         Custom selections for pocket residues. It is a pairwise list of comma delimited
 3279         values corresponding to PyMOL object names and selection specifications.  The
 3280         selection specification must be a valid PyMOL specification. No validation is
 3281         performed.
 3282         
 3283         The PyMOL objects are created for each pocket corresponding to the
 3284         specified selections. The display style for PyMOL objects is set using
 3285         value of '--selectionsChainStyle' option.
 3286         
 3287         The specified selection specification is automatically appended to appropriate
 3288         pocket specification before creating PyMOL objects.
 3289         
 3290         For example, the following specification for '--selectionsPocket' option will
 3291         generate PyMOL objects for pockets containing Tyrosines and Serines:
 3292             
 3293             Tyrosines,resn TYR,Serines,resn SER
 3294             
 3295     --selectionsPocketSurface <yes or no>  [default: auto]
 3296         Surfaces around individual pocket chain selections colored by hydrophobicity
 3297         alone and both hydrophobicity and charge. This option is similar to '--surfaceChain'
 3298         options for creating surfaces for chain. Additional details are available in the
 3299         documentation section for '--surfaceChain' options.
 3300     --selectionsPocketStyle <DisplayStyle>  [default: sticks]
 3301         Display style for PyMOL objects created for '--selectionsPocket' option. It
 3302         must be a valid PyMOL display style. No validation is performed.
 3303     --surfaceChain <yes or no>  [default: auto]
 3304         Surfaces around individual chain colored by hydrophobicity alone and
 3305         both hydrophobicity and charge. The hydrophobicity surface is colored
 3306         at residue level using Eisenberg hydrophobicity scale for residues and color
 3307         gradient specified by '--surfaceColorPalette' option. The  hydrophobicity and
 3308         charge surface is colored [ Ref 140 ] at atom level using colors specified for
 3309         groups of atoms by '--surfaceAtomTypesColors' option. This scheme allows
 3310         simultaneous mapping of hyrophobicity and charge values on the surfaces.
 3311         
 3312         This option is only valid for amino acids. By default, both surfaces are
 3313         automatically created for chains containing amino acids and skipped for
 3314         chains containing only nucleic acids.
 3315     --surfaceChainElectrostatics <yes or no>  [default: no]
 3316         Vacuum electrostatics contact potential surface and volume around individual
 3317         chain. A word to the wise from PyMOL documentation: The computed protein
 3318         contact potentials are only qualitatively useful, due to short cutoffs,
 3319         truncation, and lack of solvent "screening".
 3320         
 3321         This option is only valid for amino acids. By default, the electrostatics surface
 3322         and volume are automatically created for chains containing amino acids and
 3323         skipped for chains containing only nucleic acids.
 3324     --surfaceChainComplex <yes or no>  [default: no]
 3325         Hydrophobic surface around chain complex. The  surface is colored by
 3326         hydrophobicity. It is only valid for amino acids.
 3327     --surfaceComplex <yes or no>  [default: no]
 3328         Hydrophobic surface around complete complex. The  surface is colored by
 3329         hydrophobicity. It is only valid for amino acids.
 3330     --surfaceAtomTypesColors <ColorType,ColorSpec,...>  [default: auto]
 3331         Atom colors for generating surfaces colored by hyrophobicity and charge
 3332         around chains and pockets in proteins. It's a pairwise comma delimited list
 3333         of atom color type and color specification for goups of atoms.
 3334         
 3335         The default values for color types [ Ref 140 ] along wth color specifications
 3336         are shown below: 
 3337             
 3338             HydrophobicAtomsColor, yellow,
 3339             NegativelyChargedAtomsColor, red,
 3340             PositivelyChargedAtomsColor, blue,
 3341             OtherAtomsColor, gray90
 3342             
 3343         The color names must be valid PyMOL names.
 3344         
 3345         The color values may also be specified as space delimited RGB triplets:
 3346              
 3347             HydrophobicAtomsColor, 0.95 0.78 0.0,
 3348             NegativelyChargedAtomsColor, 1.0 0.4 0.4,
 3349             PositivelyChargedAtomsColor, 0.2 0.5 0.8,
 3350             OtherAtomsColor, 0.95 0.95 0.95
 3351             
 3352     --surfaceColor <ColorName>  [default: lightblue]
 3353         Color name for surfaces around chains and pockets. This color is not used
 3354         for surfaces colored by hydrophobicity and charge. The color name must be
 3355         a valid PyMOL name.
 3356     --surfaceColorPalette <RedToWhite or WhiteToGreen>  [default: RedToWhite]
 3357         Color palette for hydrophobic surfaces around chains and pockets in proteins.
 3358         Possible values: RedToWhite or WhiteToGreen from most hydrophobic amino
 3359         acid to least hydrophobic. The colors values for amino acids are taken from
 3360         color_h script available as part of the Script Library at PyMOL Wiki.
 3361     --surfaceTransparency <number>  [default: 0.25]
 3362         Surface transparency for molecular surfaces.
 3363     -t, --trajectories <PDBToplogyFile,TrajFiles,...>  [default: none]
 3364         PDB topology file name and MD trajectories files for visualizing trajectories
 3365         for PDB files.
 3366         
 3367         It's a pair of comma limited values corresponding to a PDB file name and
 3368         MD trajectory files. Multiple trajectory file names are delimited by spaces.
 3369         
 3370         The supported values for trajectories are shown below:
 3371              
 3372             PDBTopologyFile: A valid PDB file name
 3373             TrajFiles: A space delimited list of MD trajectory file names
 3374              
 3375         The trajectory files must correspond to the specified PDB topology file. In
 3376         addition, the format of trajectory files must be a valid PyMOL format. PyMOL
 3377         uses Molfile Plugin, which supports a variety of trajectory file formats. For
 3378         example: HARMM, NAMD, X-PLOR (.dcd), Gromacs TRR/XTC (.trr, .xtc),
 3379         XYZ (.xyz) etc.
 3380     --overwrite
 3381         Overwrite existing files.
 3382     -w, --workingdir <dir>
 3383         Location of working directory which defaults to the current directory.
 3384 
 3385 Examples:
 3386     To visualize the first chain, the largest ligand in the first chain, and ligand
 3387     binding pockets to highlight ligand interaction with pocket resiudes, solvents
 3388     and inorganics, in a PDB file, and generate a PML file, type:
 3389 
 3390         % PyMOLVisualizeMacromolecules.py -i Sample4.pdb -o Sample4.pml
 3391 
 3392     To visualize the first chain along with all cysteines and serines, the largest
 3393     ligand in the first chain, and ligand binding pockets to highlight ligand
 3394     interaction with pocket resiudes, solvents and inorganics, in a PDB file,
 3395     and generate a PML file, type:
 3396 
 3397         % PyMOLVisualizeMacromolecules.py -i Sample4.pdb -o Sample4.pml
 3398           --selectionsChain "Cysteines,resn cys,Serines,resn ser"
 3399 
 3400     To visualize the first chain along with all serines and tyrosines in binding
 3401     pockets, the largest ligand in the first chain, and ligand binding pockets
 3402     to highlight ligand interaction with pocket resiudes, solvents and inorganics,
 3403     in a PDB file, and generate a PML file, type:
 3404 
 3405         % PyMOLVisualizeMacromolecules.py -i Sample4.pdb -o Sample4.pml
 3406           --selectionsPocket "Serines,resn ser,Tyrosines,resn tyr"
 3407 
 3408     To visualize docking poses from a SD file in a pocket corresponding to a SD file
 3409     for a chain, along with visualization of other information, in a PDB file,
 3410     and generate a PML file, type:
 3411 
 3412         % PyMOLVisualizeMacromolecules.py -c All -l "N3" -i  SampleMpro6LU7.pdb
 3413           -o  SampleMpro6LU7.pml --dockedPoses "SampleMpro6LU7.pdb,A,UseInputFile,
 3414           SampleMproDockedPosesTop100.sdf"
 3415     
 3416     To visualize docking poses from a SD file in a pocket corresponding to SD file
 3417     for a chain, along with visualization of distance contacts at 3.0 and 3.5 Angstroms,
 3418     in a PDB file, and generate a PML file, type:
 3419 
 3420         % PyMOLVisualizeMacromolecules.py -c All -l "N3" -i  SampleMpro6LU7.pdb
 3421           -o  SampleMpro6LU7.pml --dockedPoses "SampleMpro6LU7.pdb,A,UseInputFile,
 3422           SampleMproDockedPosesTop100.sdf"
 3423           --dockedPosesDistanceContactsCutoffs "3.0, 3.5"
 3424     
 3425     To visualize docking poses from a SD file in a pocket corresponding to a specific
 3426     ligand a chain, along with visualization of other information, in a PDB file,
 3427     and generate a PML file, type:
 3428 
 3429         % PyMOLVisualizeMacromolecules.py -c All -l "N3" -i  SampleMpro6LU7.pdb
 3430           -o  SampleMpro6LU7.pml --dockedPoses "SampleMpro6LU7.pdb,A,N3,
 3431           SampleMproDockedPosesTop100.sdf" 
 3432     
 3433     To visualize docking poses from multiple SDs file in a pocket corresponding SD file
 3434     a for a chain, along with visualization of other information, in a PDB file, and
 3435     generate a PML file, type: 
 3436 
 3437         % PyMOLVisualizeMacromolecules.py -c All -l "N3" -i  SampleMpro6LU7.pdb
 3438           -o  SampleMpro6LU7.pml --dockedPoses "SampleMpro6LU7.pdb,A,UseInputFile,
 3439           SampleMproDockedPosesTop100.sdf SampleMproDockedPosesDiverse100.sdf"
 3440 
 3441     To visualize trajectory from a DCD file,  along with visualization of other
 3442     information, corresponding to a PDB topology file and generate a PML file,
 3443     type:
 3444 
 3445         % PyMOLVisualizeMacromolecules.py -t "Sample10.pdb, Sample10.dcd"
 3446           -i Sample10.pdb -o Sample10.pml
 3447 
 3448     To visualize all chains, all ligands in all chains, and all ligand binding pockets to
 3449     highlight ligand interaction with pocket resiudes, solvents and inorganics, in a
 3450     PDB file, and generate a PML file, type:
 3451 
 3452         % PyMOLVisualizeMacromolecules.py -c All -l All -i Sample4.pdb -o
 3453           Sample4.pml
 3454 
 3455     To visualize all chains, ligands, and ligand binding pockets along with displaying
 3456     all hydrophibic surfaces and chain electrostatic surface, in a PDB file, and
 3457     generate a PML file, type:
 3458 
 3459         % PyMOLVisualizeMacromolecules.py -c All -l All
 3460           --surfaceChainElectrostatics yes --surfaceChainComplex yes
 3461           --surfaceComplex yes -i Sample4.pdb -o Sample4.pml
 3462 
 3463     To visualize chain E, ligand ADP in chain E, and ligand binding pockets to
 3464     highlight ligand interaction with pocket resiudes, solvents and inorganics,
 3465     in a PDB file, and generate a PML file, type:
 3466 
 3467         % PyMOLVisualizeMacromolecules.py -c E -l ADP -i Sample3.pdb
 3468           -o Sample3.pml
 3469 
 3470     To visualize chain E, ligand ADP in chain E, and ligand binding pockets to
 3471     highlight ligand interaction with pocket resiudes, solvents and inorganics,
 3472     in a PDB file, and generate a PSE file, type:
 3473 
 3474         % PyMOLVisualizeMacromolecules.py -c E -l ADP -i Sample3.pdb
 3475           -o Sample3.pse
 3476 
 3477     To visualize the first chain, the largest ligand in the first chain, and ligand
 3478     binding pockets to highlight ligand interaction with pocket resiudes, solvents
 3479     and inorganics, in PDB files, along with aligning first chain in each input file to
 3480     the first chain in first input file, and generate a PML file, type:
 3481 
 3482         % PyMOLVisualizeMacromolecules.py --align yes -i
 3483           "Sample5.pdb,Sample6.pdb,Sample7.pdb" -o SampleOut.pml
 3484 
 3485     To visualize all chains, all ligands in all chains, and all ligand binding pockets to
 3486     highlight ligand interaction with pocket resiudes, solvents and inorganics, in
 3487     PDB files, along with aligning first chain in each input file to the first chain in
 3488     first input file, and generate a PML file, type:
 3489 
 3490         % PyMOLVisualizeMacromolecules.py --align yes  -c All -l All -i
 3491           "Sample5.pdb,Sample6.pdb,Sample7.pdb" -o SampleOut.pml
 3492 
 3493     To visualize all chains, all ligands in all chains, and all ligand binding pockets to
 3494     highlight ligand interaction with pocket resiudes, solvents and inorganics, in
 3495     PDB files, along with aligning first chain in each input file to the first chain in a
 3496     specified PDB file using a specified alignment method, and generate a PML
 3497     file, type:
 3498 
 3499         % PyMOLVisualizeMacromolecules.py --align yes  --alignMode FirstChain
 3500           --alignRefFile Sample5.pdb --alignMethod super   -c All  -l All -i
 3501           "Sample5.pdb,Sample6.pdb,Sample7.pdb" -o SampleOut.pml
 3502 
 3503 Author:
 3504     Manish Sud(msud@san.rr.com)
 3505 
 3506 See also:
 3507     DownloadPDBFiles.pl, PyMOLVisualizeCavities.py,
 3508     PyMOLVisualizeCryoEMDensity.py, PyMOLVisualizeElectronDensity.py,
 3509     PyMOLVisualizeInterfaces.py, PyMOLVisualizeSurfaceAndBuriedResidues.py
 3510 
 3511 Copyright:
 3512     Copyright (C) 2024 Manish Sud. All rights reserved.
 3513 
 3514     The functionality available in this script is implemented using PyMOL, a
 3515     molecular visualization system on an open source foundation originally
 3516     developed by Warren DeLano.
 3517 
 3518     This file is part of MayaChemTools.
 3519 
 3520     MayaChemTools is free software; you can redistribute it and/or modify it under
 3521     the terms of the GNU Lesser General Public License as published by the Free
 3522     Software Foundation; either version 3 of the License, or (at your option) any
 3523     later version.
 3524 
 3525 """
 3526 
 3527 if __name__ == "__main__":
 3528     main()