Example #1
0
def gettorsbytype(mol, types):
    types = [molparam.torsion_uni(type_) for type_ in types]

    result = {}
    for typ in types:
        result[typ] = []

    mol.confirmconnect()
    tors = relalist.genD(relalist.genconns(mol.connect))
    for tor in tors:
        typ = molparam.torsion_uni(gettortype(mol, tor))
        if typ in types:
            result[typ].append(tor)
    return result
Example #2
0
def readtorsionprm(prmfname, i, j, k, l):
    toridx = molparam.torsion_uni((i, j, k, l))
    ifile = file(prmfname)
    for line in ifile:
        words = line.split()
        if (
            len(words) in [14, 17, 20, 23]
            and words[0] == "torsion"
            and molparam.torsion_uni([int(x) for x in words[1:5]]) == toridx
        ):
            fold = (len(words) - 5) // 3
            result = []
            for idx in range(fold):
                data = words[5 + 3 * idx : 8 + 3 * idx]
                if idx % 2 == 0:
                    assert float(data[1]) == 0.0
                else:
                    assert float(data[1]) == 180.0
                assert int(data[2]) == idx + 1
                result.append(float(data[0]))
            ifile.close()
            return result
    return None
Example #3
0
def readidx(idxfname):
    idxs = []
    folds = []
    for line in file(idxfname):
        words = line.split()
        if not words:
            continue
        assert 4 <= len(words) <= 5
        idx = tuple([int(x) for x in words[:4]])
        if len(words) == 5:
            fold = int(words[-1])
        else:
            fold = 3
        idxs.append(molparam.torsion_uni(idx))
        folds.append(fold)
    return (idxs, folds)
Example #4
0
def getmoldata(molfname):
    mol = read.readxyz(file(molfname))
    types = tools.gettypes(mol)

    result = {}
    result['atomtypes'] = set(types)
    subtypes = list(result['atomtypes'])
    typepairs = []
    for i, type_1 in enumerate(subtypes):
        for type_2 in subtypes[i:]:
            typepairs.append(molparam.bond_uni([type_1, type_2]))
    result['typepairs'] = set(typepairs)

    rela = relalist.Relalist(mol)
    result['bondtypes'] = set([molparam.bond_uni(gettype(bond, types))
                               for bond in rela.bonds])
    result['angletypes'] = set([molparam.angle_uni(gettype(angle, types))
                                for angle in rela.angles])
    result['torsiontypes'] = set([molparam.torsion_uni(gettype(torsion, types))
                                  for torsion in rela.torsions])

    return result
Example #5
0
def checktorsiontypes(words, moldata):
    key = molparam.torsion_uni([int(words[1]), int(words[2]),
                                int(words[3]), int(words[4])])
    if key in moldata['torsiontypes']:
        return True
    return False