| 1 |
package align2; |
| 2 |
|
| 3 |
import java.util.ArrayList; |
| 4 |
|
| 5 |
import shared.Shared; |
| 6 |
import stream.SiteScore; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
public abstract class AbstractIndex { |
| 14 |
|
| 15 |
AbstractIndex(int keylen, int kfilter, int pointsMatch, int minChrom_, int maxChrom_, MSA msa_){ |
| 16 |
KEYLEN=keylen; |
| 17 |
KEYSPACE=1<<(2*KEYLEN); |
| 18 |
BASE_KEY_HIT_SCORE=pointsMatch*KEYLEN; |
| 19 |
KFILTER=kfilter; |
| 20 |
msa=msa_; |
| 21 |
|
| 22 |
minChrom=minChrom_; |
| 23 |
maxChrom=maxChrom_; |
| 24 |
assert(minChrom==MINCHROM); |
| 25 |
assert(maxChrom==MAXCHROM); |
| 26 |
assert(minChrom<=maxChrom); |
| 27 |
} |
| 28 |
|
| 29 |
final int count(int key){ |
| 30 |
|
| 31 |
if(COUNTS!=null){return COUNTS[key];} |
| 32 |
|
| 33 |
final Block b=index[0]; |
| 34 |
final int rkey=KeyRing.reverseComplementKey(key, KEYLEN); |
| 35 |
int a=b.length(key); |
| 36 |
return key==rkey ? a : a+b.length(rkey); |
| 37 |
} |
| 38 |
|
| 39 |
static final boolean overlap(int a1, int b1, int a2, int b2){ |
| 40 |
assert(a1<=b1 && a2<=b2) : a1+", "+b1+", "+a2+", "+b2; |
| 41 |
return a2<=b1 && b2>=a1; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
static final boolean isWithin(int a1, int b1, int a2, int b2){ |
| 46 |
assert(a1<=b1 && a2<=b2) : a1+", "+b1+", "+a2+", "+b2; |
| 47 |
return a1>=a2 && b1<=b2; |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
final static int scoreY(int[] locs, int centerIndex, int offsets[]){ |
| 54 |
int center=locs[centerIndex]; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
int rightIndex=-1; |
| 63 |
for(int i=offsets.length-1; rightIndex<centerIndex; i--){ |
| 64 |
if(locs[i]==center){ |
| 65 |
rightIndex=i; |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
return offsets[rightIndex]-offsets[centerIndex]; |
| 77 |
} |
| 78 |
|
| 79 |
abstract float[] keyProbArray(); |
| 80 |
abstract byte[] getBaseScoreArray(int len, int strand); |
| 81 |
abstract int[] getKeyScoreArray(int len, int strand); |
| 82 |
|
| 83 |
abstract int maxScore(int[] offsets, byte[] baseScores, int[] keyScores, int readlen, boolean useQuality); |
| 84 |
public abstract ArrayList<SiteScore> findAdvanced(byte[] basesP, byte[] basesM, byte[] qual, byte[] baseScoresP, int[] keyScoresP, int[] offsets, long id); |
| 85 |
|
| 86 |
long callsToScore=0; |
| 87 |
long callsToExtendScore=0; |
| 88 |
long initialKeys=0; |
| 89 |
long initialKeyIterations=0; |
| 90 |
long initialKeys2=0; |
| 91 |
long initialKeyIterations2=0; |
| 92 |
long usedKeys=0; |
| 93 |
long usedKeyIterations=0; |
| 94 |
|
| 95 |
static final int HIT_HIST_LEN=40; |
| 96 |
final long[] hist_hits=new long[HIT_HIST_LEN+1]; |
| 97 |
final long[] hist_hits_score=new long[HIT_HIST_LEN+1]; |
| 98 |
final long[] hist_hits_extend=new long[HIT_HIST_LEN+1]; |
| 99 |
|
| 100 |
final int minChrom; |
| 101 |
final int maxChrom; |
| 102 |
|
| 103 |
static int MINCHROM=1; |
| 104 |
static int MAXCHROM=Integer.MAX_VALUE; |
| 105 |
|
| 106 |
static final boolean SUBSUME_SAME_START_SITES=true; |
| 107 |
static final boolean SUBSUME_SAME_STOP_SITES=true; |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
static final boolean LIMIT_SUBSUMPTION_LENGTH_TO_2X=true; |
| 114 |
|
| 115 |
|
| 116 |
static final boolean SUBSUME_OVERLAPPING_SITES=false; |
| 117 |
|
| 118 |
static final boolean SHRINK_BEFORE_WALK=true; |
| 119 |
|
| 120 |
|
| 121 |
static final boolean USE_EXTENDED_SCORE=true; |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
static final boolean USE_AFFINE_SCORE=true && USE_EXTENDED_SCORE; |
| 126 |
|
| 127 |
|
| 128 |
public static final boolean RETAIN_BEST_SCORES=true; |
| 129 |
public static final boolean RETAIN_BEST_QCUTOFF=true; |
| 130 |
|
| 131 |
public static boolean QUIT_AFTER_TWO_PERFECTS=true; |
| 132 |
static final boolean DYNAMICALLY_TRIM_LOW_SCORES=true; |
| 133 |
|
| 134 |
|
| 135 |
static final boolean REMOVE_CLUMPY=true; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
static final boolean DOUBLE_SEARCH_NO_HIT=false; |
| 140 |
|
| 141 |
|
| 142 |
static final float DOUBLE_SEARCH_THRESH_MULT=0.25f; |
| 143 |
|
| 144 |
static boolean PERFECTMODE=false; |
| 145 |
static boolean SEMIPERFECTMODE=false; |
| 146 |
|
| 147 |
static boolean REMOVE_FREQUENT_GENOME_FRACTION=true; |
| 148 |
static boolean TRIM_BY_GREEDY=true; |
| 149 |
|
| 150 |
|
| 151 |
static final boolean TRIM_LONG_HIT_LISTS=false; |
| 152 |
|
| 153 |
public static int MIN_APPROX_HITS_TO_KEEP=1; |
| 154 |
|
| 155 |
|
| 156 |
public static final boolean TRIM_BY_TOTAL_SITE_COUNT=false; |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
static int MAX_USABLE_LENGTH=Integer.MAX_VALUE; |
| 163 |
static int MAX_USABLE_LENGTH2=Integer.MAX_VALUE; |
| 164 |
|
| 165 |
|
| 166 |
public static void clear(){ |
| 167 |
index=null; |
| 168 |
lengthHistogram=null; |
| 169 |
COUNTS=null; |
| 170 |
} |
| 171 |
|
| 172 |
static Block[] index; |
| 173 |
static int[] lengthHistogram=null; |
| 174 |
static int[] COUNTS=null; |
| 175 |
|
| 176 |
final int KEYLEN; |
| 177 |
final int KEYSPACE; |
| 178 |
|
| 179 |
final int KFILTER; |
| 180 |
final MSA msa; |
| 181 |
final int BASE_KEY_HIT_SCORE; |
| 182 |
|
| 183 |
|
| 184 |
boolean verbose=false; |
| 185 |
static boolean verbose2=false; |
| 186 |
|
| 187 |
static boolean SLOW=false; |
| 188 |
static boolean VSLOW=false; |
| 189 |
|
| 190 |
static int NUM_CHROM_BITS=3; |
| 191 |
static int CHROMS_PER_BLOCK=(1<<(NUM_CHROM_BITS)); |
| 192 |
|
| 193 |
static final int MINGAP=Shared.MINGAP; |
| 194 |
static final int MINGAP2=(MINGAP+128); |
| 195 |
|
| 196 |
static boolean USE_CAMELWALK=false; |
| 197 |
|
| 198 |
static final boolean ADD_LIST_SIZE_BONUS=false; |
| 199 |
static final byte[] LIST_SIZE_BONUS=new byte[100]; |
| 200 |
|
| 201 |
public static boolean GENERATE_KEY_SCORES_FROM_QUALITY=true; |
| 202 |
public static boolean GENERATE_BASE_SCORES_FROM_QUALITY=true; |
| 203 |
|
| 204 |
static final int calcListSizeBonus(int[] array){ |
| 205 |
if(array==null || array.length>LIST_SIZE_BONUS.length-1){return 0;} |
| 206 |
return LIST_SIZE_BONUS[array.length]; |
| 207 |
} |
| 208 |
|
| 209 |
static final int calcListSizeBonus(int size){ |
| 210 |
if(size>LIST_SIZE_BONUS.length-1){return 0;} |
| 211 |
return LIST_SIZE_BONUS[size]; |
| 212 |
} |
| 213 |
|
| 214 |
static{ |
| 215 |
final int len=LIST_SIZE_BONUS.length; |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
LIST_SIZE_BONUS[0]=3; |
| 221 |
LIST_SIZE_BONUS[1]=2; |
| 222 |
LIST_SIZE_BONUS[2]=1; |
| 223 |
LIST_SIZE_BONUS[len-1]=0; |
| 224 |
|
| 225 |
} |
| 226 |
|
| 227 |
} |