Java Code Examples for org.biojava.nbio.structure.align.model.AFPChain#getBlockRotationMatrix()
The following examples show how to use
org.biojava.nbio.structure.align.model.AFPChain#getBlockRotationMatrix() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AFPChainXMLConverter.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
private static void printXMLMatrixShift(PrettyXMLWriter xml, AFPChain afpChain, int blockNr) throws IOException { Matrix[] ms = afpChain.getBlockRotationMatrix(); if ( ms == null || ms.length == 0) return; Matrix matrix = ms[blockNr]; if ( matrix == null) return; xml.openTag("matrix"); for (int x=0;x<3;x++){ for (int y=0;y<3;y++){ String key = "mat"+(x+1)+(y+1); xml.attribute(key,String.format("%.6f",matrix.get(x,y))); } } xml.closeTag("matrix"); Atom[] shifts = afpChain.getBlockShiftVector(); Atom shift = shifts[blockNr]; xml.openTag("shift"); xml.attribute("x", String.format("%.3f",shift.getX())); xml.attribute("y", String.format("%.3f",shift.getY())); xml.attribute("z", String.format("%.3f",shift.getZ())); xml.closeTag("shift"); }
Example 2
Source File: RotationAxis.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** * Calculate the rotation angle for a structure * @param afpChain * @return The rotation angle, in radians * @throws StructureException If the alignment doesn't contain any blocks * @throws NullPointerException If the alignment doesn't have a rotation matrix set */ public static double getAngle(AFPChain afpChain) throws StructureException { if(afpChain.getBlockNum() < 1) { throw new StructureException("No aligned residues"); } Matrix rotation = afpChain.getBlockRotationMatrix()[0]; if(rotation == null) { throw new NullPointerException("AFPChain does not contain a rotation matrix"); } return getAngle(rotation); }
Example 3
Source File: CeCPMain.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** * Swaps the order of structures in an AFPChain * @param a * @return */ public AFPChain invertAlignment(AFPChain a) { String name1 = a.getName1(); String name2 = a.getName2(); a.setName1(name2); a.setName2(name1); int len1 = a.getCa1Length(); a.setCa1Length( a.getCa2Length() ); a.setCa2Length( len1 ); int beg1 = a.getAlnbeg1(); a.setAlnbeg1(a.getAlnbeg2()); a.setAlnbeg2(beg1); char[] alnseq1 = a.getAlnseq1(); a.setAlnseq1(a.getAlnseq2()); a.setAlnseq2(alnseq1); Matrix distab1 = a.getDisTable1(); a.setDisTable1(a.getDisTable2()); a.setDisTable2(distab1); int[] focusRes1 = a.getFocusRes1(); a.setFocusRes1(a.getFocusRes2()); a.setFocusRes2(focusRes1); //What are aftIndex and befIndex used for? How are they indexed? //a.getAfpAftIndex() String[][][] pdbAln = a.getPdbAln(); if( pdbAln != null) { for(int block = 0; block < a.getBlockNum(); block++) { String[] paln1 = pdbAln[block][0]; pdbAln[block][0] = pdbAln[block][1]; pdbAln[block][1] = paln1; } } int[][][] optAln = a.getOptAln(); if( optAln != null ) { for(int block = 0; block < a.getBlockNum(); block++) { int[] aln1 = optAln[block][0]; optAln[block][0] = optAln[block][1]; optAln[block][1] = aln1; } } a.setOptAln(optAln); // triggers invalidate() Matrix distmat = a.getDistanceMatrix(); if(distmat != null) a.setDistanceMatrix(distmat.transpose()); // invert the rotation matrices Matrix[] blockRotMat = a.getBlockRotationMatrix(); Atom[] shiftVec = a.getBlockShiftVector(); if( blockRotMat != null) { for(int block = 0; block < a.getBlockNum(); block++) { if(blockRotMat[block] != null) { // if y=x*A+b, then x=y*inv(A)-b*inv(A) blockRotMat[block] = blockRotMat[block].inverse(); Calc.rotate(shiftVec[block],blockRotMat[block]); shiftVec[block] = Calc.invert(shiftVec[block]); } } } return a; }
Example 4
Source File: AlignmentTools.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** Rotate the Atoms/Groups so they are aligned for the 3D visualisation * * @param afpChain * @param ca1 * @param ca2 * @return an array of Groups that are transformed for 3D display * @throws StructureException */ public static Group[] prepareGroupsForDisplay(AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException{ if ( afpChain.getBlockRotationMatrix().length == 0 ) { // probably the alignment is too short! System.err.println("No rotation matrix found to rotate 2nd structure!"); afpChain.setBlockRotationMatrix(new Matrix[]{Matrix.identity(3, 3)}); afpChain.setBlockShiftVector(new Atom[]{new AtomImpl()}); } // List of groups to be rotated according to the alignment Group[] twistedGroups = new Group[ ca2.length]; //int blockNum = afpChain.getBlockNum(); int i = -1; // List of groups from the structure not included in ca2 (e.g. ligands) // Will be rotated according to first block List<Group> hetatms2 = StructureTools.getUnalignedGroups(ca2); if ( (afpChain.getAlgorithmName().equals(FatCatRigid.algorithmName) ) || (afpChain.getAlgorithmName().equals(FatCatFlexible.algorithmName) ) ){ for (Atom a: ca2){ i++; twistedGroups[i]=a.getGroup(); } twistedGroups = AFPTwister.twistOptimized(afpChain, ca1, ca2); //} else if (( blockNum == 1 ) || (afpChain.getAlgorithmName().equals(CeCPMain.algorithmName))) { } else { Matrix m = afpChain.getBlockRotationMatrix()[ 0]; Atom shift = afpChain.getBlockShiftVector() [ 0 ]; shiftCA2(afpChain, ca2, m,shift, twistedGroups); } if ( afpChain.getBlockNum() > 0){ // Superimpose ligands relative to the first block if( hetatms2.size() > 0 ) { if ( afpChain.getBlockRotationMatrix().length > 0 ) { Matrix m1 = afpChain.getBlockRotationMatrix()[0]; //m1.print(3,3); Atom vector1 = afpChain.getBlockShiftVector()[0]; //System.out.println("shift vector:" + vector1); for ( Group g : hetatms2){ Calc.rotate(g, m1); Calc.shift(g,vector1); } } } } return twistedGroups; }
Example 5
Source File: AFPTwister.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** * transform the coordinates in the ca2 according to the superimposing of * the given position pairs. No Cloning, transforms input atoms. */ // orig name: transPdb private static void transformOrigPDB(int n, int[] res1, int[] res2, Atom[] ca1, Atom[] ca2, AFPChain afpChain, int blockNr) throws StructureException { logger.debug( "transforming original coordinates {} len1: {} res1: {} len2: {} res2: {}", n, ca1.length, res1.length, ca2.length, res2.length); Atom[] cod1 = getAtoms(ca1, res1, n, false); Atom[] cod2 = getAtoms(ca2, res2, n, false); // double *cod1 = pro1->Cod4Res(n, res1); // double *cod2 = pro2->Cod4Res(n, res2); Matrix4d transform = SuperPositions.superpose(Calc.atomsToPoints(cod1), Calc.atomsToPoints(cod2)); Matrix r = Matrices.getRotationJAMA(transform); Atom t = Calc.getTranslationVector(transform); logger.debug("transPdb: transforming orig coordinates with matrix: {}", r); if (afpChain != null) { Matrix[] ms = afpChain.getBlockRotationMatrix(); if (ms == null) ms = new Matrix[afpChain.getBlockNum()]; ms[blockNr] = r; Atom[] shifts = afpChain.getBlockShiftVector(); if (shifts == null) shifts = new Atom[afpChain.getBlockNum()]; shifts[blockNr] = t; afpChain.setBlockRotationMatrix(ms); afpChain.setBlockShiftVector(shifts); } for (Atom a : ca2) Calc.transform(a.getGroup(), transform); }
Example 6
Source File: FlipAFPChainTest.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
public static void rotateAtoms2(AFPChain afpChain,Atom[] ca2){ int blockNum = afpChain.getBlockNum(); int[] optLen = afpChain.getOptLen(); int[][][] optAln = afpChain.getOptAln(); for(int bk = 0; bk < blockNum; bk ++) { Matrix m= afpChain.getBlockRotationMatrix()[bk]; Atom shift = afpChain.getBlockShiftVector()[bk]; for ( int i=0;i< optLen[bk];i++){ int pos = optAln[bk][1][i]; Atom a = ca2[pos]; Calc.rotate(a, m); Calc.shift(a, shift); //atoms.add(ca2[pos]); } } }
Example 7
Source File: FlipAFPChainTest.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
public static void rotateAtoms2(AFPChain afpChain,Atom[] ca2){ int blockNum = afpChain.getBlockNum(); int[] optLen = afpChain.getOptLen(); int[][][] optAln = afpChain.getOptAln(); for(int bk = 0; bk < blockNum; bk ++) { Matrix m= afpChain.getBlockRotationMatrix()[bk]; Atom shift = afpChain.getBlockShiftVector()[bk]; for ( int i=0;i< optLen[bk];i++){ int pos = optAln[bk][1][i]; Atom a = ca2[pos]; Calc.rotate(a, m); Calc.shift(a, shift); //atoms.add(ca2[pos]); } } }
Example 8
Source File: SymmetryTools.java From biojava with GNU Lesser General Public License v2.1 | 2 votes |
/** * Returns the <em>magnitude</em> of the angle between the first and second * blocks of {@code afpChain}, measured in degrees. This is always a * positive value (unsigned). * * @param afpChain * @param ca1 * @param ca2 * @return */ public static double getAngle(AFPChain afpChain, Atom[] ca1, Atom[] ca2) { Matrix rotation = afpChain.getBlockRotationMatrix()[0]; return Math.acos(rotation.trace() - 1) * 180 / Math.PI; }