File: Whitelist.java

package info (click to toggle)
bbmap 39.20%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,024 kB
  • sloc: java: 312,743; sh: 18,099; python: 5,247; ansic: 2,074; perl: 96; makefile: 39; xml: 38
file content (46 lines) | stat: -rwxr-xr-x 1,096 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package sketch;

import kmer.AbstractKmerTable;
import structures.LongList;

public class Whitelist {

	public static void initialize(AbstractKmerTable[] tableArray){
		assert(keySets==null);
		keySets=tableArray;
	}
	
	public static void apply(Sketch s){
		assert(exists());
		LongList list=new LongList(s.keys.length);
		for(long key : s.keys){
			if(contains(key)){
				list.add(key);
			}
		}
		if(list.size()!=s.keys.length){
			s.keys=list.toArray();
		}
	}
	
	/** Hashed value from an actual sketch */
	public static boolean contains(long key){
		if(keySets==null){return true;}
		int way=(int)(key%ways);
		return keySets[way].getValue(key)>0;
	}
	
	/** Raw hashed value which has not yet been subtracted from Long.MAX_VALUE */
	public static boolean containsRaw(long key){
		return contains(Long.MAX_VALUE-key);
	}
	
	public static boolean exists(){
		return keySets!=null;
	}
	
	/** Hold codes.  A code X such that X%WAYS=Y will be stored in keySets[Y] */
	private static AbstractKmerTable[] keySets;
	private static final int ways=31;
	
}