args = parser.parse_args() # Read solute data file solute_data = lammps.Datafile(filename=args.solute) if args.pdb is not None: pdbfile = pdb.PDBFile(filename=args.pdb) for datom, patom in zip(solute_data.atoms, pdbfile.atoms): datom.set_xyz(patom.xyz) # Read box data file and force field box_data = lammps.Datafile(filename=args.box) for atom in box_data.atoms: atom.ix = None atom.iy = None atom.iz = None box_ff = lammps.Includefile(filename=args.ff) if args.dihfunc_box is not None: for dih in box_ff.dihedralparams: if dih.func == "": dih.func = args.dihfunc_box ELBA_FUNC = "lj/sf/dipole/sf" for pair in box_ff.pair_coeff: if pair.func == "": pair.func = ELBA_FUNC if not args.norespa and pair.hybrid == -1 and pair.func == ELBA_FUNC: pair.hybrid = 2 lj_hybrid = -1 if not args.norespa: lj_hybrid = 1 lj_func = {ELBA_FUNC: ELBA_FUNC}
outdata.box = np.array(box, copy=True) outdata.title = "Converted to CG with convert_aa.py from %s" % os.path.basename( infilename) outdata.write("data.%s-chexanebox" % ligand) if __name__ == '__main__': filename = sys.argv[1] filehead = os.path.splitext(os.path.basename(filename))[0] solvent = filehead.split("-")[0] ligand = filehead.split("_")[1] aadata = lammps.Datafile(filename) aapairparams = lammps.Includefile(os.path.splitext(filename)[0] + ".input") solutedata = lammps.Datafile() solatypes = [] solidx = [] solutemasses = [] solventatoms = [] # Split up solute and solvent atoms for atom in aadata.atoms: if atom.molecule == 1: solatypes.append(atom.atype) solidx.append(atom.idx) solutedata.atoms.append(atom) solutemasses.append(aadata.atomtypes[atom.atype - 1].mass) else: solventatoms.append(atom)
parser.add_argument('-k', '--kind', help="the kind of particles", default="cg") #parser.add_argument('-p','--pairfunc',help="the pair function for the AA",default="lj/charmm/coul/long") args = parser.parse_args() # Load a converter converter = lammps.Aa2Cg() if args.converter is None: converter.read(lammps.get_filename("aa2cg.dat")) # The default else: converter.read(args.converter) # Load the force field file include = lammps.Includefile(args.include) # Create a Datafile and PDBFile pdbfile = pdb.PDBFile(args.file) # Input PDB takeres = [True for res in pdbfile.residues] data = lammps.Datafile() # Convert residues all_coords = [] nwat = 0 moli = 0 for i, (res, takethis) in enumerate(zip(pdbfile.residues, takeres)): if not takethis: continue moli += 1 res2 = res.resname.strip().lower() found = False
help="the scaling factors", default=[]) parser.add_argument( '-p', '--param', choices=["e", "s", "c"], nargs="+", help="the parameter to scale, either e(psilon), s(igma), or c(oulomb)", default=[]) args = parser.parse_args() if args.file is None: print "No input file specified. Exiting!" quit() infile = lammps.Includefile(filename=args.file) # Find all mixed pairs mixed_pairs = [] for pair in infile.pair_coeff: if (pair.comment.find("AA-CG mixed") > -1 or pair.comment.find("Mixed using Lorentz-Berthelot rules") > -1): mixed_pairs.append(pair) lj_same = infile.lj_same_dict() # Loop over all the bead specification and change the given parameter for beadspec, fac, param in zip(args.beads, args.scale, args.param): beads = [int(b) for b in beadspec.strip().split(",")] for pair in mixed_pairs: if pair.iatom in beads: if param.lower()[0] == "e":
Example: lmp_duplicate_atype.py forcefield.elba """ import argparse from sgenlib import lammps if __name__ == '__main__' : # Command-line input parser = argparse.ArgumentParser(description="Duplicating atom type in Lammps include file") parser.add_argument('file',help="the lammps include file") parser.add_argument('-o','--out',help="the output file") parser.add_argument('-t','--type',type=int,help="the type to duplicate") args = parser.parse_args() ifile = lammps.Includefile(args.file) # Duplicate masses and pair coefficients newmass,newpairs = ifile.duplicate_type(args.type) newmass.comment = "# duplicate of %d"%(args.type) ifile.masses.append(newmass) ifile.pair_coeff.extend(newpairs) ifile.pair_coeff.sort(cmp=lammps.comp_pair) if args.out is None : args.out = args.file+"_mod" ifile.write(args.out)
""" import argparse from sgenlib import lammps if __name__ == '__main__': # Command-line input parser = argparse.ArgumentParser( description="Write out atom types of heavy atoms") parser.add_argument('file', help="the lammps include file") parser.add_argument('-x', '--exclude', type=float, nargs="+", help="exclude these", default=[40.0, 90.0, 62.0, 42.0]) parser.add_argument('-m', '--mass', type=float, help="the mass of hydrogen", default=1.00800) args = parser.parse_args() atypes = [] for m in lammps.Includefile(args.file).masses: if not (m.mass in args.exclude or m.mass == args.mass): atypes.append(m.idx) print " ".join(["%d" % i for i in atypes])