jpayne@68: package aligner; jpayne@68: jpayne@68: jpayne@68: /** FlatAligner with flatter weights */ jpayne@68: public final class FlatAligner2 { jpayne@68: jpayne@68: public FlatAligner2(){} jpayne@68: jpayne@68: /** jpayne@68: * @param query jpayne@68: * @param ref jpayne@68: * @param qstart jpayne@68: * @param rstart jpayne@68: * @param rstop jpayne@68: * @param minScore Quit early if score drops below this jpayne@68: * @param minRatio Don't return results if max score is less than this fraction of max possible score jpayne@68: * @return jpayne@68: */ jpayne@68: public AlignmentResult alignForward(final byte[] query, final byte[] ref, final int rstart, final int rstop, final int minScore, jpayne@68: final float minRatio) { jpayne@68: // if(ref.length<16300){return ica16.alignForward(query, ref, qstart, rstart, rstop, minScore, minRatio);} jpayne@68: final int arrayLength=rstop-rstart+1; jpayne@68: // if(array1==null || arrayLength+1>array1.length){ jpayne@68: // array1=new int[(int)((arrayLength+2)*1.2)]; jpayne@68: // array2=new int[(int)((arrayLength+2)*1.2)]; jpayne@68: // } jpayne@68: jpayne@68: //Stack allocated; faster. jpayne@68: final int[] array1=new int[arrayLength+1], array2=new int[arrayLength+1]; jpayne@68: jpayne@68: final int minPassingScore=(int)(query.length*minRatio*pointsMatch); jpayne@68: final int minPassingScore3=minPassingScore-query.length*pointsMatch; jpayne@68: jpayne@68: int[] prev=array1, next=array2; jpayne@68: int maxScore=-999999; jpayne@68: int maxQpos=-1; jpayne@68: int maxRpos=-1; jpayne@68: jpayne@68: for(int i=0; i<=arrayLength-query.length; i++){prev[i]=0;} jpayne@68: for(int i=arrayLength-query.length, score=0; i<=arrayLength; i++, score+=pointsDel) { jpayne@68: prev[i]=score; jpayne@68: } jpayne@68: jpayne@68: int currentRstart=rstart; jpayne@68: for(int qpos=0; qpos=maxScoreThisPass){ jpayne@68: // maxScoreThisPass=score; jpayne@68: // if(score>=maxScore){ jpayne@68: // maxScore=score; jpayne@68: // maxQpos=qpos; jpayne@68: // maxRpos=rpos; jpayne@68: // } jpayne@68: // } jpayne@68: jpayne@68: //Should be branchless conditional moves jpayne@68: int score=(dScore>=vScore ? dScore : vScore); jpayne@68: score=(hScore>score ? hScore : score); jpayne@68: next[apos]=score; jpayne@68: maxScoreThisPass=(score>maxScoreThisPass ? score : maxScoreThisPass); jpayne@68: jpayne@68: // minViableRstart=((scoreminViableRstart) ? minViableRstart : rpos); jpayne@68: } jpayne@68: iters+=arrayLength; jpayne@68: // currentRstart=minViableRstart; jpayne@68: // System.err.println("qPos="+qpos+", maxScoreThisPass="+maxScoreThisPass+", maxScore="+maxScore+", minScore="+minScore); jpayne@68: // System.err.println(Arrays.toString(prev)); jpayne@68: // System.err.println(Arrays.toString(next)); jpayne@68: if(maxScoreThisPass