q /= float ( len ( self.charge ) ) for i in range ( len ( self.charge ) ): self.charge[i] -= q # . Units. for i in range ( len ( self.bond_force_constant ) ): self.bond_force_constant[i] *= UNITS_ENERGY_KILOCALORIES_PER_MOLE_TO_KILOJOULES_PER_MOLE for i in range ( len ( self.angle_force_constant ) ): self.angle_force_constant[i] *= UNITS_ENERGY_KILOCALORIES_PER_MOLE_TO_KILOJOULES_PER_MOLE for i in range ( len ( self.dihedral_force_constant ) ): self.dihedral_force_constant[i] *= UNITS_ENERGY_KILOCALORIES_PER_MOLE_TO_KILOJOULES_PER_MOLE for i in range ( len ( self.lennard_jones_acoef ) ): self.lennard_jones_acoef[i] *= UNITS_ENERGY_KILOCALORIES_PER_MOLE_TO_KILOJOULES_PER_MOLE for i in range ( len ( self.lennard_jones_bcoef ) ): self.lennard_jones_bcoef[i] *= UNITS_ENERGY_KILOCALORIES_PER_MOLE_TO_KILOJOULES_PER_MOLE self.QVERIFIED = True #=================================================================================================================================== # . Helper functions. #=================================================================================================================================== def AmberTopologyFile_ToSystem ( filename, log = logFile, mmModel = None ): """Helper function that reads a system from an Amber Topology file.""" infile = AmberTopologyFileReader ( filename ) infile.Parse ( log = log ) infile.Verify ( ) infile.Summary ( log = log ) system = infile.ToSystem ( mmModel = mmModel ) return system # . Importer definitions. _Importer.AddHandler ( { System : AmberTopologyFile_ToSystem } , [ "top", "TOP" ], "Amber Topology", defaultFunction = AmberTopologyFile_ToSystem ) #=================================================================================================================================== # . Test. #=================================================================================================================================== if __name__ == "__main__": pass
return infile.ToCoordinates3() def GromacsCrdFile_ToCoordinates3(filename, log=logFile): """Helper function that returns a set of coordinates from a Gromacs .gro file.""" infile = GromacsCrdFileReader(filename) infile.Parse(log=log) infile.Summary(log=log) return infile.ToCoordinates3() def GromacsCrdFile_ToSymmetry(filename, log=logFile): """Helper function that reads symmetryparamters from a Gromacs .gro file.""" infile = GromacsCrdFileReader(filename) infile.Parse(log=log) infile.Summary(log=log) return infile.ToSymmetryParameters() # . Importer definitions. _Importer.AddHandler({Coordinates3: GromacsCrdFile_ToCoordinates3}, ["gro", "GRO"], "Gromacs Coordinates", defaultFunction=GromacsCrdFile_ToCoordinates3) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
def MOL2File_ToCoordinates3(filename, log=logFile): """Helper function that reads coordinates from a MOL2 file.""" infile = MOL2FileReader(filename) infile.Parse(log=log) coordinates3 = infile.ToCoordinates3() return coordinates3 def MOL2File_ToSystem(filename, log=logFile): """Helper function that reads a system from a MOL2 file.""" infile = MOL2FileReader(filename) infile.Parse(log=log) system = infile.ToSystem() return system # . Importer definitions. _Importer.AddHandler( { Coordinates3: MOL2File_ToCoordinates3, System: MOL2File_ToSystem }, ["mol2", "MOL2"], "Tripos MOL2", defaultFunction=MOL2File_ToSystem) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
def JaguarOutputFile_ToCoordinates3(filename): """Helper function that reads the coordinates from a Jaguar output file.""" outfile = JaguarOutputFileReader(filename) outfile.Parse() coordinates3 = outfile.ToCoordinates3() return coordinates3 def JaguarOutputFile_ToSystem(filename): """Helper function that reads a system from a Jaguar outputfile.""" outfile = JaguarOutputFileReader(filename) outfile.Parse() system = outfile.ToSystem() return system # . Importer definitions. _Importer.AddHandler( { Coordinates3: JaguarOutputFile_ToCoordinates3, System: JaguarOutputFile_ToSystem }, ["jagout", "jout", "JAGOUT", "JOUT"], "Jaguar Output", defaultFunction=JaguarOutputFile_ToSystem) #=================================================================================================================================== # . Test. #=================================================================================================================================== if __name__ == "__main__": pass
log=logFile, useComponentLibrary=False): """Helper function that returns a system defined by the atom data in a whitespace-delimited PQR file.""" return PDBFile_ToSystem(fileName, embeddedHydrogens=embeddedHydrogens, libraryPaths=libraryPaths, log=log, pqrFormat=True, useComponentLibrary=useComponentLibrary) # . Importer definitions. _Importer.AddHandler( { Coordinates3: PDBFile_ToCoordinates3, PDBModel: PDBFile_ToPDBModel, System: PDBFile_ToSystem }, ["ent", "ENT", "pdb", "PDB"], "Protein Data Bank", defaultFunction=PDBFile_ToSystem) _Importer.AddHandler( { Coordinates3: PQRFile_ToCoordinates3, System: PQRFile_ToSystem }, ["pqr", "PQR"], "PQR", defaultFunction=PQRFile_ToSystem) #================================================================================================================================== # . Test. #================================================================================================================================== if __name__ == "__main__":
infile = MOLFileReader(filename) infile.Parse(log=log) system = infile.ToSystem(index=index) return system def SDFFile_ToSystems(filename, log=logFile): """Helper function that reads all the systems from an SDF file.""" infile = MOLFileReader(filename) infile.Parse(log=log) systems = [] for i in range(len(infile.molrecords)): systems.append(infile.ToSystem(index=i)) return systems # . Importer definitions. _Importer.AddHandler( { Coordinates3: MOLFile_ToCoordinates3, System: MOLFile_ToSystem }, ["mol", "MOL"], "MDL MOL", defaultFunction=MOLFile_ToSystem) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
infile = GaussianCubeFileReader(path) infile.Parse(log=log) system = infile.ToCoordinates3() return system def GaussianCubeFile_ToSystem(path, log=logFile, volumetricdata=None): """Helper function that reads a system from a Gaussian cube file.""" infile = GaussianCubeFileReader(path) infile.Parse(log=log) system = infile.ToSystem() if volumetricdata is not None: volumetricdata.update(infile.ToVolumetricData()) return system # . Importer definitions. _Importer.AddHandler( { Coordinates3: GaussianCubeFile_ToCoordinates3, System: GaussianCubeFile_ToSystem }, ["cub", "CUB", "cube", "CUBE"], "Gaussian Cube File", defaultFunction=GaussianCubeFile_ToSystem) #=================================================================================================================================== # . Test. #=================================================================================================================================== if __name__ == "__main__": pass
def ToPolygonalSurface(self): """Return a polygonal surface.""" surface = None if self.QPARSED: surface = self.surface return surface #=================================================================================================================================== # . Helper functions. #=================================================================================================================================== def OOGLOffFile_ToPolygonalSurface(path, log=logFile): """Helper function that reads a surface from an OOGL Off file.""" infile = OOGLOffFileReader(path) infile.Parse() surface = infile.ToPolygonalSurface() return surface # . Importer definitions. _Importer.AddHandler({PolygonalSurface: OOGLOffFile_ToPolygonalSurface}, ["off", "oogloff"], "OOGL Off", defaultFunction=OOGLOffFile_ToPolygonalSurface) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
def ORCAOutputFile_ToCoordinates3(filename, frameIndex=-1): """Helper function that reads the coordinates from an ORCA output file.""" infile = ORCAOutputFileReader(filename) infile.Parse() return infile.ToCoordinates3(frameIndex=frameIndex) def ORCAOutputFile_ToSystem(filename, frameIndex=-1): """Helper function that reads a system from an ORCA output file.""" infile = ORCAOutputFileReader(filename) infile.Parse() return infile.ToSystem(frameIndex=frameIndex) # . Importer definitions. _Importer.AddHandler( { Coordinates3: ORCAOutputFile_ToCoordinates3, System: ORCAOutputFile_ToSystem }, ["olog", "oout", "OLOG", "OOUT"], "ORCA Output", defaultFunction=ORCAOutputFile_ToSystem) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
#=================================================================================================================================== # . Helper functions. #=================================================================================================================================== def AmberCrdFile_ToCoordinates3(filename, log=logFile): """Helper function that reads coordinates from an Amber crd file.""" infile = AmberCrdFileReader(filename) infile.Parse(log=log) infile.Summary(log=log) return infile.ToCoordinates3() def AmberCrdFile_ToSymmetryParameters(filename, log=logFile): """Helper function that reads symmetryparamters from an Amber crd file.""" infile = AmberCrdFileReader(filename) infile.Parse(log=log) infile.Summary(log=log) return infile.ToSymmetryParameters() # . Importer definitions. _Importer.AddHandler({Coordinates3: AmberCrdFile_ToCoordinates3}, ["crd", "CRD"], "Amber Coordinates", defaultFunction=AmberCrdFile_ToCoordinates3) #=================================================================================================================================== # . Test. #=================================================================================================================================== if __name__ == "__main__": pass
def JaguarInputFile_ToCoordinates3(filename): """Helper function that reads the coordinates from a Jaguar input file.""" infile = JaguarInputFileReader(filename) infile.Parse() coordinates3 = infile.ToCoordinates3() return coordinates3 def JaguarInputFile_ToSystem(filename, log=logFile): """Helper function that reads a system from a Jaguar inputfile.""" infile = JaguarInputFileReader(filename) infile.Parse() system = infile.ToSystem() return system # . Importer definitions. _Importer.AddHandler( { Coordinates3: JaguarInputFile_ToCoordinates3, System: JaguarInputFile_ToSystem }, ["jagin", "jin", "JAGIN", "JIN"], "Jaguar Input", defaultFunction=JaguarInputFile_ToSystem) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
def XYZFiles_ToSystemGeometryTrajectory(inPaths, outPath, system): """Convert XYZ files to a SystemGeometryTrajectory. Files are added in the order that they are supplied. """ # . Define the output trajectory. outTrajectory = SystemGeometryTrajectory(outPath, system, mode="w") # . Loop over paths. for inPath in inPaths: system.coordinates3 = XYZFile_ToCoordinates3(inPath) outTrajectory.WriteOwnerData() outTrajectory.Close() # . Importer definitions. _Importer.AddHandler( { Coordinates3: XYZFile_ToCoordinates3, System: XYZFile_ToSystem }, ["xyz"], "XYZ", defaultFunction=XYZFile_ToSystem) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
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 # . Importer definitions. _Importer.AddHandler({System: mmCIFFile_ToSystem}, ["mmcif", "MMCIF"], "Macromolecular Crystallographic Information File", defaultFunction=mmCIFFile_ToSystem) #=================================================================================================================================== # . Test. #=================================================================================================================================== if __name__ == "__main__": pass
"""Helper function that returns a set of coordinates from a CHARMM CRD file.""" infile = CHARMMCRDFileReader ( filename ) infile.Parse ( log = log ) infile.Summary ( log = log ) return infile.ToCoordinates3 ( ) def CHARMMCRDFile_ToSequence ( filename, log = logFile ): """Helper function that returns a sequence from a CHARMM CRD file.""" infile = CHARMMCRDFileReader ( filename ) infile.Parse ( log = log ) infile.Summary ( log = log ) return infile.ToSequence ( ) def CHARMMCRDFile_ToSystem ( filename, log = logFile ): """Helper function that returns a system from a CHARMM CRD file.""" infile = CHARMMCRDFileReader ( filename ) infile.Parse ( log = log ) infile.Summary ( log = log ) return infile.ToSystem ( ) # . Importer definitions. _Importer.AddHandler ( { Coordinates3 : CHARMMCRDFile_ToCoordinates3 , System : CHARMMCRDFile_ToSystem } , [ "chm", "CHM" ], "Charmm Coordinates", defaultFunction = CHARMMCRDFile_ToSystem ) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
if not QOK: self.Warning ( "Unable to build Cartesian coordinates from Z-matrix card number {:d}.".format ( i+1 ), True ) break #=================================================================================================================================== # . Helper functions. #=================================================================================================================================== def MopacInputFile_ToCoordinates3 ( filename ): """Helper function that reads the coordinates from a Mopac input file.""" infile = MopacInputFileReader ( filename ) infile.Parse ( ) coordinates3 = infile.ToCoordinates3 ( ) return coordinates3 def MopacInputFile_ToSystem ( filename ): """Helper function that reads a system from a Mopac input file.""" infile = MopacInputFileReader ( filename ) infile.Parse ( ) system = infile.ToSystem ( ) return system # . Importer definitions. _Importer.AddHandler ( { Coordinates3 : MopacInputFile_ToCoordinates3 , System : MopacInputFile_ToSystem } , [ "mopin", "MOPIN" ], "MOPAC Input", defaultFunction = MopacInputFile_ToSystem ) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
infile.Parse(log=log) infile.Summary(log=log) return infile.ToSequence() def fDynamoCRDFile_ToSystem(fileName, log=logFile): """Helper function that returns a system from an fDynamo CRD file.""" # atomTranslation = kwargs.get ( "atomTranslation", {} ) # . For future use (maybe). # residueTranslation = kwargs.get ( "residueTranslation", {} ) # subsystemTranslation = kwargs.get ( "subsystemTranslation ", {} ) infile = fDynamoCRDFileReader(fileName) infile.Parse(log=log) infile.Summary(log=log) return infile.ToSystem() # . Importer definitions. _Importer.AddHandler( { Coordinates3: fDynamoCRDFile_ToCoordinates3, System: fDynamoCRDFile_ToSystem }, ["fcrd", "FCRD"], "Fortran Dynamo Coordinates", defaultFunction=fDynamoCRDFile_ToSystem) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
return system #=================================================================================================================================== # . Helper functions. #=================================================================================================================================== def CHARMMPSFFile_ToSystem(filename, isXPLOR=False, log=logFile, mmModel=None, parameters=None): """Helper function that generates a system from a CHARMM PSF file.""" infile = CHARMMPSFFileReader(filename) infile.Parse(isXPLOR=isXPLOR, log=log) infile.Summary(log=log) system = infile.ToSystem(mmModel=mmModel, parameters=parameters) return system # . Importer definitions. _Importer.AddHandler({System: CHARMMPSFFile_ToSystem}, ["psf", "psfx", "PSF", "PSFX"], "Charmm PSF", defaultFunction=CHARMMPSFFile_ToSystem) #=================================================================================================================================== # . Testing. #=================================================================================================================================== if __name__ == "__main__": pass
#=================================================================================================================================== # . Helper functions. #=================================================================================================================================== def CIFFile_ToSystem ( path, blockCode = None, disorderGroup = _DefaultDisorderGroup, log = logFile ): """Helper function that reads a system from a CIF file.""" inFile = CIFFileReader ( path ) inFile.Parse ( ) inFile.Summary ( log = log ) system = inFile.ToSystem ( blockCode = blockCode, disorderGroup = disorderGroup ) return system def CIFFile_ToSystems ( path, disorderGroup = _DefaultDisorderGroup, log = logFile ): """Helper function that reads all the systems from a CIF file.""" inFile = CIFFileReader ( path ) inFile.Parse ( ) inFile.Summary ( log = log ) systems = [] for key in sorted ( inFile.dataBlocks.keys ( ) ): systems.append ( inFile.ToSystem ( blockCode = key, disorderGroup = disorderGroup ) ) return systems # . Importer definitions. _Importer.AddHandler ( { System : CIFFile_ToSystem } , [ "cif", "CIF" ], "Crystallographic Information File", defaultFunction = CIFFile_ToSystem ) #=================================================================================================================================== # . Test. #=================================================================================================================================== if __name__ == "__main__": pass