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
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
def GromacsStructureFromGrofile(grofile): """Create a GromacsStructure objects from a grofile.""" gstruct = GromacsStructure(name=grofile, header="title") gstruct.load(grofile) return gstruct
def GromacsStructureFromGrofile(grofile): """Create a GromacsStructure objects from a grofile.""" gstruct = GromacsStructure(name=grofile, header="title" ) gstruct.load(grofile) return gstruct