Пример #1
0
def HBpairs(mols,com,thres,box):
    pairs = []
    for i,j in pairlist.pairlist(com,thres+1.1,box):
        dmin = 999999.
        dirmin  = 0
        mins = -1
        for si in mols[i]:
            if not si[0][0] in ("O","H"):
                next
            for sj in mols[j]:
                if not sj[0][0] in ("O","H"):
                    next
                dir = 0
                if si[0][0] == "O" and sj[0][0] == "H":
                    dir = -1
                if si[0][0] == "H" and sj[0][0] == "O":
                    dir = +1
                if dir != 0:
                    d = si[1]-sj[1]
                    d = wrap(d,box)
                    d = numpy.linalg.norm(d)
                    if d < dmin:
                        dmin = d
                        dirmin = dir
        if dmin < thres:
            if dirmin > 0:
                pairs.append((i,j))
            else:
                pairs.append((j,i))
    return pairs
Пример #2
0
                line = sys.stdin.readline()
                r = map(float, line.split())
                if tag == "@NX3A":
                    #xyz+euler angles
                    euler = numpy.array(r[3:6])
                    q = rotation_numpy.euler2quat(euler)
                else:
                    #xyz + quaternion
                    q = r[3:7]
                #store the rotation matrix and coordinate in arrays.
                rotmats.append(rotation_numpy.quat2rotmat(q))
                coms.append(numpy.array(r[0:3]))

#Fast pairlist maker
rc = 3.0
pairs = pairlist.pairlist(coms,rc,box)
# lookup HB pairs
print "@BMRK"
print nmol
for i,j in pairs:
    d = wrap( coms[j] - coms[i], box )
    ih1 = numpy.dot(rotmats[i], H1)
    ih2 = numpy.dot(rotmats[i], H2)
    di1 = numpy.linalg.norm( d - ih1 )
    di2 = numpy.linalg.norm( d - ih2 )
    di = min(di1,di2)
    jh1 = numpy.dot(rotmats[j], H1)
    jh2 = numpy.dot(rotmats[j], H2)
    dj1 = numpy.linalg.norm( d + jh1 )
    dj2 = numpy.linalg.norm( d + jh2 )
    dj = min(dj1,dj2)