Java Code Examples for org.biojava.nbio.structure.align.model.AFPChain#getPdbAln()
The following examples show how to use
org.biojava.nbio.structure.align.model.AFPChain#getPdbAln() .
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 printXMLEQRKnownPositions(PrettyXMLWriter xml, AFPChain afpChain, int blockNr) throws IOException, StructureException{ int[] optLen = afpChain.getOptLen(); String[][][] pdbAln = afpChain.getPdbAln(); if ( pdbAln == null){ throw new StructureException("Can't convert to XML without known the PDB coordinates. Please provide Ca atoms and call toXML(afpChain,ca1, ca2)"); } for ( int eqrNr = 0 ; eqrNr < optLen[blockNr] ; eqrNr++ ){ String pdbResnum1 = pdbAln[blockNr][0][eqrNr]; String pdbResnum2 = pdbAln[blockNr][1][eqrNr]; //System.out.println(eqrNr + " got resnum: " + pdbResnum1 + " " + pdbResnum2); String[] spl1 = pdbResnum1.split(":"); String[] spl2 = pdbResnum2.split(":"); String chain1 = spl1[0]; String pdbres1 = spl1[1]; String chain2 = spl2[0]; String pdbres2 = spl2[1]; xml.openTag("eqr"); xml.attribute("eqrNr", String.valueOf(eqrNr)); xml.attribute("pdbres1",pdbres1); xml.attribute("chain1", chain1); xml.attribute("pdbres2",pdbres2); xml.attribute("chain2", chain2); xml.closeTag("eqr"); } }
Example 2
Source File: AFPChainXMLParser.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** replace the PDB res nums with atom positions: * * @param afpChain * @param ca1 * @param ca2 */ public static void rebuildAFPChain(AFPChain afpChain, Atom[] ca1, Atom[] ca2){ if ( afpChain.getAlgorithmName() == null) { afpChain.setAlgorithmName(DEFAULT_ALGORITHM_NAME); } if ( afpChain.getVersion() == null){ afpChain.setVersion("1.0"); } int blockNum = afpChain.getBlockNum(); int ca1Length = afpChain.getCa1Length(); int ca2Length = afpChain.getCa2Length(); int minLength = Math.min(ca1Length, ca2Length); int[][][] optAln = new int[blockNum][2][minLength]; int[][][] blockResList = afpChain.getBlockResList(); if ( blockResList == null){ blockResList = new int[blockNum][2][minLength]; } int[] optLen = afpChain.getOptLen(); String[][][] pdbAln = afpChain.getPdbAln(); int[] verifiedOptLen = null; if ( optLen != null) verifiedOptLen = afpChain.getOptLen().clone(); else { logger.warn("did not find optimal alignment, building up empty alignment."); optLen = new int[1]; optLen[0] = 0; } for (int blockNr = 0 ; blockNr < blockNum ; blockNr++){ //System.out.println("got block " + blockNr + " size: " + optLen[blockNr]); int verifiedEQR = -1; for ( int eqrNr = 0 ; eqrNr < optLen[blockNr] ; eqrNr++ ){ String pdbResnum1 = pdbAln[blockNr][0][eqrNr]; String pdbResnum2 = pdbAln[blockNr][1][eqrNr]; //System.out.println(blockNr + " " + eqrNr + " got resnum: " + pdbResnum1 + " " + pdbResnum2); String[] spl1 = pdbResnum1.split(":"); String[] spl2 = pdbResnum2.split(":"); String chain1 = spl1[0]; String pdbres1 = spl1[1]; String chain2 = spl2[0]; String pdbres2 = spl2[1]; int pos1 = getPositionForPDBresunm(pdbres1,chain1,ca1); int pos2 = getPositionForPDBresunm(pdbres2,chain2,ca2); if ( pos1 == -1 || pos2 == -1 ){ // this can happen when parsing old files that contained Calcium atoms... logger.warn("pos1: {} (residue {}), pos2: {} (residue {}), should never be -1. Probably parsing an old file.", pos1, pdbResnum1, pos2, pdbResnum2); verifiedOptLen[blockNr]-- ; continue; } verifiedEQR++; //System.out.println(blockNr + " " + eqrNr + " " + pos1 + " " + pos2); optAln[blockNr][0][verifiedEQR] = pos1; optAln[blockNr][1][verifiedEQR] = pos2; blockResList[blockNr][0][verifiedEQR] = pos1; blockResList[blockNr][1][verifiedEQR] = pos2; } } afpChain.setOptLen(verifiedOptLen); afpChain.setOptAln(optAln); afpChain.setBlockResList(blockResList); // build up alignment image: AFPAlignmentDisplay.getAlign(afpChain, ca1, ca2); }
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; }