// Path: src/main/java/edu/umd/marbl/mhap/utils/HitCounter.java
// public final class HitCounter
// {
// 	public int count;
// 
// 	public HitCounter()
// 	{
// 		this.count = 0;
// 	}
// 	
// 	public HitCounter(int count)
// 	{
// 		this.count = count;
// 	}
// 
// 	public HitCounter addHit()
// 	{
// 		this.count++;
// 		return this;
// 	}
// 	
// 	public void addHits(int counts)
// 	{
// 		this.count+=counts;
// 	}
// }


import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Map.Entry;
import edu.umd.marbl.mhap.utils.HitCounter;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
/* 
 * 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) 2014 by Konstantin Berlin and Sergey Koren
 * University Of Maryland
 * 
 * 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 MinHashSketch implements Sketch<MinHashSketch>
{
	private final int[] minHashes;
	/**
	 * 
	 */
	private static final long serialVersionUID = 8846482698636860862L;
	
	private final static int[] computeNgramMinHashesWeighted(String seq, final int nGramSize, final int numHashes,
			FrequencyCounts kmerFilter, boolean doReverseCompliment, double repeatWeight) throws ZeroNGramsFoundException
	{
		final int numberNGrams = seq.length() - nGramSize + 1;
	
		if (numberNGrams < 1)
			throw new ZeroNGramsFoundException("N-gram size bigger than string length.", seq);
	
		//if (repeatWeight>=1.0)
		//	throw new SketchRuntimeException("repeatWeight cannot be >=1.");

		// get the kmer hashes
		final long[] kmerHashes = HashUtils.computeSequenceHashesLong(seq, nGramSize, 0, doReverseCompliment);
		
		//now compute the counts of occurance
// Path: src/main/java/edu/umd/marbl/mhap/utils/HitCounter.java
// public final class HitCounter
// {
// 	public int count;
// 
// 	public HitCounter()
// 	{
// 		this.count = 0;
// 	}
// 	
// 	public HitCounter(int count)
// 	{
// 		this.count = count;
// 	}
// 
// 	public HitCounter addHit()
// 	{
// 		this.count++;
// 		return this;
// 	}
// 	
// 	public void addHits(int counts)
// 	{
// 		this.count+=counts;
// 	}
// }


// Path: src/main/java/edu/umd/marbl/mhap/sketch/MinHashSketch.java
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Map.Entry;
import edu.umd.marbl.mhap.utils.HitCounter;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;

/* 
 * 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) 2014 by Konstantin Berlin and Sergey Koren
 * University Of Maryland
 * 
 * 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 MinHashSketch implements Sketch<MinHashSketch>
{
	private final int[] minHashes;
	/**
	 * 
	 */
	private static final long serialVersionUID = 8846482698636860862L;
	
	private final static int[] computeNgramMinHashesWeighted(String seq, final int nGramSize, final int numHashes,
			FrequencyCounts kmerFilter, boolean doReverseCompliment, double repeatWeight) throws ZeroNGramsFoundException
	{
		final int numberNGrams = seq.length() - nGramSize + 1;
	
		if (numberNGrams < 1)
			throw new ZeroNGramsFoundException("N-gram size bigger than string length.", seq);
	
		//if (repeatWeight>=1.0)
		//	throw new SketchRuntimeException("repeatWeight cannot be >=1.");

		// get the kmer hashes
		final long[] kmerHashes = HashUtils.computeSequenceHashesLong(seq, nGramSize, 0, doReverseCompliment);
		
		//now compute the counts of occurance
		Long2ObjectLinkedOpenHashMap<HitCounter> hitMap = new Long2ObjectLinkedOpenHashMap<HitCounter>(kmerHashes.length);