Пример #1
0
def mag_superimpose(a1, a2):

    sup = SVDSuperimposer()

    a1 = np.asarray(a1)
    a2 = np.asarray(a2)
    mags = [norm(v) for v in a2]

    if len(a1) <= 7:

        min_dist = (1.0E6, 'foo', 'bar')

        for l in itertools.permutations(a1):

            p = np.array([m * v / norm(v) for m, v in zip(mags, l)])
            sup.set(a2, p)
            sup.run()
            rot, tran = sup.get_rotran()
            rms = sup.get_rms()

            if rms < min_dist[0]:
                min_dist = (rms, rot, tran)

    else:

        a1, a2 = match_vectors(a1, a2, 6)
        mags = [norm(v) for v in a2]

        min_dist = (1.0E6, 'foo', 'bar')

        for l in itertools.permutations(a1):

            p = np.array([m * v / norm(v) for m, v in zip(mags, l)])
            sup.set(a2, p)
            sup.run()
            rot, tran = sup.get_rotran()
            rms = sup.get_rms()

            if rms < min_dist[0]:
                min_dist = (rms, rot, tran)

    return min_dist
Пример #2
0
def superimpose(a1,a2):
	
	sup = SVDSuperimposer()

	a1 = np.asarray(a1)
	a2 = np.asarray(a2)

	if len(a1) <= 7:

		min_dist = (1.0E6, 'foo', 'bar')
		
		for l in itertools.permutations(a1):
			p = np.asarray(l)
			sup.set(a2,p)
			sup.run()
			rot,tran = sup.get_rotran()
			aff_a1 = np.dot(l,rot) + tran
			rms = sup.get_rms()

			if rms < min_dist[0]:
				min_dist = (rms,rot,tran)
	
	else:

		a1,a2 = match_vectors(a1,a2,6)
		
		min_dist = (1.0E6, 'foo', 'bar')
		
		for l in itertools.permutations(a1):
			p = np.asarray(l)
			sup.set(a2,p)
			sup.run()
			rot,tran = sup.get_rotran()
			aff_a1 = np.dot(l,rot) + tran
			rms = sup.get_rms()
		
			if rms < min_dist[0]:
				min_dist = (rms,rot,tran)

	return min_dist
Пример #3
0
           [52.71, -1.18, 49.38]], 'f')

sup = SVDSuperimposer()

# set the coords
# y will be rotated and translated on x
sup.set(x, y)

# do the lsq fit
sup.run()

# get the rmsd
rms = sup.get_rms()

# get rotation (right multiplying!) and the translation
rot, tran = sup.get_rotran()

# rotate y on x manually
y_on_x1 = dot(y, rot) + tran

# same thing
y_on_x2 = sup.get_transformed()


def simple_matrix_print(matrix):
    """Simple string to display a floating point matrix

    This should give the same output on multiple systems.  This is
    needed because a simple "print matrix" uses scientific notation
    which varies between platforms.
Пример #4
0
         [52.71, -1.18, 49.38]], 'f')

sup=SVDSuperimposer()

# set the coords
# y will be rotated and translated on x
sup.set(x, y)

# do the lsq fit
sup.run()

# get the rmsd
rms=sup.get_rms()

# get rotation (right multiplying!) and the translation
rot, tran=sup.get_rotran()

# rotate y on x manually
y_on_x1=dot(y, rot)+tran

# same thing
y_on_x2=sup.get_transformed()

def simple_matrix_print(matrix):
    """Simple string to display a floating point matrix

    This should give the same output on multiple systems.  This is
    needed because a simple "print matrix" uses scientific notation
    which varies between platforms.

    Only 4 decimal places are used to avoid false test failures due