Beispiel #1
0
            self.file.write("* " + line + "\n")


#===================================================================================================================================
# . Helper functions.
#===================================================================================================================================
def CHARMMPSFFile_FromSystem(path,
                             system,
                             extendedFormat=True,
                             hasCHEQ=True,
                             isXPLOR=True):
    """Helper function that writes a system to a CHARMM PSF file."""
    outFile = CHARMMPSFFileWriter(path)
    outFile.Open()
    outFile.OutputSystem(system,
                         extendedFormat=extendedFormat,
                         hasCHEQ=hasCHEQ,
                         isXPLOR=isXPLOR)
    outFile.Close()


# . Exporter definitions.
_Exporter.AddHandler({System: CHARMMPSFFile_FromSystem},
                     ["psf", "psfx", "PSF", "PSFX"], "Charmm PSF")

#===================================================================================================================================
# . Testing.
#===================================================================================================================================
if __name__ == "__main__":
    pass
Beispiel #2
0
        # . Number of vertices, faces and edges (latter not used).
        self.file.write ( "{:d} {:d} 0\n\n".format ( surface.NumberOfVertices ( ), surface.NumberOfPolygons ( ) ) )
        # . Vertices.
        format = 2 * ndimensions * " {:.10f}" + "\n"
        for items in surface.VertexIterator ( ):
            self.file.write ( format.format ( items ) )
        # . Polygons.
        self.file.write ( "\n" )
        format = "{:d}".format ( ndimensions ) + ndimensions * " {:d}" + "\n"
        for items in surface.PolygonIndexIterator ( ):
            self.file.write ( format.format ( items ) )
        # . Finish up.
        self.Close ( )

#===================================================================================================================================
# . Helper functions.
#===================================================================================================================================
def OOGLOffFile_FromPolygonalSurface ( path, surface, log = logFile ):
    """Helper function that writes a polygonal surface to an OOGL Off file."""
    outfile = OOGLOffFileWriter ( path )
    outfile.WritePolygonalSurface ( surface )

# . Exporter definitions.
_Exporter.AddHandler ( { PolygonalSurface : OOGLOffFile_FromPolygonalSurface } , [ "off", "oogloff" ], "OOGL Off" )

#===================================================================================================================================
# . Test.
#===================================================================================================================================
if __name__ == "__main__":
    pass
Beispiel #3
0
            self.file.write(_RTISTRING + "CRYSIN\n")
            self.file.write(
                "{:.3f} {:.3f} {:.3f} {:.1f} {:.1f} {:.1f}  1  1\n".format(
                    p.a, p.b, p.c, p.alpha, p.beta, p.gamma))

    def WriteSingleSystem(self, system, label=None, xyz=None):
        """Write a complete file."""
        self.Open()
        self.WriteFrame(system, label=label, xyz=xyz)
        self.Close()


#===================================================================================================================================
# . Helper functions.
#===================================================================================================================================
def MOL2File_FromSystem(filename, system, label=None, xyz=None):
    """Helper function that writes a system to a MOL2 file."""
    outfile = MOL2FileWriter(filename)
    outfile.WriteSingleSystem(system, label=label, xyz=xyz)


# . Exporter definitions.
_Exporter.AddHandler({System: MOL2File_FromSystem}, ["mol2", "MOL2"],
                     "Tripos MOL2")

#===================================================================================================================================
# . Testing.
#===================================================================================================================================
if __name__ == "__main__":
    pass
Beispiel #4
0
# . Helper functions.
#===================================================================================================================================
def XYZFile_FromSystem ( filename, system, label = None, xyz = None ):
    """Helper function that writes a system to a XYZ file."""
    outfile = XYZFileWriter ( filename )
    outfile.WriteSingleSystem ( system, label = label, xyz = xyz )

def XYZFiles_FromSystemGeometryTrajectory ( outPath, inPath, system ):
    """Convert a SystemGeometryTrajectory to XYZ files."""
    # . Define the paths.
    inTrajectory = SystemGeometryTrajectory  ( inPath, system, mode = "r" )
    if not os.path.exists ( outPath ): os.mkdir ( outPath )
    # . Find format.
    n      = len ( "{:d}".format ( len ( inTrajectory ) ) )
    format = "frame{:0" + repr ( n ) + "d}.xyz"
    # . Loop over frames.
    i = 0
    while inTrajectory.RestoreOwnerData ( ):
        XYZFile_FromSystem ( os.path.join ( outPath, format.format ( i+1 ) ), system )
        i += 1
    inTrajectory.Close ( )

# . Exporter definitions.
_Exporter.AddHandler ( { System : XYZFile_FromSystem } , [ "xyz" ], "XYZ" )

#===================================================================================================================================
# . Testing.
#===================================================================================================================================
if __name__ == "__main__":
    pass
# . Functions.
#===================================================================================================================================
def PDBFile_FromSystem(filename,
                       system,
                       occupancies=None,
                       QCONECT=False,
                       selection=None,
                       suppressICodeField=False,
                       temperatureFactors=None,
                       useSegmentEntityLabels=False):
    """Helper function that writes a system to a PDB file."""
    outfile = PDBFileWriter(filename)
    outfile.WriteSystem(system,
                        occupancies=occupancies,
                        QCONECT=QCONECT,
                        selection=selection,
                        suppressICodeField=suppressICodeField,
                        temperatureFactors=temperatureFactors,
                        useSegmentEntityLabels=useSegmentEntityLabels)


