Example #1
0
#
impropertypes = {}
for it in top.impropertypes:
    name = "{0}-{1}-{2}-{3}-{4}".format(it.atype1, it.atype2, it.atype3,
                                        it.atype4, it.gromacs['func'])
    if not name in impropertypes: impropertypes[name] = []
    impropertypes[name].append(it)
print("Build impropertypes dictionary with {0} entries".format(
    len(impropertypes)))

top.angletypes = scale_angles(mol, angletypes)
top.dihedraltypes = scale_dihedrals(mol, dihedraltypes)
top.impropertypes = scale_impropers(mol, impropertypes)

top.nonbond_params = []
top.cmaptypes = []
atomtypes = {at.atype for at in top.atomtypes}

pairtypes = [
    pt for pt in top.pairtypes
    if (pt.atype1 in atomtypes) and (pt.atype2 in atomtypes)
]
top.pairtypes = pairtypes

# Remove non-default moleculetypes
for k in top.dict_molname_mol.keys():
    if k in [molname]: continue
    del top.dict_molname_mol[k]

top.write(args.output)
        dihedraltypes[name].append(dt)
print("Build dihedraltypes dictionary with {0} entries".format(len(dihedraltypes)))

#
# Build improper dictionary
#
impropertypes = {}
for it in top.impropertypes:
        name = "{0}-{1}-{2}-{3}-{4}".format(it.atype1, it.atype2, it.atype3, it.atype4, it.gromacs['func'])
        if not name in impropertypes: impropertypes[name] = []
        impropertypes[name].append(it)
print("Build impropertypes dictionary with {0} entries".format(len(impropertypes)))

top.angletypes = scale_angles(mol, angletypes)
top.dihedraltypes = scale_dihedrals(mol, dihedraltypes)
top.impropertypes = scale_impropers(mol, impropertypes)

top.nonbond_params = []
top.cmaptypes = []
atomtypes = {at.atype for at in top.atomtypes}

pairtypes = [pt for pt in top.pairtypes if (pt.atype1 in atomtypes) and (pt.atype2 in atomtypes)]
top.pairtypes = pairtypes

# Remove non-default moleculetypes
for k in top.dict_molname_mol.keys():
        if k in [molname]: continue
        del top.dict_molname_mol[k]

top.write(args.output)