Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.SVDSuperimposer.SVDSuperimposer.SVDSuperimposer Class Reference

List of all members.

Public Member Functions

def __init__
def set
def run
def get_transformed
def get_rotran
def get_init_rms
def get_rms

Public Attributes

 reference_coords
 coords
 transformed_coords
 rot
 tran
 rms
 init_rms
 n

Private Member Functions

def _clear
def _rms

Detailed Description

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

Definition at line 9 of file SVDSuperimposer.py.


Constructor & Destructor Documentation

Definition at line 23 of file SVDSuperimposer.py.

00023 
00024     def __init__(self):
00025         self._clear()

Here is the call graph for this function:


Member Function Documentation

Definition at line 28 of file SVDSuperimposer.py.

00028 
00029     def _clear(self):
00030         self.reference_coords=None
00031         self.coords=None
00032         self.transformed_coords=None
00033         self.rot=None
00034         self.tran=None
00035         self.rms=None
00036         self.init_rms=None

Here is the caller graph for this function:

def Bio.SVDSuperimposer.SVDSuperimposer.SVDSuperimposer._rms (   self,
  coords1,
  coords2 
) [private]

Definition at line 37 of file SVDSuperimposer.py.

00037 
00038     def _rms(self, coords1, coords2):
00039         "Return rms deviations between coords1 and coords2."
00040         diff=coords1-coords2
00041         l=coords1.shape[0]
00042         return sqrt(sum(sum(diff*diff))/l)

Here is the caller graph for this function:

Definition at line 104 of file SVDSuperimposer.py.

00104 
00105     def get_init_rms(self):
00106         "Root mean square deviation of untransformed coordinates."
00107         if self.coords is None:
00108             raise Exception("No coordinates set yet.")
00109         if self.init_rms is None:
00110             self.init_rms=self._rms(self.coords, self.reference_coords)
00111         return self.init_rms

Here is the call graph for this function:

Definition at line 112 of file SVDSuperimposer.py.

00112 
00113     def get_rms(self):
00114         "Root mean square deviation of superimposed coordinates."
00115         if self.rms is None:
00116             transformed_coords=self.get_transformed()
00117             self.rms=self._rms(transformed_coords, self.reference_coords)
00118         return self.rms
00119 

Here is the call graph for this function:

Definition at line 98 of file SVDSuperimposer.py.

00098 
00099     def get_rotran(self):
00100         "Right multiplying rotation matrix and translation."
00101         if self.rot is None:
00102             raise Exception("Nothing superimposed yet.")
00103         return self.rot, self.tran

Definition at line 88 of file SVDSuperimposer.py.

00088 
00089     def get_transformed(self):
00090         "Get the transformed coordinate set."
00091         if self.coords is None or self.reference_coords is None:
00092             raise Exception("No coordinates set.")
00093         if self.rot is None:
00094             raise Exception("Nothing superimposed yet.")
00095         if self.transformed_coords is None:
00096             self.transformed_coords=dot(self.coords, self.rot)+self.tran
00097         return self.transformed_coords

Here is the caller graph for this function:

Definition at line 67 of file SVDSuperimposer.py.

00067 
00068     def run(self):
00069         "Superimpose the coordinate sets."
00070         if self.coords is None or self.reference_coords is None:
00071             raise Exception("No coordinates set.")
00072         coords=self.coords
00073         reference_coords=self.reference_coords
00074         # center on centroid
00075         av1=sum(coords)/self.n  
00076         av2=sum(reference_coords)/self.n    
00077         coords=coords-av1
00078         reference_coords=reference_coords-av2
00079         # correlation matrix
00080         a=dot(transpose(coords), reference_coords)
00081         u, d, vt=svd(a)
00082         self.rot=transpose(dot(transpose(vt), transpose(u)))
00083         # check if we have found a reflection
00084         if det(self.rot)<0:
00085             vt[2]=-vt[2]
00086             self.rot=transpose(dot(transpose(vt), transpose(u)))
00087         self.tran=av2-dot(av1, self.rot)

Here is the call graph for this function:

def Bio.SVDSuperimposer.SVDSuperimposer.SVDSuperimposer.set (   self,
  reference_coords,
  coords 
)
Set the coordinates to be superimposed.
coords will be put on top of reference_coords.

o reference_coords: an NxDIM array
o coords: an NxDIM array

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

Definition at line 45 of file SVDSuperimposer.py.

00045 
00046     def set(self, reference_coords, coords):
00047         """
00048         Set the coordinates to be superimposed.
00049         coords will be put on top of reference_coords.
00050 
00051         o reference_coords: an NxDIM array
00052         o coords: an NxDIM array
00053 
00054         DIM is the dimension of the points, N is the number
00055         of points to be superimposed.
00056         """
00057         # clear everything from previous runs
00058         self._clear()
00059         # store cordinates
00060         self.reference_coords=reference_coords
00061         self.coords=coords
00062         n=reference_coords.shape
00063         m=coords.shape
00064         if n!=m or not(n[1]==m[1]==3):
00065             raise Exception("Coordinate number/dimension mismatch.")
00066         self.n=n[0]

Here is the call graph for this function:


Member Data Documentation

Definition at line 30 of file SVDSuperimposer.py.

Definition at line 35 of file SVDSuperimposer.py.

Definition at line 65 of file SVDSuperimposer.py.

Definition at line 29 of file SVDSuperimposer.py.

Definition at line 34 of file SVDSuperimposer.py.

Definition at line 32 of file SVDSuperimposer.py.

Definition at line 33 of file SVDSuperimposer.py.

Definition at line 31 of file SVDSuperimposer.py.


The documentation for this class was generated from the following file: