CeCPMain extends CeMain { protected static CPRange calculateMinCP(int[] block, int blockLen, int ca2len, int minCPlength) { CPRange range = new CPRange(); int middle = Arrays.binarySearch(block, ca2len); if(middle < 0) { middle = -middle -1; } range.mid = middle; int minCPntermIndex = middle-minCPlength; if(minCPntermIndex >= 0) { range.n = block[minCPntermIndex]; } else { range.n = -1; } int minCPctermIndex = middle+minCPlength-1; if(minCPctermIndex < blockLen) { range.c = block[minCPctermIndex]; } else { range.c = ca2len*2; } return range; } CeCPMain(); @Override String getAlgorithmName(); @Override String getVersion(); static void main(String[] args); @Override AFPChain align(Atom[] ca1, Atom[] ca2, Object param); static AFPChain postProcessAlignment(AFPChain afpChain, Atom[] ca1, Atom[] ca2m,CECalculator calculator ); static AFPChain filterDuplicateAFPs(AFPChain afpChain, CECalculator ceCalc, Atom[] ca1, Atom[] ca2duplicated); static AFPChain filterDuplicateAFPs(AFPChain afpChain, CECalculator ceCalc,
			Atom[] ca1, Atom[] ca2duplicated, int minCPlength); static final String algorithmName; static final int DEFAULT_MIN_CP_LENGTH; static final String version; }
@Test public void testCalculateMinCP() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { int[] block; int ca2len; block = new int[] { 4,5,6,8,11,12,14,15, }; ca2len = 10; int minCPlength; CeCPMain.CPRange cpRange; minCPlength = 0; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,11,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,8,cpRange.c); minCPlength = 1; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,8,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,11,cpRange.c); minCPlength = 2; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,6,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,12,cpRange.c); minCPlength = 3; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,5,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,14,cpRange.c); minCPlength = 4; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,4,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,15,cpRange.c); minCPlength = 5; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,-1,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,20,cpRange.c); block = new int[] {0,9,10,19}; ca2len = 10; minCPlength = 0; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,10,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,9,cpRange.c); minCPlength = 1; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,9,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,10,cpRange.c); minCPlength = 2; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,0,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,19,cpRange.c); minCPlength = 3; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,-1,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,20,cpRange.c); minCPlength = 4; cpRange = CeCPMain.calculateMinCP(block, block.length, ca2len, minCPlength); assertEquals("Wrong minCPnterm for minCPlen="+minCPlength,-1,cpRange.n); assertEquals("Wrong minCPcterm for minCPlen="+minCPlength,20,cpRange.c); }