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

The following examples show how to use org.biojava.nbio.structure.align.model.AFPChain#getConn() . 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);
}
 
Example 2
Source File: AFPChainer.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
//Key function: calculate the connectivity of AFP pairs
//no compatibility criteria is executed
//note: afp1 is previous to afp2 in terms of the position
	 //this module must be optimized
 *
 * @param afp1
 * @param afp2
 * @return flag if they are connected
 */
public static boolean afpPairConn(int afp1, int afp2,  FatCatParameters params, AFPChain afpChain)

{

	Double conn = afpChain.getConn();
	Double dvar = afpChain.getDVar();

	double misScore = params.getMisScore();
	double maxPenalty = params.getMaxPenalty();
	double disCut = params.getDisCut();
	double gapExtend = params.getGapExtend();
	double torsionPenalty = params.getTorsionPenalty();
	double disSmooth = params.getDisSmooth();

	List<AFP> afpSet = afpChain.getAfpSet();

	int     m = calcGap(afpSet.get(afp2),afpSet.get(afp1));
	int     g = calcMismatch(afpSet.get(afp2),afpSet.get(afp1));


	double  gp = misScore * m;      //on average, penalty for a mismatch is misScore, no modification on score
	if(g > 0)       {
		gp += gapExtend * g;
	}
	if(gp < maxPenalty)     gp = maxPenalty; //penalty cut-off
	//note: use < (smaller) instead of >, because maxPenalty is a negative number

	double  d;
	d = calAfpDis(afp1, afp2,params, afpChain);
	//note: the 'dis' value is numerically equivalent to the 'rms' with exceptions

	boolean     ch = false;
	double  tp = 0.0;
	if(d >= disCut) {
		tp = torsionPenalty;
		ch = true;
	} //use the variation of the distances between AFPs
	else  if(d > disCut - disSmooth)        {
		double  wt = Math.sqrt((d - disCut + disSmooth) / disSmooth);
		//using sqrt: penalty increase with dis more quicker than linear function
		tp = torsionPenalty * wt;
	}

	dvar = d;
	conn = tp + gp;

	afpChain.setConn(conn);
	afpChain.setDVar(dvar);
	return ch;
}