# . Exporter definitions.
_Exporter.AddHandler({System: PDBFile_FromSystem},
                     ["ent", "ENT", "pdb", "PDB"], "Protein Data Bank")

#===================================================================================================================================
# . Test.
#===================================================================================================================================
if __name__ == "__main__":
    pass
Beispiel #6
0
            symbol = PeriodicTable.Symbol(n, index=i + 1)
            self.file.write("{:<5s}{:25.15f}{:25.15f}{:25.15f}\n".format(
                symbol, xyz[i, 0], xyz[i, 1], xyz[i, 2]))
        self.file.write("&\n")

    def WriteSingleSystem(self, system, label=None, xyz=None):
        """Write a complete file."""
        self.Open()
        self.WriteFrame(system, label=label, xyz=xyz)
        self.Close()


#===================================================================================================================================
# . Helper functions.
#===================================================================================================================================
def JaguarInputFile_FromSystem(filename, system, label=None, xyz=None):
    """Helper function that writes a system to a Jaguar input file."""
    outfile = JaguarInputFileWriter(filename)
    outfile.WriteSingleSystem(system, label=label, xyz=xyz)


# . Exporter definitions.
_Exporter.AddHandler({System: JaguarInputFile_FromSystem},
                     ["jagin", "jin", "JAGIN", "JIN"], "Jaguar Input")

#===================================================================================================================================
# . Test.
#===================================================================================================================================
if __name__ == "__main__":
    pass
                    if len ( label ) <= 0: label = _UNDEFINEDCHARACTER
                    oldname     = None
                    oldsequence = None
                    for component in entity.children:
                        fields      = sequence.ParseLabel ( component.label, fields = 2 )
                        name        = fields[0]
                        newSequence = fields[1]
                        if ( name != oldname ) and ( newSequence != oldsequence ):
                            self.file.write ( "{:<10s} {:<4s} {:<6s}\n".format ( label, name, newSequence ) )
                            oldname     = name
                            oldsequence = newSequence
        # . Finish up.
        self.Close ( )

#===================================================================================================================================
# . Functions.
#===================================================================================================================================
def mmCIFFile_FromSystem ( filename, system, datalabel = _DEFAULTDATALABEL ):
    """Helper function that writes a system to a mmCIF file."""
    outfile = mmCIFFileWriter ( filename )
    outfile.WriteSystem ( system, datalabel = datalabel )

# . Exporter definitions.
_Exporter.AddHandler ( { System : mmCIFFile_FromSystem } , [ "mmcif", "MMCIF" ], "Macromolecular Crystallographic Information File" )

#===================================================================================================================================
# . Test.
#===================================================================================================================================
if __name__ == "__main__":
    pass
            if ( ( i + 1 ) % _NumberAtomsPerLine ) == 0: self.write ( "\n" )
        if ( ( len ( system.atoms ) + 1 ) % _NumberAtomsPerLine ) == 0: self.write ( "\n" )
        # . Symmetry.
        if includeSymmetryParameters:
            symmetryParameters = getattr ( system.configuration, "symmetryParameters", None )
            if symmetryParameters is not None:
                self.write ( _SymmetryLineFormat.format ( symmetryParameters.a, symmetryParameters.b, symmetryParameters.c ) )

    def WriteSystem ( self, system, includeSymmetryParameters = True, label = None, xyz = None ):
        """Write a system."""
        self.Open  ( )
        self.WriteFrame ( system, includeSymmetryParameters = includeSymmetryParameters, label = label, xyz = xyz )
        self.Close ( )

#===================================================================================================================================
# . Helper functions.
#===================================================================================================================================
def AmberCrdFile_FromSystem ( path, system, includeSymmetryParameters = True, label = None, xyz = None ):
    """Helper function that writes coordinates to an Amber crd file."""
    inFile = AmberCrdFileWriter ( path )
    inFile.WriteSystem ( system, includeSymmetryParameters = includeSymmetryParameters, label = label, xyz = xyz )

# . Exporter definitions.
_Exporter.AddHandler ( { System : AmberCrdFile_FromSystem } , [ "crd", "CRD" ], "Amber Coordinates" )

#===================================================================================================================================
# . Testing.
#===================================================================================================================================
if __name__ == "__main__":
    pass
Beispiel #9
0
            formalCharge = getattr(atom, "formalCharge", 0)
            if formalCharge != 0:
                self.file.write("M  CHG  1{:4d}{:4d}\n".format(
                    i + 1, formalCharge))
        self.file.write("M  END\n")

    def WriteSingleSystem(self, system, label=None, xyz=None):
        """Write a complete file."""
        self.Open()
        self.WriteFrame(system, label=label, xyz=xyz)
        self.Close()


#===================================================================================================================================
# . Helper functions.
#===================================================================================================================================
def MOLFile_FromSystem(filename, system, label=None, xyz=None):
    """Helper function that writes a system to a MOL file."""
    outfile = MOLFileWriter(filename)
    outfile.WriteSingleSystem(system, label=label, xyz=xyz)


# . Exporter definitions.
_Exporter.AddHandler({System: MOLFile_FromSystem}, ["mol", "MOL"], "MDL MOL")

#===================================================================================================================================
# . Testing.
#===================================================================================================================================
if __name__ == "__main__":
    pass