Class SVDSuperimposer

java.lang.Object
org.biojava.nbio.structure.SVDSuperimposer

public class SVDSuperimposer extends Object
A class that calculates the superimposition between two sets of atoms inspired by the biopython SVDSuperimposer class... example usage:
                        // get some arbitrary amino acids from somewhere
                        String filename   =  "/Users/ap3/WORK/PDB/5pti.pdb" ;

                        PDBFileReader pdbreader = new PDBFileReader();
                        Structure struc = pdbreader.getStructure(filename);
                        Group g1 = (Group)struc.getChain(0).getGroup(21).clone();
                        Group g2 = (Group)struc.getChain(0).getGroup(53).clone();

                        if ( g1.getPDBName().equals("GLY")){
                                if ( g1 instanceof AminoAcid){
                                        Atom cb = Calc.createVirtualCBAtom((AminoAcid)g1);
                                        g1.addAtom(cb);
                                }
                        }

                        if ( g2.getPDBName().equals("GLY")){
                                if ( g2 instanceof AminoAcid){
                                        Atom cb = Calc.createVirtualCBAtom((AminoAcid)g2);
                                        g2.addAtom(cb);
                                }
                        }

                        Structure struc2 = new StructureImpl((Group)g2.clone());

                        System.out.println(g1);
                        System.out.println(g2);


                        Atom[] atoms1 = new Atom[3];
                        Atom[] atoms2 = new Atom[3];

                        atoms1[0] = g1.getAtom("N");
                        atoms1[1] = g1.getAtom("CA");
                        atoms1[2] = g1.getAtom("CB");


                        atoms2[0] = g2.getAtom("N");
                        atoms2[1] = g2.getAtom("CA");
                        atoms2[2] = g2.getAtom("CB");


                        SVDSuperimposer svds = new SVDSuperimposer(atoms1,atoms2);


                        Matrix rotMatrix = svds.getRotation();
                        Atom tranMatrix = svds.getTranslation();


                        // now we have all the info to perform the rotations ...

                        Calc.rotate(struc2,rotMatrix);

                        //          shift structure 2 onto structure one ...
                        Calc.shift(struc2,tranMatrix);

                        //
                        // write the whole thing to a file to view in a viewer

                        String outputfile = "/Users/ap3/WORK/PDB/rotated.pdb";

                        FileOutputStream out= new FileOutputStream(outputfile);
                        PrintStream p =  new PrintStream( out );

                        Structure newstruc = new StructureImpl();

                        Chain c1 = new ChainImpl();
                        c1.setName("A");
                        c1.addGroup(g1);
                        newstruc.addChain(c1);

                        Chain c2 = struc2.getChain(0);
                        c2.setName("B");
                        newstruc.addChain(c2);

                        // show where the group was originally ...
                        Chain c3 = new ChainImpl();
                        c3.setName("C");
                        //c3.addGroup(g1);
                        c3.addGroup(g2);

                        newstruc.addChain(c3);
                        p.println(newstruc.toPDB());

                        p.close();

                        System.out.println("wrote to file " + outputfile);

                
Since:
1.5
Version:
%I% %G%
Author:
Andreas Prlic
  • Constructor Details

    • SVDSuperimposer

      public SVDSuperimposer(Atom[] atomSet1, Atom[] atomSet2) throws StructureException
      Create a SVDSuperimposer object and calculate a SVD superimposition of two sets of atoms.
      Parameters:
      atomSet1 - Atom array 1
      atomSet2 - Atom array 2
      Throws:
      StructureException
  • Method Details

    • getRMS

      public static double getRMS(Atom[] atomSet1, Atom[] atomSet2) throws StructureException
      Calculate the RMS (root mean square) deviation of two sets of atoms. Atom sets must be pre-rotated.
      Parameters:
      atomSet1 - atom array 1
      atomSet2 - atom array 2
      Returns:
      the RMS of two atom sets
      Throws:
      StructureException
    • getTMScore

      public static double getTMScore(Atom[] atomSet1, Atom[] atomSet2, int len1, int len2) throws StructureException
      Calculate the TM-Score for the superposition. Normalizes by the minimum-length structure (that is, min\{len1,len2\}). Atom sets must be pre-rotated.

      Citation:
      Zhang Y and Skolnick J (2004). "Scoring function for automated assessment of protein structure template quality". Proteins 57: 702 - 710.

      Parameters:
      atomSet1 - atom array 1
      atomSet2 - atom array 2
      len1 - The full length of the protein supplying atomSet1
      len2 - The full length of the protein supplying atomSet2
      Returns:
      The TM-Score
      Throws:
      StructureException
    • getTMScoreAlternate

      public static double getTMScoreAlternate(Atom[] atomSet1, Atom[] atomSet2, int len1, int len2) throws StructureException
      Calculate the TM-Score for the superposition. Normalizes by the maximum-length structure (that is, max\{len1,len2\}) rather than the minimum. Atom sets must be pre-rotated.

      Citation:
      Zhang Y and Skolnick J (2004). "Scoring function for automated assessment of protein structure template quality". Proteins 57: 702 - 710.

      Parameters:
      atomSet1 - atom array 1
      atomSet2 - atom array 2
      len1 - The full length of the protein supplying atomSet1
      len2 - The full length of the protein supplying atomSet2
      Returns:
      The TM-Score
      Throws:
      StructureException
    • getRotation

      public Matrix getRotation()
      Get the Rotation matrix that is required to superimpose the two atom sets.
      Returns:
      a rotation matrix.
    • getTranslation

      public Atom getTranslation()
      Get the shift vector.
      Returns:
      the shift vector
    • getTransformation

      public javax.vecmath.Matrix4d getTransformation()