package var2; import shared.Tools; import structures.ByteBuilder; public class SoftClipper { public static byte[] softClipMatch(byte[] match, int minClipLength, boolean allowMutation, final int oldStart, final int oldStop, final int[] startStopRvec){ final int matchScore=100; final int subScore=-200; final int subScore2=-100; final int insScore=-200; final int delScore=-200; final int delScore2=-10; final int clipScore=-1; final int nScore=1; int insCount=0; int delCount=0; long score=0; long maxScore=0; int maxPos=-1; int maxStart=-1; int currentStart=-1; byte current='?'; for(int mpos=0; mposmaxScore){ maxScore=score; maxPos=mpos; maxStart=currentStart; } }else{ if(m=='S' || m=='s'){ score=score+(m==current ? subScore2 : subScore); }else if(m=='D'){ score=score+(m==current ? delScore2 : delScore); delCount++; }else if(m=='I' || m=='X' || m=='Y'){ score=score+insScore; insCount++; }else if(m=='C'){ score=score+clipScore; } score=Tools.max(0, score); } current=m; } if(maxScore<1){return match;} final int leftClipM=maxStart; final int rightClipM=(match.length-maxPos-1); int leftClip=0, rightClip=0; for(int i=0; imaxPos){ rightClip+=(m=='D' ? 0 : 1); } } if(leftClip=minClipLength){ for(int mpos=0, processed=0; mpos=leftClipM){ bb.append(m); }else{ if(m=='D'){ start++; }else if(m=='I'){ start--; bb.append('C'); processed++; }else{ bb.append('C'); processed++; } } } }else{ bb.append(match); } if(rightClip>=minClipLength){ bb.reverseInPlace(); byte[] temp=bb.toBytes(); bb.clear(); for(int mpos=0, processed=0; mpos=rightClipM){ bb.append(m); }else{ if(m=='D'){ stop--; }else if(m=='I'){ stop++; bb.append('C'); processed++; }else{ bb.append('C'); processed++; } } } bb.reverseInPlace(); } startStopRvec[0]=start; startStopRvec[1]=stop; return bb.toBytes(); } }