Java Code Examples for org.biojava.nbio.structure.align.model.AFPChain#setDisTable2()

The following examples show how to use org.biojava.nbio.structure.align.model.AFPChain#setDisTable2() . 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: CEMirrorSymm.java    From symmetry with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void postProcessAlignment(AFPChain afpChain) {
	if (mirrorSequence) {
		// reverse the optAln
		reverseOptAln(afpChain);

		// reverse the distance matrix
		afpChain.setDistanceMatrix(reverseMatrixCols(afpChain
				.getDistanceMatrix()));

		// reverse the ca2 matrix
		Matrix distMat2 = afpChain.getDisTable2();
		distMat2 = reverseMatrixRows(distMat2);
		distMat2 = reverseMatrixCols(distMat2);
		afpChain.setDisTable2(distMat2);
	}

}
 
Example 2
Source File: OptimalCECPMain.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Permute the second protein of afpChain by the specified number of residues.
 * @param afpChain Input alignment
 * @param cp Amount leftwards (or rightward, if negative) to shift the
 * @return A new alignment equivalent to afpChain after the permutations
 */
private static void permuteAFPChain(AFPChain afpChain, int cp) {

	int ca2len = afpChain.getCa2Length();

	//fix up cp to be positive
	if(cp == 0) {
		return;
	}
	if(cp < 0) {
		cp = ca2len+cp;
	}
	if(cp < 0 || cp >= ca2len) {
		throw new ArrayIndexOutOfBoundsException(
				"Permutation point ("+cp+") must be between -ca2.length and ca2.length-1" );
	}

	// Fix up optAln
	permuteOptAln(afpChain,cp);

	if(afpChain.getBlockNum() > 1)
		afpChain.setSequentialAlignment(false);
	// fix up matrices
	// ca1 corresponds to row indices, while ca2 corresponds to column indices.
	afpChain.setDistanceMatrix(permuteMatrix(afpChain.getDistanceMatrix(),0,-cp));
	// this is square, so permute both
	afpChain.setDisTable2(permuteMatrix(afpChain.getDisTable2(),-cp,-cp));

	//TODO fix up other AFP parameters?

}
 
Example 3
Source File: CeCPMain.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * 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;
}