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

The following examples show how to use org.biojava.nbio.structure.align.model.AFPChain#setBlockScore() . 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: AFPOptimizer.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * to update the chaining score after block delete and merge processed
 * the blockScore value is important for significance evaluation
 */
public static void updateScore(FatCatParameters params, AFPChain afpChain)
{
	int     i, j, bknow, bkold, g1, g2;


	afpChain.setConn(0d);
	afpChain.setDVar(0d);

	int blockNum = afpChain.getBlockNum();
	int alignScoreUpdate = 0;
	double[] blockScore = afpChain.getBlockScore();
	int[] blockGap = afpChain.getBlockGap();
	int[] blockSize =afpChain.getBlockSize();
	int[] afpChainList = afpChain.getAfpChainList();
	List<AFP>afpSet = afpChain.getAfpSet();
	int[] block2Afp = afpChain.getBlock2Afp();

	double torsionPenalty = params.getTorsionPenalty();


	bkold = 0;
	for(i = 0; i < blockNum; i ++)  {
		blockScore[i] = 0;
		blockGap[i] = 0;
		for(j = 0; j < blockSize[i]; j ++)      {
			bknow = afpChainList[block2Afp[i] + j];
			if(j == 0)      {
				blockScore[i] = afpSet.get(bknow).getScore();
			}
			else    {
				AFPChainer.afpPairConn(bkold, bknow, params, afpChain); //note: j, i
				Double conn = afpChain.getConn();
				blockScore[i] += afpSet.get(bknow).getScore() + conn;
				g1 = afpSet.get(bknow).getP1() - afpSet.get(bkold).getP1() - afpSet.get(bkold).getFragLen();
				g2 = afpSet.get(bknow).getP2() - afpSet.get(bkold).getP2() - afpSet.get(bkold).getFragLen();
				blockGap[i] += (g1 > g2)?g1:g2;
			}
			bkold = bknow;
		}
		alignScoreUpdate += blockScore[i];
	}
	if(blockNum >= 2)       {
		alignScoreUpdate += (blockNum - 1) * torsionPenalty;
	}

	afpChain.setBlockGap(blockGap);
	afpChain.setAlignScoreUpdate(alignScoreUpdate);
	afpChain.setBlockScore(blockScore);
	afpChain.setBlockSize(blockSize);
	afpChain.setAfpChainList(afpChainList);
	afpChain.setBlock2Afp(block2Afp);
}