Example #1
0
def _make_waterdata(atoms, box, ligands, infilename):
    """
    Make a datafile for a CG box with water molecules
    """
    outdata = lammps.Datafile()
    atoms = atoms[::3]  # Map to the oxygen

    for i, aaatom in enumerate(atoms, 1):
        cgatom = lammps.Atom()
        cgatom.idx = i
        cgatom.atype = 1
        cgatom.set_xyz(aaatom.xyz)  # This is the only thing used from all-atom
        cgatom.charge = 0
        cgatom.set_mu(geo.sphere_rand(0.541))  # Random dipole direction
        cgatom.diameter = 3.0
        cgatom.density = 2.7
        cgatom.kind = "cg"
        outdata.atoms.append(cgatom)

    outdata.atomtypes = [None] * 6
    outdata.bondtypes = [None] * 5
    outdata.angletypes = [None] * 5

    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-waterbox" % ligand)
Example #2
0
def _make_cyclohexanedata(atoms, box, ligands, infilename):
    """
    Make a datafile for a CG box with cyclohexane molecules
    """

    outdata = lammps.Datafile()
    c1_atoms = atoms[::18]  # Map to first carbon
    c2_atoms = atoms[1::18]  # Map to second carbon
    c3_atoms = atoms[3::18]  # Map to fourth carbon

    for i, (c1atom, c2atom,
            c3atom) in enumerate(zip(c1_atoms, c2_atoms, c3_atoms)):
        aatoms = [c1atom, c2atom, c3atom]
        for j in range(3):
            cgatom = lammps.Atom()
            cgatom.idx = i * 3 + j + 1
            cgatom.atype = 6
            cgatom.set_xyz(aatoms[j].xyz)
            cgatom.charge = 0
            cgatom.set_mu([0, 0, 0])
            cgatom.diameter = 4.5
            cgatom.density = 0.9
            cgatom.kind = "cg"
            cgatom.molecule = i + 1
            outdata.atoms.append(cgatom)
        outdata.bonds.append(
            lammps.Connectivity(
                "%d 5 %d %d" % (len(outdata.bonds) + 1, i * 3 + 1, i * 3 + 2)))
        outdata.bonds.append(
            lammps.Connectivity(
                "%d 5 %d %d" % (len(outdata.bonds) + 1, i * 3 + 1, i * 3 + 3)))
        outdata.bonds.append(
            lammps.Connectivity(
                "%d 5 %d %d" % (len(outdata.bonds) + 1, i * 3 + 3, i * 3 + 2)))

    outdata.atomtypes = [None] * 6
    outdata.bondtypes = [None] * 5
    outdata.angletypes = [None] * 5

    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)
Example #3
0
                        default="lj/charmm/coul/long")
    parser.add_argument('--dihfunc',
                        help="the dihedral function for the solute")
    parser.add_argument('--dihfunc_box',
                        help="the dihedral function for the box")
    parser.add_argument('--pairmix',
                        nargs="+",
                        help="pair functions to use when mixing pairs")
    parser.add_argument('--noff',
                        action="store_true",
                        help="turns off the creating of force field file",
                        default=False)
    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:
Example #4
0
    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
        for residue in converter.residues:
            if residue.name == res2:
                coord = residue.generate_cg(res, moli + 1, data, mapping=False)
                all_coords.extend(coord)
                found = True
Example #5
0
    outdata.angletypes = [None] * 5

    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:
