meshi.util.overlap
Class Overlap

java.lang.Object
  extended by meshi.util.overlap.Overlap

public class Overlap
extends java.lang.Object

Kabsch algorithm for optimal superposition. The following class implements the procedure for obtaining
the best rotation to relate two sets of vectors as described
in papers:
1. "A solution for the best rotation to relate two sets of vectors". By Wolfgang Kabsch, Acta Cryst. (1976) A 32: 922-923
2. "A discussion of the solution for the best rotation to relate two sets
of vectors". By Wolfgang Kabsch, Acta Cryst. (1978). A34, 827-828 .


Field Summary
private static double[][] bvector
           
private static java.lang.String comment
           
private static java.lang.String comment2
           
private static double[][] coor
           
private static double[][] coor2
           
private static double[] eigenv
           
private static double[][] eigenVectors
           
private static double eps
           
private static double[][] help
           
private static int npt
           
private static double rms
           
private static double[][] temp
           
private static double[][] Umatrix
           
 
Constructor Summary
Overlap(double[][] co, double[][] co2, int n, java.lang.String com, java.lang.String com2)
           
 
Method Summary
static double[][] calcBvectors()
          Calculating the B vectors (equation 12 at Kabsch-1976)
static double[] calcCharPol(double[][] mat)
          this function will calculate the characteristic polynom after caululating the determinant manually
static void calculateRms()
           
static void checkEigenval(double[] eigenval)
          We now have to find the corresponding eigenvectors so we check if all eigenvalues are different or not.
static void checkEigenVec()
          In order to get the proper rotation matrix (kabsch 1978) when a1,a2,a3 are out eigenvectors we make sure that a1*a2 = a3
static double[][] copyMat(double[][] mat)
           
static double[][] createP()
          Building a P matrix according to equation 10
which is R*Rt(1976)
static double[][] createR()
          Building the R matrix according to equation 7
at the Kabsch paper (1976)
static void createUmatrix(double[][] bVectors)
          Creating the U matrix, the rotation matrix.
static double[] findEigenval(double[] charpol)
          In order to find the 3 eigenValues of P, which is
a positive definite matrix, we are solving a cubic equation
static double[][] findEigenvec1(double[] eigenval)
          Incase all 3 eigenvalues are different (most cases) in order to derive the eigenvectors we use the Gauss elimination procedure with scaled pivoting
static double[][] findEigenvec2(double[] eigenval)
          FIND EIGEN VEC 2
static double findMax(double a, double b)
           
static double findMaxAbs(double a, double b)
          some help functions
static double findMin(double a, double b)
           
static void gravityCenter()
          Uniting the gravity center of both proteins to (0,0,0)
private static void initiateFields(double[][] co, double[][] co2, int n, java.lang.String com, java.lang.String com2)
          A function that initializes all the class fields so that
all the other functions can use them
 double rms()
           
static double rmsPartial(double[][] co, double[][] co2, int[] partList)
          Finds the RMS according to a small subset of the two proteins.
static double rmsPartialAltRMS(double[][] co, double[][] co2, int[] partList)
          This is exactly the same as 'rmsPartial' except that the rms is calculated on the subset only.
 double[][] rotationMatrix()
           
private static double[] sortEigenval(double[] eigenval)
          this function sorts the eigenvalues in descending order, according to Kabsch(1978) so we obtain the proper rotation matrix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

coor

private static double[][] coor

coor2

private static double[][] coor2

temp

private static double[][] temp

comment

private static java.lang.String comment

comment2

private static java.lang.String comment2

npt

private static int npt

help

private static double[][] help

eigenv

private static double[] eigenv

eigenVectors

private static double[][] eigenVectors

bvector

private static double[][] bvector

Umatrix

private static double[][] Umatrix

eps

private static double eps

rms

private static double rms
Constructor Detail

Overlap

public Overlap(double[][] co,
               double[][] co2,
               int n,
               java.lang.String com,
               java.lang.String com2)
Method Detail

rotationMatrix

public double[][] rotationMatrix()

rms

public double rms()

initiateFields

private static void initiateFields(double[][] co,
                                   double[][] co2,
                                   int n,
                                   java.lang.String com,
                                   java.lang.String com2)
A function that initializes all the class fields so that
all the other functions can use them


gravityCenter

public static void gravityCenter()
Uniting the gravity center of both proteins to (0,0,0)


createR

public static double[][] createR()
Building the R matrix according to equation 7
at the Kabsch paper (1976)


createP

public static double[][] createP()
Building a P matrix according to equation 10
which is R*Rt(1976)


calcCharPol

public static double[] calcCharPol(double[][] mat)
this function will calculate the characteristic polynom after caululating the determinant manually


findEigenval

public static double[] findEigenval(double[] charpol)
In order to find the 3 eigenValues of P, which is
a positive definite matrix, we are solving a cubic equation


sortEigenval

private static double[] sortEigenval(double[] eigenval)
this function sorts the eigenvalues in descending order, according to Kabsch(1978) so we obtain the proper rotation matrix


checkEigenval

public static void checkEigenval(double[] eigenval)
We now have to find the corresponding eigenvectors so we check if all eigenvalues are different or not. Then sending the eigenvalues to a function that calculates the vectors


findEigenvec1

public static double[][] findEigenvec1(double[] eigenval)
Incase all 3 eigenvalues are different (most cases) in order to derive the eigenvectors we use the Gauss elimination procedure with scaled pivoting


findEigenvec2

public static double[][] findEigenvec2(double[] eigenval)
FIND EIGEN VEC 2


checkEigenVec

public static void checkEigenVec()
In order to get the proper rotation matrix (kabsch 1978) when a1,a2,a3 are out eigenvectors we make sure that a1*a2 = a3


calcBvectors

public static double[][] calcBvectors()
Calculating the B vectors (equation 12 at Kabsch-1976)


createUmatrix

public static void createUmatrix(double[][] bVectors)
Creating the U matrix, the rotation matrix. Please note that since we switched the X and the Y atoms when creating the R matrix, we don't return U but the transposed of U


calculateRms

public static void calculateRms()

findMaxAbs

public static double findMaxAbs(double a,
                                double b)
some help functions


findMin

public static double findMin(double a,
                             double b)

findMax

public static double findMax(double a,
                             double b)

copyMat

public static double[][] copyMat(double[][] mat)

rmsPartial

public static double rmsPartial(double[][] co,
                                double[][] co2,
                                int[] partList)
Finds the RMS according to a small subset of the two proteins. The subset is an array of indexes to set of atoms in the proteins (starting from 0 for the first atom).The second protein is then rotated so that the subset is in best rms fit woth the first protein. the first protein does not move. The output RMS number is the RMS of the entire two proteins.


rmsPartialAltRMS

public static double rmsPartialAltRMS(double[][] co,
                                      double[][] co2,
                                      int[] partList)
This is exactly the same as 'rmsPartial' except that the rms is calculated on the subset only.