def Summary(self, log=logFile): """Print a summary of the stored data.""" if self.QPARSED and LogFileActive(log): # . Heading. if self.name is None: log.Heading("mmCIF File Summary", qblankline=True) else: log.Heading("Summary for mmCIF File \"" + self.name + "\"", qblankline=True) # . Basic data. summary = log.GetSummary() summary.Start("mmCIF File Data Summary") summary.Entry("Data Blocks", "{:d}".format(len(self.datablocks))) summary.Entry("Warnings", "{:d}".format(self.nwarnings)) summary.Stop() # . Data blocks and models. mmcifmodels = getattr(self, "mmcifmodels", {}) keys = self.datablocks.keys() keys.sort() for key in keys: summary = log.GetSummary(pageWidth=_SUMMARYPAGEWIDTH) summary.Start("Summary for Data Block " + key) tablenames = self.datablocks[key].keys() tablenames.sort() for tablename in tablenames: summary.Entry( tablename, "{:d}".format( self.datablocks[key][tablename].NumberOfRows())) summary.Stop() # . Models. if key in mmcifmodels: mmcifmodels[key].Summary(log=log)
def Parse ( self, log = logFile, filterlevel = -1, QGEOMETRY = True ): """Parse the data on the file.""" if not self.QPARSED: # . Initialization. if LogFileActive ( log ): self.log = log # . Open the file. self.Open ( ) try: # . Keyword line. self._ParseKeywords ( ) # . Title line. self._ParseTitle ( ) # . Extra information. self._ParseExtras ( ) # . Geometry. if QGEOMETRY: if self.QXYZ: self._ParseXYZ ( ) else: self._ParseZMatrix ( ) except EOFError: pass # . Close the file. self.WarningStop ( ) self.Close ( ) # . Set the parsed flag and some other options. self.log = None self.QPARSED = True # . Filter out Mopac-specific atoms. self.FilterAtoms ( filterlevel )
def Summary(self, log=logFile): """Summary.""" if LogFileActive(log) and ((self.mmModel is not None) or (self.qcModel is not None)): if self.label is None: title = "Energy Model Summary" else: title = "Summary for Energy Model \"" + self.label + "\"" log.Heading(title, includeBlankLine=True) if self.mmModel is not None: summary = log.GetSummary(pageWidth=100) if self.mmModel.label is None: summary.Start("MM Model Summary") else: summary.Start("Summary for MM Model \"" + self.mmModel.label + "\"") for item in self.MMObjects(): if hasattr(item, "SummaryEntry"): item.SummaryEntry(summary) summary.Stop() if self.qcModel is not None: summary = log.GetSummary() if self.qcModel.label is None: summary.Start("QC Model Summary") else: summary.Start("Summary for QC Model \"" + self.qcModel.label + "\"") for item in self.QCObjects(): if hasattr(item, "SummaryEntry"): item.SummaryEntry(summary) summary.Stop() if self.nbModel is not None: self.nbModel.Summary(log) if self.softConstraints is not None: self.softConstraints.Summary(log)
def __init__(self, customFiles=None, log=logFile): """Constructor.""" # . Include standard files files = glob.glob(os.path.join(YAMLPATHIN, "sites", "*.yaml")) # . Include custom files if customFiles: for filename in customFiles: fileTruncated = os.path.basename(filename) if os.path.exists(filename): if LogFileActive(log): log.Text("\nIncluding custom file: %s\n" % fileTruncated) files.append(filename) else: raise ContinuumElectrostaticsError( "Custom file %s not found." % fileTruncated) # . Check for a known extension stem, extension = os.path.splitext(filename) if not extension in (".yaml", ".YAML", ".est", ".EST"): raise ContinuumElectrostaticsError( "Unknown extension of file: %s" % fileTruncated) # . Parse all files self.log = log self.files = files self._Parse()
def Parse(self, log=logFile): """Parsing.""" if not self.QPARSED: # . Initialization. if LogFileActive(log): self.log = log # . Open the file. self.Open() # . Parse the data. try: # . Parse all entries. QCONTINUE = True while QCONTINUE: line = self.GetLine() # print line if line.startswith(_RTISTRING + "ATOM"): self.ParseAtomSection() elif line.startswith(_RTISTRING + "BOND"): self.ParseBondSection() elif line.startswith(_RTISTRING + "CRYSIN"): self.ParseCrysinSection() elif line.startswith(_RTISTRING + "MOLECULE"): self.ParseMoleculeSection() # elif line.startswith ( _RTISTRING ): self.ParseUnknownSection ( ) except EOFError: pass # . Close the file. self.WarningStop() self.Close() # . Set the parsed flag and some other options. self.log = None self.QPARSED = True
def WriteCurves(self, directory=_DefaultDirectory, log=logFile): """Write calculated curves to a directory.""" if self.isCalculated: # Initialize output directory if not os.path.exists(directory): try: os.makedirs(directory) except: raise ContinuumElectrostaticsError( "Cannot create directory %s" % directory) # For each instance of each site, write a curve file meadModel = self.owner phdata = self.steps for site in meadModel.sites: for instance in site.instances: # Collect instance data lines = [] for step in range(self.nsteps): lines.append("%f %f\n" % ( self.curveStart + step * self.curveSampling, phdata[step][site.siteIndex][instance.instIndex], )) # Write instance data filename = os.path.join( directory, "%s_%s.dat" % (site.label, instance.label)) WriteInputFile(filename, lines) if LogFileActive(log): log.Text("\nWriting curve files complete.\n")
def Parse(self, log=logFile): """Parsing.""" if not self.QPARSED: # . Initialization. if LogFileActive(log): self.log = log # . Get the atom line format. atomlineformat = self.GetAtomLineFormat() # . Open the file. self.Open() # . Parse all the lines. try: # . Keyword line. self.title = self.GetLine() # . Number of atoms. items = self.GetTokens(converters=(int, )) natoms = items[0] # . The coordinate data. self.xyz = Coordinates3(natoms) for n in range(natoms): tokens = self.GetFixedFormatTokens(*atomlineformat) for i in range(3): self.xyz[n, i] = float(tokens[i + 3] * 10.0) # . Symmetry data. self.symmetryItems = self.GetTokens() except EOFError: pass # . Close the file. self.WarningStop() self.Close() # . Set the parsed flag and some other options. self.log = None self.QPARSED = True
def GetLog(self): """Get the log file.""" if self.outputPath is not None: self.log = TextLogFileWriter(fileName=self.outputPath) log = self.log if not LogFileActive(log): log = None return log
def __init__(self, meadModel, selectedSites, pH=7.0, log=logFile): """Construct a substate defined by |selectedSites|. |selectedSites| is a sequence of three-element sequences (segmentName, residueName, residueSerial)""" pairs = [] indicesOfSites = [] for selectedSegment, selectedResidueName, selectedResidueSerial in selectedSites: foundSite = False for siteIndex, site in enumerate(meadModel.sites): if site.segName == selectedSegment and site.resSerial == selectedResidueSerial: indicesOfSites.append(siteIndex) foundSite = True break if not foundSite: raise ContinuumElectrostaticsError( "Site %s %s %d not found." % (selectedSegment, selectedResidueName, selectedResidueSerial)) pairs.append([selectedSegment, selectedResidueSerial]) self.indicesOfSites = indicesOfSites self.isCalculated = False self.substates = None self.owner = meadModel self.pH = pH self.vector = self._DetermineLowestEnergyVector() self.vector.DefineSubstate(pairs) if LogFileActive(log): nsites = len(indicesOfSites) log.Text("\nSubstate is initialized with %d site%s.\n" % (nsites, "s" if nsites > 1 else ""))
def Summary(self, log=logFile): """Summary.""" if LogFileActive(log) and self.QPARSED: summary = log.GetSummary() summary.Start("Amber Crd File Summary") summary.Entry("Number of Atoms", "{:d}".format(self.xyz.rows)) summary.Stop()
def Summary(self, log=logFile): """Write a summary of the data set.""" if LogFileActive(log): if len(self) == 0: log.Paragraph("Data set " + self.label + " is empty.") else: # . Data. if len(self.data) > 0: table = log.GetTable(columns=[20, 20, 20]) table.Start() table.Title(self.Path()) table.Heading("Label") table.Heading("Reference") table.Heading("Tolerance") keys = self.data.keys() keys.sort() for key in keys: datum = self.data[key] table.Entry(datum.label, alignment="left") table.Entry(datum.ValueAsString()) table.Entry(datum.ToleranceAsString()) table.Stop() # . Header. # else: # log.Heading ( self.Path ( ), QBLANKLINE = True ) # . Children. if len(self.children) > 0: keys = self.children.keys() keys.sort() for key in keys: self.children[key].Summary(log=log)
def Parse(self, log=logFile): """Parse the data on the file.""" if not self.QPARSED: # . Initialization. if LogFileActive(log): self.log = log # . Open the file. self.Open() try: # . Number of atoms. items = self.GetTokens(converters=[int]) natoms = items[0] # . Title line. self.title = self.GetLine() # . XYZ lines. self.atomicNumbers = [] self.coordinates3 = Coordinates3.WithExtent(natoms) for i in range(natoms): items = self.GetTokens(converters=[ PeriodicTable.AtomicNumber, float, float, float ]) self.atomicNumbers.append(items[0]) self.coordinates3[i, 0] = items[1] self.coordinates3[i, 1] = items[2] self.coordinates3[i, 2] = items[3] except EOFError: pass # . Close the file. self.WarningStop() self.Close() # . Set the parsed flag and some other options. self.log = None self.QPARSED = True
def PrintInteractions(self, sort=False, log=logFile): """Print interactions of an instance of a site with other instances of other sites.""" if LogFileActive(log): site = self.parent model = site.parent interactions = self.interactions if model.isCalculated: instances = [] for site in model.sites: for instance in site.instances: wij = interactions[instance._instIndexGlobal] instances.append([ wij, site.segName, site.resName, site.resSerial, instance.label ]) if sort: instances.sort() tab = log.GetTable(columns=[6, 6, 6, 6, 16]) tab.Start() tab.Heading("Instance of a site", columnSpan=4) tab.Heading("Wij") for wij, segName, resName, resSerial, label in instances: entries = ( ("%s" % segName), ("%s" % resName), ("%d" % resSerial), ("%s" % label), ("%16.4f" % wij), ) for entry in entries: tab.Entry(entry) tab.Stop()
def mmCIFFile_ToSystem(filename, altLoc=_UNDEFINEDCHARACTER, datablockname=None, log=logFile, modelNumber=_DEFAULTMODELNUMBER, embeddedHydrogens=False, useComponentLibrary=False): """Helper function that returns a system defined by the atom data in a mmCIF file.""" # . Parse the file. infile = mmCIFFileReader(filename) infile.Parse(log=log) infile.GenerateModels(log=log) infile.Summary(log=log) # . Get the model. model = infile.GetModel(datablockname=datablockname) # . Make the system. system = model.ToSystem(altLoc=altLoc, modelNumber=modelNumber, embeddedHydrogens=embeddedHydrogens) # . Print out whether there are undefined coordinates. if LogFileActive(log) and (system.coordinates3.numberUndefined > 0): # . Determine the types of atoms with undefined coordinates. nheavy = 0 nhydrogen = 0 for i in system.coordinates3.undefined: if system.atoms[i].atomicNumber == 1: nhydrogen += 1 else: nheavy += 1 # . Output a summary. summary = log.GetSummary() summary.Start("Undefined Coordinates") summary.Entry("Heavy Atoms", "{:d}".format(nheavy)) summary.Entry("Hydrogens", "{:d}".format(nhydrogen)) summary.Stop() # . Finish up. return system
def SummaryMaxima(self, log=logFile): """Output the maxima.""" # . Output. if LogFileActive(log) and (self.maximaA is not None) and (self.maximaI is not None): # . Consistency between two profiles. if len(self.maximaA) == len(self.maximaI): log.Paragraph("Number of maxima found = {:d}".format( len(self.maximaI))) table = log.GetTable(columns=[20, 20, 20]) table.Start() table.Title("Maxima Summary") table.Heading("Structure") table.Heading("Arc Length") table.Heading("Function") for ((a, fa), (s, fs)) in zip(self.maximaA, self.maximaI): table.Entry("{:.3f}".format(s)) table.Entry("{:.3f}".format(a)) table.Entry("{:.3f}".format(fs)) table.Stop() # . Inconsistency between profiles. else: for (tag, maxima) in (("Arc Length", self.maximaA), ("Structure", self.maximaI)): log.Paragraph("Number of {:s} maxima found = {:d}".format( tag.lower(), len(maxima))) table = log.GetTable(columns=[20, 20]) table.Start() table.Title(tag + " Maxima Summary") table.Heading("Abscissa") table.Heading("Function") for (x, f) in maxima: table.Entry("{:.3f}".format(x)) table.Entry("{:.3f}".format(f)) table.Stop()
def Parse(self, log=logFile): """Parse the data on the file.""" if not self.QPARSED: # . Initialization. if LogFileActive(log): self.log = log # . Open the file. self.Open() try: # . Loop over the lines. while True: line = self.GetLine(QWARNING=False) # . Entry name. if line.startswith("entry name:"): entryname = line[11:].strip() if len(entryname) > 0: self.entryname = entryname # . Other sections. elif line.startswith("&gen") or line.startswith("$gen"): self.ParseGenSection(line) elif line.startswith("&guess") or line.startswith( "$guess"): self.ParseGuessSection(line) elif line.startswith("&hess") or line.startswith("$hess"): self.ParseHessianSection(line) elif line.startswith("&zmat") or line.startswith("$zmat"): self.ParseZmatSection(line) except: pass # . Close the file. self.WarningStop() self.Close() # . Set the parsed flag and some other options. self.log = None self.QPARSED = True
def GetSystem(self, doQCMM=True, log=logFile, nbModel=None, qcModel=None): """Get the system with the energy model defined.""" # . Basic setup. molecule = MOLFile_ToSystem( os.path.join(self.dataPath, self.fileName + ".mol")) molecule.label = self.label molecule.DefineMMModel(self.mmModel) # . Set up the QC model. if qcModel is not None: molecule.electronicState = ElectronicState( charge=self.qcCharge, multiplicity=self.multiplicity) if doQCMM: molecule.DefineQCModel(qcModel, qcSelection=self.qcSelection) else: molecule.DefineQCModel(qcModel) # . Set up the NB model. if (qcModel is None) or doQCMM: if nbModel is None: molecule.DefineNBModel(self.nbModel) else: molecule.DefineNBModel(nbModel) # . Summary. if LogFileActive(log): molecule.Summary(log=log) log.Paragraph("\nFormula = " + molecule.atoms.FormulaString() + ".") # . Finish up. return molecule
def Summary(self, log=logFile): """Print a summary of the stored data.""" if self.QPARSED and LogFileActive(log): # . Heading. if self.name is None: log.Heading(self.FileType() + " File Summary", includeBlankLine=True) else: log.Heading("Summary for " + self.FileType() + " File \"" + self.name + "\"", includeBlankLine=True) # . Basic data. summary = log.GetSummary() summary.Start("STAR File Data Summary") summary.Entry("Data Blocks", "{:d}".format(len(self.dataBlocks))) summary.Entry("Warnings", "{:d}".format(self.nwarnings)) summary.Stop() # . Data blocks. for dataBlockKey in sorted(self.dataBlocks.keys()): dataBlock = self.dataBlocks[dataBlockKey] d = t = 0 for value in dataBlock.values(): if isinstance(value, STARFileTable): t += 1 else: d += 1 summary = log.GetSummary(pageWidth=_SummaryPageWidth) summary.Start("Summary for Data Block " + dataBlockKey) summary.Entry("Data Values", "{:d}".format(d)) summary.Entry("Tables", "{:d}".format(t)) summary.Stop()
def CrystalAnalyzeTransformations(system, log=logFile): """Analyze the transformations for a crystal. Transformations must be either proper or improper rotations and have inverses. An inverse check needs to be added. """ # . Basic checks. if LogFileActive(log) and isinstance(system, System) and (system.symmetry is not None): # . Get the lattice matrices for the system. sp = system.configuration.symmetryParameters M = sp.M inverseM = sp.inverseM # . Loop over the transformations. for (i, t3) in enumerate(system.symmetry.transformations): # . Output the transformation. newt3 = Clone(t3) newt3.Orthogonalize(M, inverseM) newt3.Print(log=log, title="Transformation {:d}".format(i)) # . Check for a rotation of some sort. if newt3.rotation.IsProperRotation(): log.Paragraph("Transformation is a proper rotation.") elif newt3.rotation.IsImproperRotation(): log.Paragraph("Transformation is an improper rotation.") else: log.Paragraph( "Transformation is neither a proper nor an improper rotation." )
def CalculateSubstateEnergies(self, log=logFile): """Calculate microstate energies for a substate.""" if not self.isCalculated: indicesOfSites = self.indicesOfSites increment = True substates = [] vector = self.vector owner = self.owner vector.ResetSubstate() while increment: Gmicro = owner.CalculateMicrostateEnergy(vector, pH=self.pH) indicesOfInstances = [] for siteIndex in indicesOfSites: indicesOfInstances.append(vector[siteIndex]) substates.append([Gmicro, indicesOfInstances]) increment = vector.IncrementSubstate() substates.sort() lowestSubstate = substates[0] lowestEnergy = lowestSubstate[0] self.substates = substates self.zeroEnergy = lowestEnergy self.isCalculated = True if LogFileActive(log): log.Text( "\nCalculating substate energies at pH=%.1f complete.\n" % self.pH)
def Summary(self, log=logFile): """Print a summary of the stored data.""" if self.QPARSED and LogFileActive(log): summary = log.GetSummary() summary.Start("Gromacs .gro File Summary") summary.Entry("Number of Atom Lines", "{:d}".format(self.xyz.rows)) summary.Stop()
def ReportsSummary(self, reports, log=logFile): """Write out a summary of the reports.""" if LogFileActive(log): table = log.GetTable(columns=[10, 10, 10, 10, 10, 10, 10, 10]) table.Start() table.Title("Minimization Results") table.Heading("Function") table.Heading("Step") table.Heading("Info") table.Heading("Calls") table.Heading("Variable") table.Heading("Gradient") table.Heading("Function") table.Heading("Converged") for report in reports: table.Entry("{:d}".format(report["Function Index"])) table.Entry("{:.1g}".format(report["Initial Step"])) message = report["Status Message"] if message.startswith("Minimization converged"): info = 1 elif message.startswith("Rounding errors "): info = 2 elif message.startswith("The relative width"): info = 3 else: raise ValueError("Unknown message: " + message) table.Entry("{:d}".format(info)) table.Entry("{:d}".format(report["Function Calls"])) table.Entry("{:.3f}".format(report["Variable"])) table.Entry("{:.3g}".format(report["Gradient"])) table.Entry("{:.3g}".format(report["Function Value"])) table.Entry("{!r}".format(report["Converged"])) table.Stop()
def HandlerSummary ( self, log = logFile, title = "Export/Import Handler Container" ): """Handler summary.""" if LogFileActive ( log ): # . Gather data. data = [] l0 = l1 = l2 = 18 for handler in self.handlers: label = handler.label identifiers = handler.identifierString objects = handler.objectString l0 = max ( l0, len ( label ) ) l1 = max ( l1, len ( identifiers ) ) l2 = max ( l2, len ( objects ) ) data.append ( ( label, identifiers, objects ) ) data.sort ( ) # . Output. table = log.GetTable ( columns = [ l0+2, l1+2, l2 ] ) table.Start ( ) table.Title ( title ) table.Heading ( "Format Label" ) table.Heading ( "Other Identifiers" ) table.Heading ( "Objects" ) for ( label, identifiers, objects ) in data: table.Entry ( label , alignment = "l" ) table.Entry ( identifiers, alignment = "l" ) table.Entry ( objects , alignment = "l" ) table.Stop ( )
def SubsystemSummary ( self, log = logFile ): """Write out a summary of the subsystems.""" if LogFileActive ( log ): table = log.GetTable ( columns = [ 8, 16, 12, 12, 12, 40 ] ) table.Start ( ) table.Title ( "Multi-Layer Objective Function Subsystems" ) table.Heading ( "Index" ) table.Heading ( "Total Atoms" ) table.Heading ( "Link Atoms" ) table.Heading ( "Weight" ) table.Heading ( "QC Charge" ) table.Heading ( "Energy Model" ) # . System. table.Entry ( "0" ) table.Entry ( "{:d}".format ( len ( self.system.atoms ) ) ) table.Entry ( "0" ) table.Entry ( "{:.3f}".format ( 1.0 ) ) table.Entry ( "{:d}".format ( self.system.electronicState.charge ) ) table.Entry ( self.system.energyModel.label ) # . Subsystems. for ( i, subsystem ) in enumerate ( self.subsystems ): table.Entry ( "{:d}".format ( i+1 ) ) table.Entry ( "{:d}".format ( len ( subsystem.system.atoms ) ) ) table.Entry ( "{:d}".format ( len ( subsystem.boundaryAtoms ) ) ) table.Entry ( "{:.3f}".format ( subsystem.weight ) ) table.Entry ( "{:d}".format ( subsystem.system.electronicState.charge ) ) table.Entry ( subsystem.system.energyModel.label ) # . Finish up the table. table.Stop ( )
def TimingSummary(self, log=logFile, orderByMagnitude=False): """Timing summary.""" self.TimingStop() self.timings.Summary(log=log, orderByMagnitude=orderByMagnitude) if LogFileActive(log): log.Paragraph("Number of Energy Calls = {:d}".format( self.numberOfEnergyCalls))
def CheckMissingParameters(self, missingParameters, log): """Print any missing parameters and raise an error.""" numberMissing = len(missingParameters) if numberMissing > 0: if LogFileActive(log): # . Sort. missingParameters = list(missingParameters) missingParameters.sort() # . Find label data. labelCount = 0 labelLength = 0 tagLength = 0 for (tag, labels) in missingParameters: labelCount = max(len(labels), labelCount) tagLength = max(len(tag), tagLength) for label in labels: labelLength = max(len(label), labelLength) # . Output. table = log.GetTable(columns=[tagLength + 2] + labelCount * [max(10, labelLength + 2)]) table.Start() table.Title("Missing Force Field Parameters") for (tag, labels) in missingParameters: table.Entry(tag, alignment="l") for label in labels: table.Entry(label) if len(labels) < labelCount: table.EndRow() table.Stop() raise MMModelError( "There are {:d} missing force field parameters.".format( numberMissing))
def Parse(self, log=logFile): """Parse the data on the file.""" if not self.QPARSED: # . Initialization. if LogFileActive(log): self.log = log # . Open the file. self.Open() # . Read the raw data. try: basis = [] bases = [] for (iline, line) in enumerate(self.file): line = line.strip() if len(line) <= 0: continue # . Header line. elif line.startswith("BASIS"): self.basisname = line[7:-1] # . Terminator line. elif line == "****": if len(basis) > 0: bases.append(basis) basis = [] # . General line. else: basis.append((iline, line)) except EOFError: pass # . Process the data. self._ProcessRawData(bases) # . Close the file. self.WarningStop() self.Close() # . Set the parsed flag and some other options. self.log = None self.QPARSED = True
def PrintComponentFrequency(sequence, log=logFile, title="Sequence Component Frequency"): """Print the component frequency of the entities of a sequence.""" if LogFileActive(log) and isinstance(sequence, Sequence): log.Heading(title) for entity in sequence.children: if len(entity.children) > 0: # . Frequencies. frequencies = {} for component in entity.children: frequencies[component.genericLabel] = frequencies.get( component.genericLabel, 0) + 1 keys = frequencies.keys() keys.sort() # . Output. length = min(10, len(frequencies)) table = log.GetTable(columns=length * [6, 6]) table.Start() if len(entity.label) <= 0: title = "Component Frequency for Unnamed Entity" else: title = "Component Frequency for Entity " + entity.label table.Title(title) for key in keys: table.Entry(key, alignment="r") table.Entry("{:d}".format(frequencies[key]), alignment="r") table.Stop()
def GetSystem ( self, doQCMM = False, doQCQC = False, expandToP1 = False, log = logFile, qcModel = None, useSymmetry = True ): """Get the system with the energy model defined.""" # . Read the molecule. molecule = AmberTopologyFile_ToSystem ( os.path.join ( _dataPath, self.label + ".top" ), mmModel = self.mmModel, log = log ) molecule.coordinates3 = AmberCrdFile_ToCoordinates3 ( os.path.join ( _dataPath, self.label + ".crd" ), log = log ) molecule.label = self.label # . Set up symmetry. if useSymmetry: kwargs = { "crystalClass" : self.crystalClass, "transformations" : self.transformations } kwargs.update ( self.crystalParameters ) molecule.DefineSymmetry ( **kwargs ) if expandToP1: self.p1Factor = float ( len ( molecule.symmetry.transformations ) * _numberCells ) molecule = CrystalExpandToP1 ( molecule, aRange = _aRange, bRange = _bRange, cRange = _cRange ) # . Set up the QC model. if qcModel is not None: # . QC/MM. if doQCMM: if self.qcCharge != 0: molecule.electronicState = ElectronicState ( charge = self.qcCharge ) # . For the tests do not worry if the MM charge is not zero or integral. try: molecule.DefineQCModel ( qcModel, qcSelection = self.qcSelection ) except: pass else: molecule.DefineQCModel ( qcModel ) # . Set up the NB model. if ( qcModel is None ) or doQCMM or doQCQC: molecule.DefineNBModel ( self.nbModel ) # . Summary. if LogFileActive ( log ): molecule.Summary ( log = log ) log.Paragraph ( "\nFormula = " + molecule.atoms.FormulaString ( ) + "." ) # . Finish up. return molecule
def PrintHalfpKs(self, decimalPlaces=2, sortSites=False, log=logFile): """Print pK1/2 values.""" if LogFileActive(log): if self.isCalculated: owner = self.owner entries = [] longest = 0 if not self.isHalves: self.CalculateHalfpKs() for site in owner.sites: entry = self._GetEntry(site, decimalPlaces) entries.append(entry) length = len(entry) if length > longest: longest = length tab = log.GetTable(columns=[6, 6, 6, longest]) tab.Start() tab.Heading("Site", columnSpan=3) tab.Heading("pK1/2 values of instances".center(longest)) form = "%%-%ds" % longest table = [] for site, entry in zip(owner.sites, entries): table.append( [site.segName, site.resName, site.resSerial, entry]) if sortSites: table.sort(key=lambda k: (k[0], k[1], k[2])) for segName, resName, resSerial, entry in table: tab.Entry("%6s" % segName) tab.Entry("%6s" % resName) tab.Entry("%6d" % resSerial) tab.Entry(form % entry) tab.Stop()