Example #6
0
    parser.add_argument('data', help="the lammps data file")
    parser.add_argument('-o', '--out', help="the output file")
    parser.add_argument('-a', '--atoms', nargs="+", help="the atoms to change")
    parser.add_argument('-t', '--type', type=int, help="the new atom type")
    parser.add_argument('--increase',
                        help="increase number of atom types",
                        action='store_true',
                        default=False)
    parser.add_argument('--decrease',
                        help="decrease number of atom types",
                        action='store_true',
                        default=False)
    args = parser.parse_args()

    # Read datafile and parse into molecules
    datafile = lammps.Datafile(filename=args.data)
    mols = lammps.parse_molecules(datafile)

    # Loop over all atom selections and modify atom type
    for atom in args.atoms:
        molrange, atomi = atom.split(":")
        atomi = int(atomi)
        first, last = map(int, molrange.split("-"))
        print "Changing: ", first, last, atomi
        for m in range(first, last + 1):
            mols[m][atomi - 1].atype = args.type

    # Increase or decrease the atomtype list
    if args.increase:
        datafile.atomtypes.append(None)
    elif args.decrease:
Example #7
0
"""

import argparse

from sgenlib import lammps

if __name__ == '__main__':

    parser = argparse.ArgumentParser(description="Truncate a LAMMPS datafile")
    parser.add_argument('file', help="the data file.")
    parser.add_argument('-m',
                        '--mol',
                        type=int,
                        help="the molecule id of the QM system")
    parser.add_argument('-o', '--out', help="the output file")
    args = parser.parse_args()

    if args.file is None:
        print "No input file specified. Exiting!"
        quit()

    datafile = lammps.Datafile(args.file)
    for atom in datafile.atoms:
        if atom.molecule == args.mol:
            atom.q = 0.0

    if args.out is None:
        datafile.write(args.file)
    else:
        datafile.write(args.out)
Example #8
0
import numpy as np

from sgenlib import lammps
from sgenlib import pdb
from sgenlib import pbc

if __name__ == '__main__':

    # Command-line input
    parser = argparse.ArgumentParser(
        description="Making molecules whole in a LAMMPS datafile")
    parser.add_argument('file', help="the lammps data file")
    parser.add_argument('-o', '--out', help="the output file")
    args = parser.parse_args()

    data = lammps.Datafile(filename=args.file)

    # Create a box with the length of the datafile box
    box = np.zeros(3)
    box[0] = data.box[3] - data.box[0]
    box[1] = data.box[4] - data.box[1]
    box[2] = data.box[5] - data.box[2]

    mols = lammps.parse_molecules(data)
    for atom in data.atoms:
        if atom.ix != None:
            atom.ix = None
            atom.iy = None
            atom.iz = None

    for mol in mols:
Example #9
0
}

harmonic {
  colvars solute
  forceConstant %.3f
  centers %.1f
  outputCenters on
} 

"""

  
  # Find the first and last atom of the membrane and solute
  mfirst = 10000
  mlast  = -10000
  sfirst = 10000
  slast  = -10000
  for atom in lammps.Datafile(args.file).atoms :
    if atom.molecule >= args.membrane[0] and atom.molecule <= args.membrane[1] :
      mfirst = min(atom.idx,mfirst)
      mlast = max(atom.idx,mlast)
    elif atom.molecule == args.solute :
      sfirst = min(atom.idx,sfirst)
      slast = max(atom.idx,slast)

  # Create an output file for each depth
  for z in args.zdepth :
    with open("%sz%0.f"%(args.out,z),"w") as f:
      f.write(strtempl%(sfirst,slast,mfirst,mlast,args.weight,z))
          
Example #10
0
                        '--watrad',
                        type=float,
                        help="the water radius to keep atomistic")
    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)

    # Create a Datafile and PDBFile
    pdbfile = pdb.PDBFile(args.file)  # Input PDB
    takeres = [True for res in pdbfile.residues]
    data = lammps.Datafile()
    pdbout = pdb.PDBFile()  # Output PDB

    # Load the force field file
    include = lammps.Includefile(args.include)

    if args.atomistic:
        # At the moment, multiple AA solutes are not supported with atomistic water radius
        if len(args.atomistic) > 1:
            args.watrad = None
        natomtypes = _ntypes(include.masses)
        contypes = [
            _ntypes(include.bondparams),
            _ntypes(include.angleparams),
            _ntypes(include.dihedralparams)
        ]