Skip to content

Commit

Permalink
Read two values on startup, low-copy and repeat size separately
Browse files Browse the repository at this point in the history
  • Loading branch information
skoren committed Oct 5, 2017
1 parent 35694d2 commit c634a7b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main/java/edu/umd/marbl/mhap/sketch/FrequencyCounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,34 @@ public FrequencyCounts(BufferedReader bf, double filterCutoff, double offset, in
String line = bf.readLine();
try
{
long size;
long sizeBloom;
long sizeRepeat;
if (line==null)
{
System.err.println("Warning, k-mer filter file is empty. Assuming zero entries.");
size = 1L;
sizeBloom = sizeRepeat = 1L;
}
else
{
size = Long.parseLong(line);
// we assume the line has two entries, the first is the size of the bloom filter, the second is the size of the filter set
String[] splitLine = line.trim().split("\\s+");
sizeBloom = Long.parseLong(splitLine[0]);
sizeRepeat = Long.parseLong(splitLine[1]);
System.err.println("Read in values for repeat " + sizeRepeat + " and " + sizeBloom);

if (size<0L)
if (sizeBloom<0L || sizeRepeat <0L)
throw new MhapRuntimeException("K-mer filter file size line must have positive long value.");
else
if (size==0L)
if (sizeBloom==0L)
{
System.err.println("Warning, k-mer filter file has zero elements.");
size = 1L;
sizeBloom = 1L;
}
}

System.err.println("Initializing");
Long2DoubleOpenHashMap tempMap = null;
for (long i = size; i > 0; i /= 2) {
for (long i = sizeRepeat; i > 0; i /= 2) {
try {
System.err.print("Trying size " + i);
tempMap = new Long2DoubleOpenHashMap((int)(i));
Expand All @@ -129,7 +134,7 @@ public FrequencyCounts(BufferedReader bf, double filterCutoff, double offset, in

//if no nothing, no need to store the while list
if (removeUnique>0)
validMers = BloomFilter.create((value, sink) -> sink.putLong(value), size, 1.0e-5);
validMers = BloomFilter.create((value, sink) -> sink.putLong(value), sizeBloom, 1.0e-5);
else
validMers = null;
}
Expand Down

0 comments on commit c634a7b

Please sign in to comment.