Example #1
0
def PDBFromGrofile(grofile,
                   stripWaters=False,
                   stripIons=False,
                   stripDummy=False):
    """Take in a *.gro Grofile file and write it as a PDB file."""

    gstruct = GromacsStructure(name=grofile, header="title")
    gstruct.load(grofile)

    p = PDBStructure()

    for gatom in gstruct.atoms:

        atom = {}
        atom["serial"] = gatom.atomnum
        atom["name"] = '%-4s' % (gatom.atomname.strip())
        atom["altLoc"] = ' '
        atom["resName"] = '%-4s' % (gatom.resname.strip())
        atom["chainID"] = ' '
        atom["resSeq"] = gatom.resnum
        atom["iCode"] = ' '
        atom["x"] = gatom.x * 10.  # *.gro files are in nm
        atom["y"] = gatom.y * 10.
        atom["z"] = gatom.z * 10.
        atom["occupancy"] = 1.0
        atom["tempFactor"] = 0.0
        atom["segID"] = '    '
        atom["element"] = '  '
        atom["charge"] = '   '

        if (atom["resName"].count('HOH') > 0) or (atom["resName"].count('SOL')
                                                  > 0):
            if not stripWaters:
                atoms.append(atom)
        elif (atom["resName"].count('Cl') > 0) or (atom["resName"].count('Na')
                                                   > 0):
            if not stripIons:
                atoms.append(atom)
        elif (atom["resName"].count('DMM') > 0):
            if not stripDummy:
                p.atoms.append(atom)
        else:
            p.atoms.append(atom)

    return p
Example #2
0
def GromacsStructureFromPDB(pdbfile):
    """Take in a PDB file a GromacsStructure class."""
    p = PDBStructure(filename=pdbfile)
    gstruct = GromacsStructure(name=pdbfile, header="title")
    gatoms = GromacsAtoms()
    for atom in p.atoms:
        gatoms.append(
            GromacsAtom(resnum=atom["resSeq"],
                        resname=atom["resName"],
                        atomname=atom["name"],
                        atomnum=atom["serial"],
                        x=(atom["x"] / 10.),
                        y=(atom["y"] / 10.),
                        z=(atom["z"] / 10.),
                        vx=0.0,
                        vy=0.0,
                        vz=0.0))
    gstruct.appendatoms(gatoms)
    return gstruct
Example #3
0
def GromacsStructureFromGrofile(grofile):
    """Create a GromacsStructure objects from a grofile."""

    gstruct = GromacsStructure(name=grofile, header="title")
    gstruct.load(grofile)
    return gstruct