| 1 |
package sketch; |
| 2 |
|
| 3 |
import java.util.ArrayList; |
| 4 |
import java.util.Arrays; |
| 5 |
import java.util.Collections; |
| 6 |
import java.util.HashMap; |
| 7 |
import java.util.concurrent.atomic.AtomicInteger; |
| 8 |
|
| 9 |
import dna.AminoAcid; |
| 10 |
import fileIO.ReadWrite; |
| 11 |
import shared.KillSwitch; |
| 12 |
import shared.Tools; |
| 13 |
import structures.AbstractBitSet; |
| 14 |
import structures.ByteBuilder; |
| 15 |
import structures.IntList; |
| 16 |
import structures.LongHashMap; |
| 17 |
import structures.LongList; |
| 18 |
import structures.LongPair; |
| 19 |
import tax.ImgRecord; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public class Sketch extends SketchObject implements Comparable<Sketch>, Cloneable { |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
@Override |
| 33 |
public Sketch clone() { |
| 34 |
Sketch copy=null; |
| 35 |
try { |
| 36 |
copy = (Sketch)super.clone(); |
| 37 |
} catch (CloneNotSupportedException e) { |
| 38 |
|
| 39 |
throw new RuntimeException(e); |
| 40 |
} |
| 41 |
copy.compareBitSet=null; |
| 42 |
copy.indexBitSet=null; |
| 43 |
return copy; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
public Sketch(long[] keys_, int[] keyCounts_, long[] baseCounts_, byte[] r16S_, byte[] r18S_, ArrayList<String> meta_){ |
| 48 |
this(keys_, keyCounts_, baseCounts_, r16S_, r18S_, -1, -1, -1, -1, -1, -1, null, null, null, meta_); |
| 49 |
} |
| 50 |
|
| 51 |
public Sketch(SketchHeap heap, boolean clearFname, boolean keepCounts, ArrayList<String> meta_){ |
| 52 |
this(heap, clearFname, keepCounts, meta_, -1); |
| 53 |
} |
| 54 |
|
| 55 |
public Sketch(SketchHeap heap, boolean clearFname, boolean keepCounts, ArrayList<String> meta_, int minKeyOccuranceCount){ |
| 56 |
this(heap.toSketchArray_minCount(minKeyOccuranceCount), null, heap.baseCounts(false), heap.r16S(), heap.r18S(), (int)heap.taxID, heap.imgID, |
| 57 |
heap.genomeSizeBases, heap.genomeSizeKmers, heap.genomeSequences, |
| 58 |
heap.probCorrect(), heap.taxName(), heap.name0(), heap.fname(), meta_); |
| 59 |
assert(keyCounts==null); |
| 60 |
if(!heap.setMode && keepCounts){ |
| 61 |
LongHashMap map=heap.map(); |
| 62 |
keyCounts=new int[keys.length]; |
| 63 |
for(int i=0; i<keys.length; i++){ |
| 64 |
int count=map.get(Long.MAX_VALUE-keys[i]); |
| 65 |
assert(count>0) : keys[i]+" -> "+count+"\n"+Arrays.toString(map.values())+"\n"+Arrays.toString(map.keys()); |
| 66 |
keyCounts[i]=count; |
| 67 |
} |
| 68 |
} |
| 69 |
if(heap.setMode){heap.clearSet();} |
| 70 |
heap.clear(clearFname); |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
public Sketch(long[] keys_, int[] keyCounts_, long[] baseCounts_, byte[] r16S_, byte[] r18S_, int taxID_, long imgID_, long gSizeBases_, |
| 77 |
long gSizeKmers_, long gSequences_, double probCorrect_, String taxName_, String name0_, String fname_, ArrayList<String> meta_){ |
| 78 |
|
| 79 |
|
| 80 |
keys=keys_; |
| 81 |
keyCounts=keyCounts_; |
| 82 |
|
| 83 |
baseCounts=baseCounts_; |
| 84 |
r16S=r16S_; |
| 85 |
r18S=r18S_; |
| 86 |
assert(keyCounts==null || keys==null || keyCounts.length==keys.length) : (keys==null ? "null" : keys.length)+", "+(keyCounts==null ? "null" : keyCounts.length); |
| 87 |
taxID=taxID_; |
| 88 |
imgID=imgID_; |
| 89 |
sketchID=nextSketch.getAndIncrement(); |
| 90 |
genomeSizeBases=gSizeBases_; |
| 91 |
genomeSizeKmers=gSizeKmers_; |
| 92 |
genomeSequences=gSequences_; |
| 93 |
probCorrect=probCorrect_<=0 ? 0f : (float)probCorrect_; |
| 94 |
meta=meta_; |
| 95 |
|
| 96 |
taxName=fix(taxName_); |
| 97 |
name0=fix(name0_); |
| 98 |
fname=fix(fname_); |
| 99 |
if(fname!=null && (fname.startsWith("stdin.") || fname.endsWith(".sketch") || fname.endsWith(".sketch.gz"))){fname=null;} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
if(ImgRecord.imgMap!=null && imgID>=0 && taxID<0){ |
| 116 |
ImgRecord record=ImgRecord.imgMap.get(imgID); |
| 117 |
if(record!=null){ |
| 118 |
if(record.name!=null && taxName==null){taxName=record.name;} |
| 119 |
taxID=record.taxID; |
| 120 |
} |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
void loadSSU(){ |
| 125 |
if(taxID>0 && taxID<minFakeID){ |
| 126 |
if(r16S==null && SSUMap.r16SMap!=null){ |
| 127 |
r16S=SSUMap.r16SMap.get(taxID); |
| 128 |
} |
| 129 |
if(r18S==null && SSUMap.r18SMap!=null){ |
| 130 |
r18S=SSUMap.r18SMap.get(taxID); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
} |
| 136 |
|
| 137 |
void addMeta(String s){ |
| 138 |
s=fixMeta(s); |
| 139 |
if(s==null){return;} |
| 140 |
if(meta==null){meta=new ArrayList<String>(1);} |
| 141 |
meta.add(s); |
| 142 |
} |
| 143 |
|
| 144 |
void setMeta(ArrayList<String> list){ |
| 145 |
assert(meta==null); |
| 146 |
meta=list; |
| 147 |
} |
| 148 |
|
| 149 |
private static String fix(String s){ |
| 150 |
if(s==null){return null;} |
| 151 |
return s.replace('\t', ' '); |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
public void add(Sketch other, int maxlen){ |
| 159 |
assert(keyCounts==null && other.keyCounts==null); |
| 160 |
final long[] a=keys; |
| 161 |
final long[] b=other.keys; |
| 162 |
if(maxlen<1){ |
| 163 |
assert(false); |
| 164 |
maxlen=1000000; |
| 165 |
} |
| 166 |
LongList list=new LongList(Tools.min(maxlen, a.length+b.length)); |
| 167 |
|
| 168 |
for(int i=0, j=0; i<a.length && j<b.length; ){ |
| 169 |
final long ka=a[i], kb=b[j]; |
| 170 |
if(ka==kb){ |
| 171 |
list.add(ka); |
| 172 |
i++; |
| 173 |
j++; |
| 174 |
}else if(ka<kb){ |
| 175 |
list.add(ka); |
| 176 |
i++; |
| 177 |
}else{ |
| 178 |
list.add(kb); |
| 179 |
j++; |
| 180 |
} |
| 181 |
if(list.size()>=maxlen){break;} |
| 182 |
} |
| 183 |
|
| 184 |
if(keys.length==list.size()){ |
| 185 |
for(int i=0; i<list.size; i++){ |
| 186 |
keys[i]=list.array[i]; |
| 187 |
} |
| 188 |
}else{ |
| 189 |
keys=list.toArray(); |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
public void resize(int newSize) { |
| 194 |
if(newSize>=length()){return;} |
| 195 |
keys=Arrays.copyOf(keys, newSize); |
| 196 |
|
| 197 |
if(keyCounts!=null){ |
| 198 |
for(int i=0; i<newSize; i++) |
| 199 |
keyCounts=Arrays.copyOf(keyCounts, newSize); |
| 200 |
} |
| 201 |
} |
| 202 |
|
| 203 |
int fixKeyCounts(){ |
| 204 |
return fixKeyCounts(keyCounts==null ? maxCount : keyCounts.length); |
| 205 |
} |
| 206 |
|
| 207 |
int fixKeyCounts(int maxLen){ |
| 208 |
int max=0; |
| 209 |
if(keyCounts!=null){ |
| 210 |
for(int i=0; i<maxLen && max<2; i++){ |
| 211 |
max=Tools.max(keyCounts[i], max); |
| 212 |
} |
| 213 |
} |
| 214 |
if(max<2){keyCounts=null;} |
| 215 |
maxCount=Tools.max((maxCount>0 ? 1 : 0), max); |
| 216 |
return maxCount; |
| 217 |
} |
| 218 |
|
| 219 |
public int applyBlacklist() { |
| 220 |
assert(blacklist!=null); |
| 221 |
LongList keylist=new LongList(keys.length); |
| 222 |
IntList countlist=(keyCounts==null ? null : new IntList(keys.length)); |
| 223 |
int removed=0; |
| 224 |
for(int i=0; i<keys.length; i++){ |
| 225 |
long key=keys[i]; |
| 226 |
if(!Blacklist.contains(Long.MAX_VALUE-key)){ |
| 227 |
keylist.add(key); |
| 228 |
if(keyCounts!=null){countlist.add(keyCounts[i]);} |
| 229 |
}else{ |
| 230 |
removed++; |
| 231 |
} |
| 232 |
} |
| 233 |
if(keylist.size()!=keys.length){ |
| 234 |
keys=keylist.toArray(); |
| 235 |
if(keyCounts!=null){keyCounts=countlist.toArray();} |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
return removed; |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
public static final Sketch intersection(Sketch sa, Sketch sb){ |
| 248 |
Sketch shared=intersection(sa.keys, sb.keys, sa.keyCounts); |
| 249 |
if(shared!=null){ |
| 250 |
shared.taxID=sb.taxID; |
| 251 |
shared.taxName=sb.taxName; |
| 252 |
shared.name0=sb.name0; |
| 253 |
shared.fname=sb.fname; |
| 254 |
shared.meta=sb.meta; |
| 255 |
shared.imgID=sb.imgID; |
| 256 |
shared.spid=sb.spid; |
| 257 |
} |
| 258 |
return shared; |
| 259 |
} |
| 260 |
|
| 261 |
public static final Sketch intersection(long[] a, long[] b, int[] aCounts){ |
| 262 |
int i=0, j=0, matches=0; |
| 263 |
LongList ll=new LongList(); |
| 264 |
IntList il=new IntList(); |
| 265 |
for(; i<a.length && j<b.length; ){ |
| 266 |
final long ka=a[i], kb=b[j]; |
| 267 |
if(ka==kb){ |
| 268 |
matches++; |
| 269 |
ll.add(ka); |
| 270 |
if(aCounts!=null){ |
| 271 |
il.add(aCounts[i]); |
| 272 |
} |
| 273 |
i++; |
| 274 |
j++; |
| 275 |
}else if(ka<kb){ |
| 276 |
i++; |
| 277 |
}else{ |
| 278 |
j++; |
| 279 |
} |
| 280 |
} |
| 281 |
if(matches<1){return null;} |
| 282 |
|
| 283 |
return new Sketch(ll.toArray(), il.size>0 ? il.toArray() : null, null, null, null, null); |
| 284 |
} |
| 285 |
|
| 286 |
public static final Sketch union(Sketch sa, Sketch sb){ |
| 287 |
Sketch shared=union(sa.keys, sb.keys, sa.keyCounts, sb.keyCounts, sa.baseCounts, sb.baseCounts, sa.r16S, sb.r16S, sa.r18S, sb.r18S); |
| 288 |
if(shared!=null){ |
| 289 |
shared.taxID=sa.taxID; |
| 290 |
shared.taxName=sa.taxName; |
| 291 |
shared.name0=sa.name0; |
| 292 |
shared.fname=sa.fname; |
| 293 |
shared.meta=sa.meta; |
| 294 |
shared.imgID=sa.imgID; |
| 295 |
shared.spid=sa.spid; |
| 296 |
} |
| 297 |
return shared; |
| 298 |
} |
| 299 |
|
| 300 |
public static final Sketch union(long[] a, long[] b, int[] aCounts, int[] bCounts, long[] aBaseCounts, long[] bBaseCounts, |
| 301 |
byte[] a16S, byte[] b16S, byte[] a18S, byte[] b18S){ |
| 302 |
int i=0, j=0, matches=0; |
| 303 |
LongList ll=new LongList(); |
| 304 |
IntList il=(aCounts==null || bCounts==null ? null : new IntList()); |
| 305 |
byte[] r16S=(b16S==null ? a16S : a16S==null ? b16S : a16S.length>b16S.length ? a16S : b16S); |
| 306 |
byte[] r18S=(b18S==null ? a18S : a18S==null ? b18S : a18S.length>b18S.length ? a18S : b18S); |
| 307 |
long[] baseCounts=(aBaseCounts==null || bBaseCounts==null ? null : new long[aBaseCounts.length]); |
| 308 |
if(baseCounts!=null){ |
| 309 |
for(int k=0; k<baseCounts.length; k++) {baseCounts[k]+=(aBaseCounts[k]+bBaseCounts[k]);} |
| 310 |
} |
| 311 |
for(; i<a.length && j<b.length; ){ |
| 312 |
final long ka=a[i], kb=b[j]; |
| 313 |
if(ka==kb){ |
| 314 |
matches++; |
| 315 |
ll.add(ka); |
| 316 |
if(il!=null){ |
| 317 |
il.add(aCounts[i]+bCounts[i]); |
| 318 |
} |
| 319 |
i++; |
| 320 |
j++; |
| 321 |
}else if(ka<kb){ |
| 322 |
ll.add(ka); |
| 323 |
if(il!=null){ |
| 324 |
il.add(aCounts[i]); |
| 325 |
} |
| 326 |
i++; |
| 327 |
}else{ |
| 328 |
ll.add(kb); |
| 329 |
if(il!=null){ |
| 330 |
il.add(bCounts[i]); |
| 331 |
} |
| 332 |
j++; |
| 333 |
} |
| 334 |
} |
| 335 |
if(matches<1){return null;} |
| 336 |
|
| 337 |
return new Sketch(ll.toArray(), il.size>0 ? il.toArray() : null, baseCounts, r16S, r18S, null); |
| 338 |
} |
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
boolean passesMeta(DisplayParams params) { |
| 345 |
return passesMeta(params.requiredMeta, params.bannedMeta, params.requiredMetaAnd); |
| 346 |
} |
| 347 |
|
| 348 |
boolean passesMeta(ArrayList<String> requiredMeta, ArrayList<String> bannedMeta, boolean requiredMetaAnd) { |
| 349 |
assert(requiredMeta!=null || bannedMeta!=null ); |
| 350 |
assert(requiredMeta==null || requiredMeta.size()>0); |
| 351 |
assert(bannedMeta==null || bannedMeta.size()>0); |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
if(requiredMeta!=null){ |
| 357 |
if(meta==null){return false;} |
| 358 |
for(String tag : requiredMeta){ |
| 359 |
if(meta.contains(tag)){ |
| 360 |
if(!requiredMetaAnd){break;} |
| 361 |
}else if(requiredMetaAnd){ |
| 362 |
return false; |
| 363 |
} |
| 364 |
} |
| 365 |
} |
| 366 |
if(bannedMeta!=null && meta!=null){ |
| 367 |
for(String tag : bannedMeta){ |
| 368 |
if(!meta.contains(tag)){ |
| 369 |
return false; |
| 370 |
} |
| 371 |
} |
| 372 |
} |
| 373 |
return true; |
| 374 |
} |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
public int countMatches(Sketch other, CompareBuffer buffer, AbstractBitSet present, boolean fillPresent, int[][] taxHits, int contamLevel){ |
| 381 |
return countMatches(keys, other.keys, keyCounts, other.keyCounts, refHitCounts, other.taxID, buffer, present, fillPresent, taxHits, contamLevel); |
| 382 |
} |
| 383 |
|
| 384 |
public static final int countMatches(long[] a, long[] b, int[] aCounts, int[] bCounts, int[] refHitCounts, int bid, |
| 385 |
CompareBuffer buffer, AbstractBitSet present, boolean fillPresent, int[][] taxHits, int contamLevel){ |
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
if(bid>0 && bid<minFakeID && taxHits!=null){ |
| 392 |
bid=taxtree.getIdAtLevelExtended(bid, contamLevel); |
| 393 |
}else{ |
| 394 |
bid=-1; |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
assert(a.length>0 && b.length>0); |
| 399 |
|
| 400 |
|
| 401 |
int matches=0; |
| 402 |
|
| 403 |
|
| 404 |
int multiMatches=0; |
| 405 |
|
| 406 |
|
| 407 |
int noHits=0; |
| 408 |
|
| 409 |
|
| 410 |
int contamHits=0; |
| 411 |
|
| 412 |
|
| 413 |
int sameTax=0; |
| 414 |
|
| 415 |
|
| 416 |
int unique2=0; |
| 417 |
|
| 418 |
|
| 419 |
int unique3_temp=0; |
| 420 |
|
| 421 |
|
| 422 |
int multiContamHits=0; |
| 423 |
|
| 424 |
|
| 425 |
long depthSum=0; |
| 426 |
|
| 427 |
|
| 428 |
double depthSum2=0; |
| 429 |
|
| 430 |
|
| 431 |
long refHitSum=0; |
| 432 |
|
| 433 |
|
| 434 |
int k1hits=0; |
| 435 |
|
| 436 |
|
| 437 |
int k1seenQ=0; |
| 438 |
|
| 439 |
|
| 440 |
int k1seenR=0; |
| 441 |
int i=0, j=0; |
| 442 |
assert(present==null || present.capacity()==a.length); |
| 443 |
|
| 444 |
if(present!=null){ |
| 445 |
if(fillPresent){ |
| 446 |
for(; i<a.length && j<b.length; ){ |
| 447 |
final long ka=a[i], kb=b[j]; |
| 448 |
final int bit=(int)(ka&1); |
| 449 |
if(ka==kb){ |
| 450 |
present.increment(i); |
| 451 |
matches++; |
| 452 |
k1hits+=bit; |
| 453 |
k1seenQ+=bit; |
| 454 |
k1seenR+=bit; |
| 455 |
if(aCounts!=null){ |
| 456 |
depthSum+=aCounts[i]; |
| 457 |
if(bCounts!=null){ |
| 458 |
depthSum2+=aCounts[i]/(double)bCounts[j]; |
| 459 |
} |
| 460 |
} |
| 461 |
if(refHitCounts!=null){refHitSum+=refHitCounts[i];} |
| 462 |
i++; |
| 463 |
j++; |
| 464 |
}else if(ka<kb){ |
| 465 |
i++; |
| 466 |
k1seenQ+=bit; |
| 467 |
}else{ |
| 468 |
j++; |
| 469 |
k1seenR+=bit; |
| 470 |
} |
| 471 |
} |
| 472 |
}else{ |
| 473 |
for(; i<a.length && j<b.length; ){ |
| 474 |
final long ka=a[i], kb=b[j]; |
| 475 |
final int bit=(int)(ka&1); |
| 476 |
if(ka==kb){ |
| 477 |
final int count=present.getCount(i); |
| 478 |
if(count>1){ |
| 479 |
multiMatches++; |
| 480 |
} |
| 481 |
|
| 482 |
matches++; |
| 483 |
k1hits+=bit; |
| 484 |
k1seenQ+=bit; |
| 485 |
k1seenR+=bit; |
| 486 |
if(aCounts!=null){ |
| 487 |
depthSum+=aCounts[i]; |
| 488 |
if(bCounts!=null){ |
| 489 |
depthSum2+=aCounts[i]/(double)bCounts[j]; |
| 490 |
} |
| 491 |
} |
| 492 |
if(refHitCounts!=null){refHitSum+=refHitCounts[i];} |
| 493 |
if(bid>0){ |
| 494 |
int[] taxHitsRow=taxHits[i]; |
| 495 |
if(taxHitsRow!=null && taxHitsRow.length==1 && taxHitsRow[0]==bid){unique2++;} |
| 496 |
} |
| 497 |
|
| 498 |
i++; |
| 499 |
j++; |
| 500 |
}else if(ka<kb){ |
| 501 |
k1seenQ+=bit; |
| 502 |
final int count=present.getCount(i); |
| 503 |
if(count>0){ |
| 504 |
contamHits++; |
| 505 |
if(count>1){ |
| 506 |
multiContamHits++; |
| 507 |
} |
| 508 |
}else{ |
| 509 |
noHits++; |
| 510 |
} |
| 511 |
|
| 512 |
if(bid>0){ |
| 513 |
int[] taxHitsRow=taxHits[i]; |
| 514 |
if(taxHitsRow!=null){ |
| 515 |
if(taxHitsRow!=null && taxHitsRow.length==1 && taxHitsRow[0]==bid){unique3_temp++;} |
| 516 |
for(int tid : taxHitsRow){ |
| 517 |
if(tid==bid){ |
| 518 |
sameTax++; |
| 519 |
break; |
| 520 |
} |
| 521 |
} |
| 522 |
} |
| 523 |
} |
| 524 |
|
| 525 |
i++; |
| 526 |
}else{ |
| 527 |
k1seenR+=bit; |
| 528 |
j++; |
| 529 |
} |
| 530 |
} |
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
if(bid>0 && i<a.length-1){ |
| 535 |
for(; i<a.length; i++){ |
| 536 |
int[] taxHitsRow=taxHits[i]; |
| 537 |
if(taxHitsRow!=null){ |
| 538 |
if(taxHitsRow!=null && taxHitsRow.length==1 && taxHitsRow[0]==bid){unique3_temp++;} |
| 539 |
} |
| 540 |
} |
| 541 |
} |
| 542 |
} |
| 543 |
}else{ |
| 544 |
for(; i<a.length && j<b.length; ){ |
| 545 |
final long ka=a[i], kb=b[j]; |
| 546 |
final int bit=(int)(ka&1); |
| 547 |
|
| 548 |
if(ka==kb){ |
| 549 |
matches++; |
| 550 |
k1hits+=bit; |
| 551 |
k1seenQ+=bit; |
| 552 |
k1seenR+=bit; |
| 553 |
if(aCounts!=null){depthSum+=aCounts[i];} |
| 554 |
if(refHitCounts!=null){refHitSum+=refHitCounts[i];} |
| 555 |
i++; |
| 556 |
j++; |
| 557 |
}else if(ka<kb){ |
| 558 |
i++; |
| 559 |
k1seenQ+=bit; |
| 560 |
}else{ |
| 561 |
j++; |
| 562 |
k1seenR+=bit; |
| 563 |
} |
| 564 |
} |
| 565 |
} |
| 566 |
|
| 567 |
if(k2<1){ |
| 568 |
k1hits=matches; |
| 569 |
k1seenQ=i; |
| 570 |
k1seenR=j; |
| 571 |
} |
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
if(buffer!=null){ |
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
buffer.set(matches, multiMatches, unique2, unique2+unique3_temp, noHits, |
| 585 |
contamHits, contamHits-sameTax, multiContamHits, i, j, |
| 586 |
a.length, b.length, depthSum, depthSum2, refHitSum, k1hits, k1seenQ, k1seenR); |
| 587 |
} |
| 588 |
return matches; |
| 589 |
} |
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
@Override |
| 602 |
public int hashCode(){ |
| 603 |
long gSize=genomeSizeKmers>0 ? genomeSizeKmers : genomeSizeBases; |
| 604 |
int code=(int) ((gSize^taxID^imgID^(name0==null ? 0 : name0.hashCode()))&Integer.MAX_VALUE); |
| 605 |
|
| 606 |
return code; |
| 607 |
} |
| 608 |
|
| 609 |
@Override |
| 610 |
public int compareTo(Sketch b){ |
| 611 |
if(this==b){return 0;} |
| 612 |
if(taxID>-1 && b.taxID>-1){return taxID-b.taxID;} |
| 613 |
int x=taxName.compareTo(b.taxName); |
| 614 |
if(x!=0){return x;} |
| 615 |
if(name0!=null && b.name0!=null){return name0.compareTo(b.name0);} |
| 616 |
return name0!=null ? 1 : b.name0!=null ? -1 : 0; |
| 617 |
} |
| 618 |
|
| 619 |
@Override |
| 620 |
public boolean equals(Object b){ |
| 621 |
if(this==b){return true;} |
| 622 |
if(b==null || this.getClass()!=b.getClass()){return false;} |
| 623 |
return equals((Sketch)b); |
| 624 |
} |
| 625 |
|
| 626 |
public boolean equals(Sketch b){ |
| 627 |
return compareTo(b)==0; |
| 628 |
} |
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
public ByteBuilder toHeader(){ |
| 635 |
ByteBuilder sb=new ByteBuilder(); |
| 636 |
return toHeader(sb); |
| 637 |
} |
| 638 |
|
| 639 |
public ByteBuilder toHeader(ByteBuilder bb){ |
| 640 |
bb.append("#SZ:").append(keys.length); |
| 641 |
bb.append("\tCD:"); |
| 642 |
bb.append(codingArray[CODING]); |
| 643 |
if(deltaOut){bb.append('D');} |
| 644 |
if(keyCounts!=null){bb.append('C');} |
| 645 |
if(aminoOrTranslate()){bb.append('M');} |
| 646 |
if(amino8){bb.append('8');} |
| 647 |
|
| 648 |
bb.append("\tK:").append(k); |
| 649 |
if(k2!=0){bb.append(",").append(k2);} |
| 650 |
if(HASH_VERSION>1){bb.append("\tH:").append(HASH_VERSION);} |
| 651 |
|
| 652 |
|
| 653 |
if(genomeSizeBases>0){bb.append("\tGS:").append(genomeSizeBases);} |
| 654 |
if(genomeSizeKmers>0){bb.append("\tGK:").append(genomeSizeKmers);} |
| 655 |
final long ge=genomeSizeEstimate(); |
| 656 |
if(ge>0){bb.append("\tGE:").append(ge);} |
| 657 |
if(genomeSequences>0){bb.append("\tGQ:"+genomeSequences);} |
| 658 |
if(baseCounts!=null && !aminoOrTranslate()){ |
| 659 |
bb.append("\tBC:").append(baseCounts[0]).append(',').append(baseCounts[1]).append(','); |
| 660 |
bb.append(baseCounts[2]).append(',').append(baseCounts[3]); |
| 661 |
} |
| 662 |
if(probCorrect>0){bb.append("\tPC:"+Tools.format("%.4f", probCorrect));} |
| 663 |
if(taxID>=0){bb.append("\tID:").append(taxID);} |
| 664 |
if(imgID>=0){bb.append("\tIMG:").append(imgID);} |
| 665 |
if(spid>0){bb.append("\tSPID:").append(spid);} |
| 666 |
if(fname!=null){bb.append("\tFN:").append(fname);} |
| 667 |
if(taxName!=null){bb.append("\tNM:").append(taxName);} |
| 668 |
if(name0!=null){bb.append("\tNM0:").append(name0);} |
| 669 |
if(meta!=null){ |
| 670 |
for(String s : meta){ |
| 671 |
bb.append("\tMT_").append(s); |
| 672 |
} |
| 673 |
} |
| 674 |
|
| 675 |
if(r16S!=null){ |
| 676 |
bb.append("\t16S:").append(r16S.length); |
| 677 |
} |
| 678 |
if(r18S!=null){ |
| 679 |
bb.append("\t18S:").append(r18S.length); |
| 680 |
} |
| 681 |
if(r16S!=null){ |
| 682 |
bb.append('\n'); |
| 683 |
bb.append("#16S:").append(r16S); |
| 684 |
} |
| 685 |
if(r18S!=null){ |
| 686 |
bb.append('\n'); |
| 687 |
bb.append("#18S:").append(r18S); |
| 688 |
} |
| 689 |
return bb; |
| 690 |
} |
| 691 |
|
| 692 |
public ByteBuilder toBytes(){ |
| 693 |
return toBytes(new ByteBuilder()); |
| 694 |
} |
| 695 |
|
| 696 |
public ByteBuilder toBytes(ByteBuilder bb){ |
| 697 |
if(CODING==A48 && deltaOut){return toBytesA48D(bb);} |
| 698 |
long prev=0; |
| 699 |
toHeader(bb); |
| 700 |
bb.append("\n"); |
| 701 |
byte[] temp=null; |
| 702 |
if(CODING==A48){temp=KillSwitch.allocByte1D(12);} |
| 703 |
for(int i=0; i<keys.length; i++){ |
| 704 |
long key=keys[i]; |
| 705 |
int count=(keyCounts==null ? 1 : keyCounts[i]); |
| 706 |
long x=key-prev; |
| 707 |
if(CODING==A48){ |
| 708 |
appendA48(x, bb, temp); |
| 709 |
if(count>1){ |
| 710 |
bb.append('\t'); |
| 711 |
appendA48(count-1, bb, temp); |
| 712 |
} |
| 713 |
bb.append('\n'); |
| 714 |
}else if(CODING==HEX){ |
| 715 |
bb.append(Long.toHexString(x)).append('\n'); |
| 716 |
}else if(CODING==RAW){ |
| 717 |
bb.append(x).append('\n'); |
| 718 |
}else{ |
| 719 |
assert(false); |
| 720 |
} |
| 721 |
if(deltaOut){prev=key;} |
| 722 |
} |
| 723 |
return bb; |
| 724 |
} |
| 725 |
|
| 726 |
|
| 727 |
private ByteBuilder toBytesA48D(ByteBuilder bb){ |
| 728 |
assert(CODING==A48 && deltaOut); |
| 729 |
long prev=0; |
| 730 |
toHeader(bb); |
| 731 |
bb.append("\n"); |
| 732 |
final byte[] temp=KillSwitch.allocByte1D(12); |
| 733 |
|
| 734 |
if(keyCounts==null){ |
| 735 |
for(int i=0; i<keys.length; i++){ |
| 736 |
long key=keys[i]; |
| 737 |
long x=key-prev; |
| 738 |
if(CODING==A48){ |
| 739 |
appendA48(x, bb, temp); |
| 740 |
bb.append('\n'); |
| 741 |
} |
| 742 |
prev=key; |
| 743 |
} |
| 744 |
}else{ |
| 745 |
for(int i=0; i<keys.length; i++){ |
| 746 |
long key=keys[i]; |
| 747 |
int count=keyCounts[i]; |
| 748 |
long x=key-prev; |
| 749 |
if(CODING==A48){ |
| 750 |
appendA48(x, bb, temp); |
| 751 |
if(count>1){ |
| 752 |
bb.append('\t'); |
| 753 |
appendA48(count-1, bb, temp); |
| 754 |
} |
| 755 |
bb.append('\n'); |
| 756 |
} |
| 757 |
prev=key; |
| 758 |
} |
| 759 |
} |
| 760 |
return bb; |
| 761 |
} |
| 762 |
|
| 763 |
public static final void appendA48(long value, ByteBuilder bb, byte[] temp){ |
| 764 |
int i=0; |
| 765 |
|
| 766 |
while(value!=0){ |
| 767 |
byte b=(byte)(value&0x3F); |
| 768 |
|
| 769 |
temp[i]=b; |
| 770 |
value=value>>6; |
| 771 |
i++; |
| 772 |
} |
| 773 |
if(i==0){ |
| 774 |
bb.append((byte)'0'); |
| 775 |
}else{ |
| 776 |
for(i--;i>=0;i--){ |
| 777 |
bb.append((char)(temp[i]+48)); |
| 778 |
} |
| 779 |
} |
| 780 |
} |
| 781 |
|
| 782 |
public static final String toA48(long value){ |
| 783 |
int i=0; |
| 784 |
|
| 785 |
StringBuilder sb=new StringBuilder(12); |
| 786 |
while(value!=0){ |
| 787 |
byte b=(byte)(value&0x3F); |
| 788 |
|
| 789 |
sb.append((char)(b+48)); |
| 790 |
value=value>>6; |
| 791 |
i++; |
| 792 |
} |
| 793 |
if(i==0){ |
| 794 |
sb.append((byte)'0'); |
| 795 |
}else{ |
| 796 |
sb.reverse(); |
| 797 |
} |
| 798 |
return sb.toString(); |
| 799 |
} |
| 800 |
|
| 801 |
@Override |
| 802 |
public String toString(){ |
| 803 |
return toBytes().toString(); |
| 804 |
} |
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
public static long parseA48(String line){ |
| 811 |
if(line.length()==0){return 0;} |
| 812 |
long x=0; |
| 813 |
for(int i=0; i<line.length(); i++){ |
| 814 |
x<<=6; |
| 815 |
long c=line.charAt(i); |
| 816 |
x|=(c-48); |
| 817 |
} |
| 818 |
return x; |
| 819 |
} |
| 820 |
|
| 821 |
|
| 822 |
public static long parseA48C(String line, IntList covList){ |
| 823 |
if(line.length()==0){ |
| 824 |
covList.add(1); |
| 825 |
return 0; |
| 826 |
} |
| 827 |
long key=0, cov=0; |
| 828 |
int i=0, len=line.length(); |
| 829 |
for(; i<len; i++){ |
| 830 |
long c=line.charAt(i); |
| 831 |
if(c<48){break;} |
| 832 |
key<<=6; |
| 833 |
key|=(c-48); |
| 834 |
} |
| 835 |
for(i++; i<len; i++){ |
| 836 |
long c=line.charAt(i); |
| 837 |
cov<<=6; |
| 838 |
cov|=(c-48); |
| 839 |
} |
| 840 |
covList.add((int)(cov+1)); |
| 841 |
return key; |
| 842 |
} |
| 843 |
|
| 844 |
public static long parseHex(String line){ |
| 845 |
if(line.length()==0){return 0;} |
| 846 |
long x=0; |
| 847 |
for(int i=0; i<line.length(); i++){ |
| 848 |
x<<=4; |
| 849 |
x|=hexTable[line.charAt(i)]; |
| 850 |
} |
| 851 |
if(line.charAt(0)=='-'){x*=-1;} |
| 852 |
return x; |
| 853 |
} |
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
public static long parseA48(byte[] line){ |
| 860 |
if(line.length==0){return 0;} |
| 861 |
long x=0; |
| 862 |
for(byte b : line){ |
| 863 |
x<<=6; |
| 864 |
x|=(((long)b)-48); |
| 865 |
} |
| 866 |
return x; |
| 867 |
} |
| 868 |
|
| 869 |
public static long parseNuc(String line){ |
| 870 |
return parseNuc(line.getBytes()); |
| 871 |
} |
| 872 |
|
| 873 |
|
| 874 |
public static long parseNuc(byte[] bases){ |
| 875 |
if(bases.length<k){return -1;} |
| 876 |
final int shift=2*k; |
| 877 |
final int shift2=shift-2; |
| 878 |
final long mask=(shift>63 ? -1L : ~((-1L)<<shift)); |
| 879 |
|
| 880 |
long kmer=0, rkmer=0; |
| 881 |
int len=0; |
| 882 |
|
| 883 |
long key=-1; |
| 884 |
for(int i=0; i<bases.length; i++){ |
| 885 |
byte b=bases[i]; |
| 886 |
long x=AminoAcid.baseToNumber[b]; |
| 887 |
long x2=AminoAcid.baseToComplementNumber[b]; |
| 888 |
kmer=((kmer<<2)|x)&mask; |
| 889 |
rkmer=((rkmer>>>2)|(x2<<shift2))&mask; |
| 890 |
if(x<0){len=0; rkmer=0;}else{len++;} |
| 891 |
if(len>=k){ |
| 892 |
|
| 893 |
final long hashcode=hash(kmer, rkmer); |
| 894 |
key=Tools.max(key, hashcode); |
| 895 |
} |
| 896 |
} |
| 897 |
return key<minHashValue ? -1 : Long.MAX_VALUE-key; |
| 898 |
} |
| 899 |
|
| 900 |
|
| 901 |
public static long parseA48C(byte[] line, IntList covList){ |
| 902 |
if(line.length==0){ |
| 903 |
covList.add(1); |
| 904 |
return 0; |
| 905 |
} |
| 906 |
long key=0, cov=0; |
| 907 |
int i=0, len=line.length; |
| 908 |
for(; i<len; i++){ |
| 909 |
long b=line[i]; |
| 910 |
if(b<48){break;} |
| 911 |
key<<=6; |
| 912 |
key|=(b-48); |
| 913 |
} |
| 914 |
for(i++; i<len; i++){ |
| 915 |
long b=line[i]; |
| 916 |
cov<<=6; |
| 917 |
cov|=(b-48); |
| 918 |
} |
| 919 |
covList.add((int)(cov+1)); |
| 920 |
return key; |
| 921 |
} |
| 922 |
|
| 923 |
public static long parseHex(byte[] line){ |
| 924 |
if(line.length==0){return 0;} |
| 925 |
long x=0; |
| 926 |
for(byte b : line){ |
| 927 |
x<<=4; |
| 928 |
x|=hexTable[b]; |
| 929 |
} |
| 930 |
if(line[0]=='-'){x*=-1;} |
| 931 |
return x; |
| 932 |
} |
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
public static long parseA48(ByteBuilder bb){ |
| 939 |
final int len=bb.length; |
| 940 |
final byte[] line=bb.array; |
| 941 |
if(len==0){return 0;} |
| 942 |
long x=0; |
| 943 |
for(int i=0; i<len; i++){ |
| 944 |
x<<=6; |
| 945 |
x|=(((long)line[i])-48); |
| 946 |
} |
| 947 |
return x; |
| 948 |
} |
| 949 |
|
| 950 |
public static long parseNuc(ByteBuilder bb){ |
| 951 |
return parseNuc(bb.toBytes()); |
| 952 |
} |
| 953 |
|
| 954 |
|
| 955 |
public static long parseA48C(ByteBuilder bb, IntList covList){ |
| 956 |
final int len=bb.length; |
| 957 |
final byte[] line=bb.array; |
| 958 |
if(len==0){ |
| 959 |
covList.add(1); |
| 960 |
return 0; |
| 961 |
} |
| 962 |
long key=0, cov=0; |
| 963 |
int i=0; |
| 964 |
for(; i<len; i++){ |
| 965 |
long b=line[i]; |
| 966 |
if(b<48){break;} |
| 967 |
key<<=6; |
| 968 |
key|=(b-48); |
| 969 |
} |
| 970 |
for(i++; i<len; i++){ |
| 971 |
long b=line[i]; |
| 972 |
cov<<=6; |
| 973 |
cov|=(b-48); |
| 974 |
} |
| 975 |
covList.add((int)(cov+1)); |
| 976 |
return key; |
| 977 |
} |
| 978 |
|
| 979 |
public static long parseHex(ByteBuilder bb){ |
| 980 |
final int len=bb.length; |
| 981 |
final byte[] line=bb.array; |
| 982 |
if(line.length==0){return 0;} |
| 983 |
long x=0; |
| 984 |
for(int i=0; i<len; i++){ |
| 985 |
x<<=4; |
| 986 |
x|=hexTable[line[i]]; |
| 987 |
} |
| 988 |
if(line[0]=='-'){x*=-1;} |
| 989 |
return x; |
| 990 |
} |
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
public long genomeSizeEstimate() { |
| 997 |
return keys.length==0 ? 0 : Tools.min(genomeSizeKmers, genomeSizeEstimate(keys[keys.length-1], keys.length)); |
| 998 |
} |
| 999 |
|
| 1000 |
public long genomeSizeEstimate(int minCount) { |
| 1001 |
if(minCount<2){return genomeSizeEstimate();} |
| 1002 |
if(length()==0){return 0;} |
| 1003 |
long max=0; |
| 1004 |
int num=0; |
| 1005 |
for(int i=0; i<keyCounts.length; i++){ |
| 1006 |
if(keyCounts[i]>=minCount){ |
| 1007 |
max=keys[i]; |
| 1008 |
num++; |
| 1009 |
} |
| 1010 |
} |
| 1011 |
if(max==0){return 0;} |
| 1012 |
long est=Tools.min(genomeSizeKmers, SketchObject.genomeSizeEstimate(max, num)); |
| 1013 |
return est; |
| 1014 |
} |
| 1015 |
|
| 1016 |
public float gc(){ |
| 1017 |
if(baseCounts==null){return 0;} |
| 1018 |
long at=baseCounts[0]+baseCounts[3]; |
| 1019 |
long gc=baseCounts[1]+baseCounts[2]; |
| 1020 |
return gc/(Tools.max(1.0f, at+gc)); |
| 1021 |
} |
| 1022 |
|
| 1023 |
public String filePrefix(){return ReadWrite.stripToCore(fname);} |
| 1024 |
public String name(){return taxName!=null ? taxName : name0!=null ? name0 : fname;} |
| 1025 |
public String taxName(){return taxName;} |
| 1026 |
public String name0(){return name0;} |
| 1027 |
public String fname(){return fname;} |
| 1028 |
public int length(){return keys.length;} |
| 1029 |
public void setTaxName(String s){taxName=s;} |
| 1030 |
public void setName0(String s){name0=s;} |
| 1031 |
public void setFname(String s){ |
| 1032 |
|
| 1033 |
fname=(s==null ? s : ReadWrite.stripPath(s)); |
| 1034 |
} |
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
public ArrayList<LongPair> toKhist() { |
| 1043 |
HashMap<Long, LongPair> map=new HashMap<Long, LongPair>(); |
| 1044 |
for(int i=0; i<keyCounts.length; i++){ |
| 1045 |
int a=keyCounts[i]; |
| 1046 |
Long key=(long)a; |
| 1047 |
LongPair value=map.get(key); |
| 1048 |
if(value==null){ |
| 1049 |
value=new LongPair(); |
| 1050 |
value.a=a; |
| 1051 |
map.put(key, value); |
| 1052 |
} |
| 1053 |
value.b++; |
| 1054 |
} |
| 1055 |
ArrayList<LongPair> list=new ArrayList<LongPair>(map.size()); |
| 1056 |
list.addAll(map.values()); |
| 1057 |
Collections.sort(list); |
| 1058 |
return list; |
| 1059 |
} |
| 1060 |
|
| 1061 |
|
| 1062 |
public void addSSU(){ |
| 1063 |
if(useSSUMapOnly){r16S=r18S=null;} |
| 1064 |
if(taxID<1 || taxID>=minFakeID){return;} |
| 1065 |
if(!SSUMap.hasMap()){return;} |
| 1066 |
if(taxtree==null){ |
| 1067 |
|
| 1068 |
|
| 1069 |
assert(false) : "Please set a path to the taxtree when adding SSUs."; |
| 1070 |
} |
| 1071 |
final boolean euk=taxtree!=null && (preferSSUMapForEuks || useSSUMapOnlyForEuks || ban16SForEuks) ? taxtree.isEukaryote(taxID) : false; |
| 1072 |
final boolean prok=taxtree!=null && ban18SForProks ? taxtree.isProkaryote(taxID) : false; |
| 1073 |
|
| 1074 |
final boolean mapOnly=(useSSUMapOnly || (useSSUMapOnlyForEuks && euk)); |
| 1075 |
final boolean preferMap=(mapOnly || preferSSUMap || (preferSSUMapForEuks && euk)); |
| 1076 |
if(mapOnly){r16S=r18S=null;} |
| 1077 |
|
| 1078 |
if(SSUMap.r16SMap!=null && (r16S==null || preferMap)){ |
| 1079 |
byte[] x=SSUMap.r16SMap.get(taxID); |
| 1080 |
if(x!=null){r16S=x;} |
| 1081 |
} |
| 1082 |
if(SSUMap.r18SMap!=null && (r18S==null || preferMap)){ |
| 1083 |
byte[] x=SSUMap.r18SMap.get(taxID); |
| 1084 |
if(x!=null){r18S=x;} |
| 1085 |
} |
| 1086 |
if(ban18SForProks && prok){r18S=null;} |
| 1087 |
if(ban16SForEuks && euk){r16S=null;} |
| 1088 |
} |
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
public void makeBitSets(boolean printContam, boolean index){ |
| 1095 |
assert(compareBitSet==null && indexBitSet==null); |
| 1096 |
if(!printContam){return;} |
| 1097 |
compareBitSet=AbstractBitSet.make(length(), bitSetBits); |
| 1098 |
if(index){indexBitSet=AbstractBitSet.make(length(), bitSetBits);} |
| 1099 |
} |
| 1100 |
|
| 1101 |
public void addToBitSet(AbstractBitSet rbs){ |
| 1102 |
compareBitSet.add(rbs); |
| 1103 |
} |
| 1104 |
|
| 1105 |
public AbstractBitSet compareBitSet(){return compareBitSet;} |
| 1106 |
|
| 1107 |
public AbstractBitSet indexBitSet(){return indexBitSet;} |
| 1108 |
|
| 1109 |
public void mergeBitSets(){ |
| 1110 |
assert(!mergedBitSets); |
| 1111 |
if(compareBitSet!=null && indexBitSet!=null){ |
| 1112 |
compareBitSet.setToMax(indexBitSet); |
| 1113 |
} |
| 1114 |
indexBitSet=null; |
| 1115 |
mergedBitSets=true; |
| 1116 |
} |
| 1117 |
|
| 1118 |
public boolean merged(){return mergedBitSets;} |
| 1119 |
|
| 1120 |
public int r16SLen(){return r16S==null ? 0 : r16S.length;} |
| 1121 |
public int r18SLen(){return r18S==null ? 0 : r18S.length;} |
| 1122 |
public byte[] r16S(){return r16S;} |
| 1123 |
public byte[] r18S(){return r18S;} |
| 1124 |
public boolean hasSSU(){return r16S!=null || r18S!=null;} |
| 1125 |
public boolean sharesSSU(Sketch b){ |
| 1126 |
return (r16S!=null && b.r16S!=null) || (r18S!=null && b.r18S!=null); |
| 1127 |
} |
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
public long[] keys; |
| 1135 |
|
| 1136 |
public int[] keyCounts; |
| 1137 |
|
| 1138 |
final long[] baseCounts; |
| 1139 |
private byte[] r16S; |
| 1140 |
private byte[] r18S; |
| 1141 |
public int taxID; |
| 1142 |
public int maxCount; |
| 1143 |
int sketchID; |
| 1144 |
public final long genomeSequences; |
| 1145 |
public final long genomeSizeBases; |
| 1146 |
public final long genomeSizeKmers; |
| 1147 |
public final float probCorrect; |
| 1148 |
|
| 1149 |
private String taxName; |
| 1150 |
private String name0; |
| 1151 |
private String fname; |
| 1152 |
ArrayList<String> meta; |
| 1153 |
|
| 1154 |
|
| 1155 |
private AbstractBitSet compareBitSet; |
| 1156 |
private AbstractBitSet indexBitSet; |
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
public long imgID=-1; |
| 1161 |
public long spid=-1; |
| 1162 |
|
| 1163 |
|
| 1164 |
private boolean mergedBitSets=false; |
| 1165 |
|
| 1166 |
|
| 1167 |
private int[] refHitCounts; |
| 1168 |
|
| 1169 |
public int[] refHitCounts(){return refHitCounts;} |
| 1170 |
public void clearRefHitCounts(){ |
| 1171 |
refHitCounts=null; |
| 1172 |
} |
| 1173 |
public void setRefHitCounts(int[] x) { |
| 1174 |
refHitCounts=x; |
| 1175 |
assert(x!=null); |
| 1176 |
} |
| 1177 |
|
| 1178 |
private static AtomicInteger nextSketch=new AtomicInteger(1); |
| 1179 |
|
| 1180 |
} |