// Path: src/main/java/edu/umd/marbl/mhap/impl/MhapRuntimeException.java
// public class MhapRuntimeException extends RuntimeException
// {
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 56387323839744808L;
// 
// 	public MhapRuntimeException()
// 	{
// 		super();
// 	}
// 
// 	public MhapRuntimeException(String message, Throwable cause)
// 	{
// 		super(message, cause);
// 	}
// 
// 	public MhapRuntimeException(String message)
// 	{
// 		super(message);
// 	}
// 
// 	public MhapRuntimeException(Throwable cause)
// 	{
// 		super(cause);
// 	}
// 
// 	
// }


import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import com.google.common.hash.BloomFilter;
import edu.umd.marbl.mhap.impl.MhapRuntimeException;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
import java.io.BufferedReader;
import java.io.IOException;
/* 
 * MHAP package
 * 
 * This  software is distributed "as is", without any warranty, including 
 * any implied warranty of merchantability or fitness for a particular
 * use. The authors assume no responsibility for, and shall not be liable
 * for, any special, indirect, or consequential damages, or any damages
 * whatsoever, arising out of or in connection with the use of this
 * software.
 * 
 * Copyright (c) 2015 by Konstantin Berlin and Sergey Koren
 * 
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package edu.umd.marbl.mhap.sketch;




public final class FrequencyCounts
{
	private final double filterCutoff;
	private final Map<Long,Double> fractionCounts;
	private final Set<Integer> kmerSizes;
	private final double maxIdfValue;
	private final double maxValue;
	private final double minIdfValue;
	private final double minValue;
	private final boolean noTf;
	private final double offset;
	private final double range;
	private final int removeUnique;
	private final BloomFilter<Long> validMers;
	
	public FrequencyCounts(BufferedReader bf, double filterCutoff, double offset, int removeUnique, boolean noTf, int numThreads, double range, boolean doReverseCompliment) throws IOException
	{
		//removeUnique = 0: do nothing extra to k-mers not specified in the file
		//removeUnique = 1: remove k-mers not specified in the file from the sketch
		//removeUnique = 2: supress k-mers not specified in the file the same as max supression
		
		this.range = range;
		
		if (removeUnique<0 || removeUnique>2)
// Path: src/main/java/edu/umd/marbl/mhap/impl/MhapRuntimeException.java
// public class MhapRuntimeException extends RuntimeException
// {
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 56387323839744808L;
// 
// 	public MhapRuntimeException()
// 	{
// 		super();
// 	}
// 
// 	public MhapRuntimeException(String message, Throwable cause)
// 	{
// 		super(message, cause);
// 	}
// 
// 	public MhapRuntimeException(String message)
// 	{
// 		super(message);
// 	}
// 
// 	public MhapRuntimeException(Throwable cause)
// 	{
// 		super(cause);
// 	}
// 
// 	
// }


// Path: src/main/java/edu/umd/marbl/mhap/sketch/FrequencyCounts.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import com.google.common.hash.BloomFilter;
import edu.umd.marbl.mhap.impl.MhapRuntimeException;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
import java.io.BufferedReader;
import java.io.IOException;

/* 
 * MHAP package
 * 
 * This  software is distributed "as is", without any warranty, including 
 * any implied warranty of merchantability or fitness for a particular
 * use. The authors assume no responsibility for, and shall not be liable
 * for, any special, indirect, or consequential damages, or any damages
 * whatsoever, arising out of or in connection with the use of this
 * software.
 * 
 * Copyright (c) 2015 by Konstantin Berlin and Sergey Koren
 * 
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package edu.umd.marbl.mhap.sketch;




public final class FrequencyCounts
{
	private final double filterCutoff;
	private final Map<Long,Double> fractionCounts;
	private final Set<Integer> kmerSizes;
	private final double maxIdfValue;
	private final double maxValue;
	private final double minIdfValue;
	private final double minValue;
	private final boolean noTf;
	private final double offset;
	private final double range;
	private final int removeUnique;
	private final BloomFilter<Long> validMers;
	
	public FrequencyCounts(BufferedReader bf, double filterCutoff, double offset, int removeUnique, boolean noTf, int numThreads, double range, boolean doReverseCompliment) throws IOException
	{
		//removeUnique = 0: do nothing extra to k-mers not specified in the file
		//removeUnique = 1: remove k-mers not specified in the file from the sketch
		//removeUnique = 2: supress k-mers not specified in the file the same as max supression
		
		this.range = range;
		
		if (removeUnique<0 || removeUnique>2)
			throw new MhapRuntimeException("Unknown removeUnique option "+removeUnique+".");