[frames] | no frames]

# Class SVDSuperimposer

source code

```object --+
|
SVDSuperimposer
```

Class to run SVD alignment.

SVDSuperimposer finds the best rotation and translation to put two point sets on top of each other (minimizing the RMSD). This is eg. useful to superimpose crystal structures.

SVD stands for Singular Value Decomposition, which is used to calculate the superposition.

Reference:

Matrix computations, 2nd ed. Golub, G. & Van Loan, CF., The Johns Hopkins University Press, Baltimore, 1989

```>>> from Bio.SVDSuperimposer import SVDSuperimposer
>>> from numpy import array, dot, set_printoptions
>>>
>>> x = array([[51.65, -1.90, 50.07],
...      [50.40, -1.23, 50.65],
...      [50.68, -0.04, 51.54],
...      [50.22, -0.02, 52.85]], 'f')
>>>
>>> y = array([[51.30, -2.99, 46.54],
...      [51.09, -1.88, 47.58],
...      [52.36, -1.20, 48.03],
...      [52.71, -1.18, 49.38]], 'f')```

start

`>>> 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

`>>> y_on_x1 = dot(y, rot) + tran`

same thing

`>>> y_on_x2 = sup.get_transformed()`
```>>> set_printoptions(precision=2)
>>> print(y_on_x1)
[[  5.17e+01  -1.90e+00   5.01e+01]
[  5.04e+01  -1.23e+00   5.06e+01]
[  5.07e+01  -4.16e-02   5.15e+01]
[  5.02e+01  -1.94e-02   5.29e+01]]
>>> print(y_on_x2)
[[  5.17e+01  -1.90e+00   5.01e+01]
[  5.04e+01  -1.23e+00   5.06e+01]
[  5.07e+01  -4.16e-02   5.15e+01]
[  5.02e+01  -1.94e-02   5.29e+01]]
>>> print("%.2f" % rms)
0.00```
 Instance Methods

 __init__(self) Initialize the class. source code

 _clear(self) source code

 _rms(self, coords1, coords2) Return rms deviations between coords1 and coords2 (PRIVATE). source code

 set(self, reference_coords, coords) Set the coordinates to be superimposed. source code

 run(self) Superimpose the coordinate sets. source code

 get_transformed(self) Get the transformed coordinate set. source code

 get_rotran(self) Right multiplying rotation matrix and translation. source code

 get_init_rms(self) Root mean square deviation of untransformed coordinates. source code

 get_rms(self) Root mean square deviation of superimposed coordinates. source code

Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

 Properties

Inherited from `object`: `__class__`

 Method Details

### __init__(self)(Constructor)

source code
Initialize the class.
Overrides: object.__init__

### set(self, reference_coords, coords)

source code

Set the coordinates to be superimposed.

coords will be put on top of reference_coords.

• reference_coords: an NxDIM array
• coords: an NxDIM array

DIM is the dimension of the points, N is the number of points to be superimposed.

 Generated by Epydoc 3.0.1 on Fri Jun 22 16:36:02 2018 http://epydoc.sourceforge.net