예제 #1
0
파일: aa2cg.py 프로젝트: syn2018/Scripts
def _generate_aa_wat(residue, molidx, sysdata, include):

    n = len(sysdata.atoms)
    charges = [-0.834, 0.417, 0.417]
    mass = [9.9514, 3.024, 3.024]
    nt = len(include.masses)
    types = [nt - 1, nt, nt]
    for i, ratom in enumerate(residue.atoms):
        atom = lammps.Atom()
        atom.idx = n + i + 1
        atom.set_xyz(ratom.xyz)
        atom.molecule = molidx
        atom.q = charges[i]
        atom.atype = types[i]
        atom.comment = "# water"
        atom.diameter = 0.0
        atom.density = mass[i]
        atom.set_mu([0.0, 0.0, 0.0])
        sysdata.atoms.append(atom)

    nb = len(include.bondparams)
    b = lammps.Connectivity(record="%d %d %d %d" %
                            (len(sysdata.bonds) + 1, nb, n + 1, n + 2))
    b.comment = "# O-H bond"
    sysdata.bonds.append(b)
    b = lammps.Connectivity(record="%d %d %d %d" %
                            (len(sysdata.bonds) + 1, nb, n + 1, n + 3))
    b.comment = "# O-H bond"
    sysdata.bonds.append(b)

    na = len(include.angleparams)
    a = lammps.Connectivity(record="%d %d %d %d %d" %
                            (len(sysdata.angles) + 1, na, n + 2, n + 1, n + 3))
    a.comment = "# H-O-H angle"
    sysdata.angles.append(a)
예제 #2
0
파일: aa2cg.py 프로젝트: syn2018/Scripts
def _generate_aa_residue(residue, molidx, resdata, sysdata):
    """
    Generates an aa residue by copying most of the structure
    from a datafile template, but the coordinates from a PDB residue
    """
    n = len(sysdata.atoms)
    for i, (ratom, datom) in enumerate(zip(residue.atoms, resdata.atoms)):
        atom = copy.deepcopy(datom)
        atom.idx = atom.idx + n
        atom.set_xyz(ratom.xyz)
        atom.molecule = molidx
        sysdata.atoms.append(atom)

    for bond in resdata.bonds:
        b = lammps.Connectivity(
            record="%d %d %d %d" %
            (len(sysdata.bonds) + 1, bond[0], bond[1] + n, bond[2] + n))
        sysdata.bonds.append(b)

    for angle in resdata.angles:
        a = lammps.Connectivity(record="%d %d %d %d %d" %
                                (len(sysdata.angles) + 1, angle[0],
                                 angle[1] + n, angle[2] + n, angle[3] + n))
        sysdata.angles.append(a)

    for dihedral in resdata.dihedrals:
        a = lammps.Connectivity(
            record="%d %d %d %d %d %d" %
            (len(sysdata.dihedrals) + 1, dihedral[0], dihedral[1] + n,
             dihedral[2] + n, dihedral[3] + n, dihedral[4] + n))
        sysdata.dihedrals.append(a)
예제 #3
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)