[med-svn] [kmc] 08/15: Imported Upstream version 2.2

Sascha Steinbiss sascha-guest at moszumanska.debian.org
Mon Aug 24 21:25:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

sascha-guest pushed a commit to branch master
in repository kmc.

commit 2169066fe7c2a49884068bf75fa455d0c3d72746
Author: Sascha Steinbiss <sascha at steinbiss.name>
Date:   Mon Aug 24 19:23:50 2015 +0000

    Imported Upstream version 2.2
---
 API.pdf                             | Bin 0 -> 220319 bytes
 README.md                           |   1 +
 kmc_api/kmc_file.cpp                | 771 ++++++++++++++++++++++++++++--------
 kmc_api/kmc_file.h                  |  23 +-
 kmc_api/kmer_api.cpp                |  29 +-
 kmc_api/kmer_api.h                  | 612 +++++++++++++++-------------
 kmc_api/kmer_defs.h                 |   8 +-
 kmc_api/mmer.cpp                    |   4 +-
 kmc_api/mmer.h                      |   8 +-
 kmc_dump/kmc_dump.cpp               |  45 ++-
 kmc_dump/nc_utils.cpp               |   4 +-
 kmc_dump/nc_utils.h                 |   4 +-
 kmc_dump_sample/kmc_dump_sample.cpp |  33 +-
 kmer_counter.sln                    |   2 +-
 kmer_counter/asmlib_wrapper.h       |   4 +-
 kmer_counter/bkb_merger.h           |   4 +-
 kmer_counter/bkb_reader.cpp         |   4 +-
 kmer_counter/bkb_reader.h           |   4 +-
 kmer_counter/bkb_sorter.h           |   4 +-
 kmer_counter/bkb_subbin.h           |   4 +-
 kmer_counter/bkb_uncompactor.h      |   4 +-
 kmer_counter/bkb_writer.cpp         |   4 +-
 kmer_counter/bkb_writer.h           |   4 +-
 kmer_counter/defs.h                 |   8 +-
 kmer_counter/develop.cpp            | 142 +++++++
 kmer_counter/develop.h              |  16 +
 kmer_counter/fastq_reader.cpp       |   4 +-
 kmer_counter/fastq_reader.h         |   4 +-
 kmer_counter/kb_collector.h         |   4 +-
 kmer_counter/kb_completer.cpp       |   4 +-
 kmer_counter/kb_completer.h         |   4 +-
 kmer_counter/kb_reader.h            |   4 +-
 kmer_counter/kb_sorter.h            |   4 +-
 kmer_counter/kb_storer.cpp          |   4 +-
 kmer_counter/kb_storer.h            |   4 +-
 kmer_counter/kmc.h                  |   4 +-
 kmer_counter/kmer.cpp               |   4 +-
 kmer_counter/kmer.h                 |   4 +-
 kmer_counter/kmer_counter.cpp       |   6 +-
 kmer_counter/kmer_counter.vcxproj   |   2 +
 kmer_counter/kxmer_set.h            |   4 +-
 kmer_counter/mem_disk_file.cpp      |   4 +-
 kmer_counter/mem_disk_file.h        |   4 +-
 kmer_counter/meta_oper.h            |   4 +-
 kmer_counter/mmer.cpp               |   4 +-
 kmer_counter/mmer.h                 |   8 +-
 kmer_counter/params.h               |   4 +-
 kmer_counter/queues.h               |   4 +-
 kmer_counter/radix.cpp              |   4 +-
 kmer_counter/radix.h                |   4 +-
 kmer_counter/rev_byte.cpp           |   4 +-
 kmer_counter/rev_byte.h             |   4 +-
 kmer_counter/s_mapper.h             |   4 +-
 kmer_counter/splitter.h             |   4 +-
 kmer_counter/timer.cpp              |   4 +-
 kmer_counter/timer.h                |   4 +-
 56 files changed, 1287 insertions(+), 583 deletions(-)

diff --git a/API.pdf b/API.pdf
new file mode 100644
index 0000000..dc2b016
Binary files /dev/null and b/API.pdf differ
diff --git a/README.md b/README.md
index 4fbde6e..ec67620 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@ KMC
 KMC is a disk-based programm for counting k-mers from (possibly gzipped) FASTQ/FASTA files.
 The homepage of the KMC project is http://sun.aei.polsl.pl/kmc
 
+For accessing k-mers stored in database produced by KMC there is an API (kmc_api directory). Note that for KMC versions 0.x and 1.x dababase format differs from produced by KMC version 2.x. From version 2.2.0 API is unified for both formats and all new features/bug fixes are present only for 2.x branch (standalone API for older KMC version is not longer under development, so new version of API  should be used even for databases produced by older KMC version).
 
 Installation
 =
diff --git a/kmc_api/kmc_file.cpp b/kmc_api/kmc_file.cpp
index e08e221..c4c674c 100644
--- a/kmc_api/kmc_file.cpp
+++ b/kmc_api/kmc_file.cpp
@@ -4,18 +4,20 @@
 
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "stdafx.h"
 #include "mmer.h"
 #include "kmc_file.h"
 #include <iostream>
+#include <tuple>
 
 
 uint64 CKMCFile::part_size = 1 << 25;
 
+
 // ----------------------------------------------------------------------------------
 // Open files *.kmc_pre & *.kmc_suf, read them to RAM, close files. 
 // The file *.kmc_suf is opened for random access
@@ -27,10 +29,10 @@ bool CKMCFile::OpenForRA(const std::string &file_name)
 	uint64 size;
 	size_t result;
 
-	if(file_pre || file_suf)
+	if (file_pre || file_suf)
 		return false;
 
-	if(!OpenASingleFile(file_name + ".kmc_pre", file_pre, size, (char *)"KMCP"))
+	if (!OpenASingleFile(file_name + ".kmc_pre", file_pre, size, (char *)"KMCP"))
 		return false;
 
 	ReadParamsFrom_prefix_file_buf(size);
@@ -38,12 +40,12 @@ bool CKMCFile::OpenForRA(const std::string &file_name)
 	fclose(file_pre);
 	file_pre = NULL;
 		
-	if(!OpenASingleFile(file_name + ".kmc_suf", file_suf, size, (char *)"KMCS"))
+	if (!OpenASingleFile(file_name + ".kmc_suf", file_suf, size, (char *)"KMCS"))
 		return false;
 
 	sufix_file_buf = new uchar[size];
-	result = fread (sufix_file_buf, 1, size, file_suf);
-	if(result == 0)
+	result = fread(sufix_file_buf, 1, size, file_suf);
+	if (result == 0)
 		return false;
 
 	fclose(file_suf);
@@ -66,13 +68,13 @@ bool CKMCFile::OpenForListing(const std::string &file_name)
 	uint64 size;
 	size_t result;
 
-	if(is_opened)
+	if (is_opened)
 		return false;
 	
-	if(file_pre || file_suf)
+	if (file_pre || file_suf)
 		return false;
 
-	if(!OpenASingleFile(file_name + ".kmc_pre", file_pre, size, (char *)"KMCP"))
+	if (!OpenASingleFile(file_name + ".kmc_pre", file_pre, size, (char *)"KMCP"))
 		return false;
 
 	ReadParamsFrom_prefix_file_buf(size);
@@ -81,12 +83,12 @@ bool CKMCFile::OpenForListing(const std::string &file_name)
 
 	end_of_file = total_kmers == 0;
 
-	if(!OpenASingleFile(file_name + ".kmc_suf", file_suf, size, (char *)"KMCS"))
+	if (!OpenASingleFile(file_name + ".kmc_suf", file_suf, size, (char *)"KMCS"))
 		return false;
 
 	sufix_file_buf = new uchar[part_size];
-	result = fread (sufix_file_buf, 1, part_size, file_suf);
-	if(result == 0)
+	result = fread(sufix_file_buf, 1, part_size, file_suf);
+	if (result == 0)
 		return false;
 
 	is_opened = opened_for_listing;
@@ -111,14 +113,14 @@ CKMCFile::CKMCFile()
 //----------------------------------------------------------------------------------	
 CKMCFile::~CKMCFile()
 {
-	if(file_pre)
-		fclose(file_pre);	
-	if(file_suf)
+	if (file_pre)
+		fclose(file_pre);
+	if (file_suf)
 		fclose(file_suf);
-	if(prefix_file_buf)
-		delete [] prefix_file_buf;
-	if(sufix_file_buf)
-		delete [] sufix_file_buf;
+	if (prefix_file_buf)
+		delete[] prefix_file_buf;
+	if (sufix_file_buf)
+		delete[] sufix_file_buf;
 	if (signature_map)
 		delete[] signature_map;
 };
@@ -132,35 +134,35 @@ bool CKMCFile::OpenASingleFile(const std::string &file_name, FILE *&file_handler
 	char _marker[4];
 	size_t result;
 
- 	if((file_handler = my_fopen(file_name.c_str(), "rb")) == NULL)
-			return false;
-	
+	if ((file_handler = my_fopen(file_name.c_str(), "rb")) == NULL)
+		return false;
+
 	my_fseek(file_handler, 0, SEEK_END);
 	size = my_ftell(file_handler);					//the size of a whole file
-	
+
 	my_fseek(file_handler, -4, SEEK_CUR);
-	result = fread (_marker, 1, 4, file_handler);
-	if(result == 0)
+	result = fread(_marker, 1, 4, file_handler);
+	if (result == 0)
 		return false;
 
 	size = size - 4;							//the size of the file without the terminal marker
-	if (strncmp (marker, _marker, 4) != 0)
+	if (strncmp(marker, _marker, 4) != 0)
 	{
-		fclose(file_handler);	
+		fclose(file_handler);
 		file_handler = NULL;
 		return false;
 	}
 
-	rewind (file_handler);
-	result = fread (_marker, 1, 4, file_handler);
-	if(result == 0)
+	rewind(file_handler);
+	result = fread(_marker, 1, 4, file_handler);
+	if (result == 0)
 		return false;
 
 	size = size - 4;							//the size of the file without initial and terminal markers 
 
-	if (strncmp (marker, _marker, 4) != 0)
+	if (strncmp(marker, _marker, 4) != 0)
 	{
-		fclose(file_handler);	
+		fclose(file_handler);
 		file_handler = NULL;
 		return false;
 	}
@@ -174,52 +176,112 @@ bool CKMCFile::OpenASingleFile(const std::string &file_name, FILE *&file_handler
 //----------------------------------------------------------------------------------
 bool CKMCFile::ReadParamsFrom_prefix_file_buf(uint64 &size)
 {
+	size_t prev_pos = my_ftell(file_pre);
+	my_fseek(file_pre, -12, SEEK_END);
 	size_t result;
 
-	my_fseek(file_pre, -8, SEEK_END);
-	
-	int64 header_offset;
-	header_offset = fgetc(file_pre);
-		
-	size = size - 4;	//file size without the size of header_offset (and without 2 markers)
-
-	my_fseek(file_pre, (0LL - (header_offset + 8)), SEEK_END);
-	result = fread(&kmer_length, 1, sizeof(uint32), file_pre);
-	result = fread(&mode, 1, sizeof(uint32), file_pre);
-	result = fread(&counter_size, 1, sizeof(uint32), file_pre);
-	result = fread(&lut_prefix_length, 1, sizeof(uint32), file_pre);
-	result = fread(&signature_len, 1, sizeof(uint32), file_pre);
-	result = fread(&min_count, 1, sizeof(uint32), file_pre);
-	original_min_count = min_count;
-	result = fread(&max_count, 1, sizeof(uint32), file_pre);
-	original_max_count = max_count;
-	result = fread(&total_kmers, 1, sizeof(uint64), file_pre);
-
-	signature_map_size = ((1 << (2 * signature_len)) + 1);
-	uint64 lut_area_size_in_bytes = size - (signature_map_size * sizeof(uint32) + header_offset + 8);
-	single_LUT_size = 1 << (2 * lut_prefix_length);
-	uint64 last_data_index = lut_area_size_in_bytes / sizeof(uint64);
-
-	rewind(file_pre);
-	my_fseek(file_pre, +4, SEEK_CUR);
-	prefix_file_buf_size = (lut_area_size_in_bytes + 8) / sizeof(uint64);		//reads without 4 bytes of a header_offset (and without markers)		
-	prefix_file_buf = new uint64[prefix_file_buf_size];
-	result = fread(prefix_file_buf, 1, (size_t)(lut_area_size_in_bytes + 8), file_pre);
-	if (result == 0)
+	result = fread(&kmc_version, sizeof(uint32), 1, file_pre);
+	if (kmc_version != 0 && kmc_version != 0x200) //only this versions are supported, 0 = kmc1, 0x200 = kmc2
 		return false;
-	prefix_file_buf[last_data_index] = total_kmers + 1;
+	my_fseek(file_pre, prev_pos, SEEK_SET);
 
-	signature_map = new uint32[signature_map_size];
-	result = fread(signature_map, 1, signature_map_size * sizeof(uint32), file_pre);
-	if (result == 0)
-		return false;
+	if (kmc_version == 0x200)
+	{
+		my_fseek(file_pre, -8, SEEK_END);
+		
+		int64 header_offset;
+		header_offset = fgetc(file_pre);
+		
+		size = size - 4;	//file size without the size of header_offset (and without 2 markers)
+
+		my_fseek(file_pre, (0LL - (header_offset + 8)), SEEK_END);
+		result = fread(&kmer_length, 1, sizeof(uint32), file_pre);
+		result = fread(&mode, 1, sizeof(uint32), file_pre);
+		result = fread(&counter_size, 1, sizeof(uint32), file_pre);
+		result = fread(&lut_prefix_length, 1, sizeof(uint32), file_pre);
+		result = fread(&signature_len, 1, sizeof(uint32), file_pre);
+		result = fread(&min_count, 1, sizeof(uint32), file_pre);
+		original_min_count = min_count;
+		result = fread(&max_count, 1, sizeof(uint32), file_pre);
+		original_max_count = max_count;
+		result = fread(&total_kmers, 1, sizeof(uint64), file_pre);
+
+		signature_map_size = ((1 << (2 * signature_len)) + 1);
+		uint64 lut_area_size_in_bytes = size - (signature_map_size * sizeof(uint32)+header_offset + 8);
+		single_LUT_size = 1 << (2 * lut_prefix_length);
+		uint64 last_data_index = lut_area_size_in_bytes / sizeof(uint64);
+
+		rewind(file_pre);
+		my_fseek(file_pre, +4, SEEK_CUR);
+		prefix_file_buf_size = (lut_area_size_in_bytes + 8) / sizeof(uint64);		//reads without 4 bytes of a header_offset (and without markers)		
+		prefix_file_buf = new uint64[prefix_file_buf_size];
+		result = fread(prefix_file_buf, 1, (size_t)(lut_area_size_in_bytes + 8), file_pre);
+		if (result == 0)
+			return false;
+		prefix_file_buf[last_data_index] = total_kmers + 1;
+
+		signature_map = new uint32[signature_map_size];
+		result = fread(signature_map, 1, signature_map_size * sizeof(uint32), file_pre);
+		if (result == 0)
+			return false;
 
-	sufix_size = (kmer_length - lut_prefix_length) / 4;		 
+		sufix_size = (kmer_length - lut_prefix_length) / 4;		 
 	
-	sufix_rec_size = sufix_size + counter_size;	
+		sufix_rec_size = sufix_size + counter_size;	
 
-	return true;
+		return true;
+	}
+	else if (kmc_version == 0)
+	{
+		prefix_file_buf_size = (size - 4) / sizeof(uint64);		//reads without 4 bytes of a header_offset (and without markers)		
+		prefix_file_buf = new uint64[prefix_file_buf_size];
+		result = fread(prefix_file_buf, 1, (size_t)(size - 4), file_pre);
+		if (result == 0)
+			return false;
+
+		my_fseek(file_pre, -8, SEEK_END);
+
+		uint64 header_offset;
+		header_offset = fgetc(file_pre);
+
+		size = size - 4;
+
+		uint64 header_index = (size - header_offset) / sizeof(uint64);
+		uint64 last_data_index = header_index;
+
+		uint64 d = prefix_file_buf[header_index];
+
+		kmer_length = (uint32)d;			//- kmer's length
+		mode = d >> 32;				//- mode: 0 or 1
+
+		header_index++;
+		counter_size = (uint32)prefix_file_buf[header_index];	//- the size of a counter in bytes; 
+		//- for mode 0 counter_size is 1, 2, 3, or 4
+		//- for mode = 1 counter_size is 4;
+		lut_prefix_length = prefix_file_buf[header_index] >> 32;		//- the number of prefix's symbols cut frm kmers; 
+		//- (kmer_length - lut_prefix_length) is divisible by 4
+
+		header_index++;
+		original_min_count = (uint32)prefix_file_buf[header_index];    //- the minimal number of kmer's appearances 
+		min_count = original_min_count;
+		original_max_count = prefix_file_buf[header_index] >> 32;      //- the maximal number of kmer's appearances
+		max_count = original_max_count;
+
+		header_index++;
+		total_kmers = prefix_file_buf[header_index];					//- the total number of kmers 
+
+		prefix_file_buf[last_data_index] = total_kmers + 1;
+
+		sufix_size = (kmer_length - lut_prefix_length) / 4;
+
+		sufix_rec_size = sufix_size + counter_size;
+
+		return true;
+
+	}
+	return false;
 }
+
 //------------------------------------------------------------------------------------------
 // Check if kmer exists. 
 // IN : kmer  - kmer
@@ -228,109 +290,58 @@ bool CKMCFile::ReadParamsFrom_prefix_file_buf(uint64 &size)
 //------------------------------------------------------------------------------------------
 bool CKMCFile::CheckKmer(CKmerAPI &kmer, float &count)
 {
+	uint32 int_counter;
+	if (CheckKmer(kmer, int_counter))
+	{
+		if (mode == 0)
+			count = (float)int_counter;
+		else
+			memcpy(&count, &int_counter, counter_size);
+		return true;
+	}
+	return false;
+}
+
+//------------------------------------------------------------------------------------------
+// Check if kmer exists. 
+// IN : kmer  - kmer
+// OUT: count - kmer's counter if kmer exists
+// RET: true  - if kmer exists
+//------------------------------------------------------------------------------------------
+bool CKMCFile::CheckKmer(CKmerAPI &kmer, uint32 &count)
+{
 	if(is_opened != opened_for_RA)
 		return false;
 	if(end_of_file)
 		return false;
 	
-	uint32 signature = kmer.get_signature(signature_len);
-	
-	uint32 bin_start_pos = signature_map[signature];
-	bin_start_pos *= single_LUT_size;
-
 	//recognize a prefix:
 	uint64 pattern_prefix_value = kmer.kmer_data[0];
 
-	uint32 pattern_offset = (sizeof(pattern_prefix_value) * 8) - (lut_prefix_length * 2) - (kmer.byte_alignment * 2);
-	
+	uint32 pattern_offset = (sizeof(pattern_prefix_value)* 8) - (lut_prefix_length * 2) - (kmer.byte_alignment * 2);
+	int64 index_start = 0, index_stop = 0;
+
 	pattern_prefix_value = pattern_prefix_value >> pattern_offset;  //complements with 0
-	if(pattern_prefix_value >= prefix_file_buf_size)
+	if (pattern_prefix_value >= prefix_file_buf_size)
 		return false;
-	//look into the array with data
 
-	int64 index_start = *(prefix_file_buf + bin_start_pos + pattern_prefix_value);			
-	int64 index_stop = *(prefix_file_buf + bin_start_pos + pattern_prefix_value + 1) - 1;	
- 
-	uchar *sufix_byte_ptr; 
-	uint64 sufix = 0;
-	
-										//sufix_offset is always 56
-	uint32 sufix_offset = 56;			// the ofset of a sufix is for shifting the sufix towards MSB, to compare the sufix with a pattern
-										// Bytes of a pattern to search are always shifted towards MSB
-	
-	uint32 row_index = 0;				// the number of a current row in an array kmer_data
-	
-	bool found = false;
-
-	//binary search:
-
-	while (index_start <= index_stop) 
+	if (kmc_version == 0x200)
 	{
-		int64 mid_index = (index_start + index_stop) / 2; 
-		sufix_byte_ptr = &sufix_file_buf[mid_index * sufix_rec_size];
-
-		uint64 pattern = 0;
-	  
-		pattern_offset = (lut_prefix_length + kmer.byte_alignment ) * 2;		
-	  
-		for(uint32 a = 0; a < sufix_size; a ++)		//check byte by byte
-		{
-			pattern = kmer.kmer_data[row_index];
-			pattern = pattern << pattern_offset;
-			pattern = pattern & 0xff00000000000000;
-			
-			sufix = sufix_byte_ptr[a];
-			sufix = sufix << sufix_offset;
-		
-			if(pattern != sufix)					
-				break;
-
-			pattern_offset += 8;
-			
-			if (pattern_offset == 64)				//the end of a word
-			{
-					pattern_offset = 0;
-					row_index++;
-			}
-		}
-
-		if(pattern == sufix)
-		{
-		  found = true;
-		  break;
-		}
-		if( sufix < pattern )
-			index_start = mid_index + 1;
-		else
-			index_stop = mid_index - 1;
+		uint32 signature = kmer.get_signature(signature_len);
+		uint32 bin_start_pos = signature_map[signature];
+		bin_start_pos *= single_LUT_size;				
+		//look into the array with data
+		index_start = *(prefix_file_buf + bin_start_pos + pattern_prefix_value);
+		index_stop = *(prefix_file_buf + bin_start_pos + pattern_prefix_value + 1) - 1;
 	}
-	
-	if(found)
+	else if (kmc_version == 0)
 	{
-		sufix_byte_ptr += sufix_size;
-		uint32 int_counter;
-	
-		int_counter = *sufix_byte_ptr;
-
-		for(uint32 b = 1; b < counter_size; b ++)
-		{
-			uint32 aux = 0x000000ff & *(sufix_byte_ptr + b);
-
-			aux = aux << 8 * ( b);
-			int_counter = aux | int_counter;
-		}
-	
-		if(mode == 0)
-			count = (float)int_counter;
-		else
-			memcpy(&count, &int_counter, counter_size);
-		
-		if((count >= min_count) && (count <= max_count))
-			return true;
-		else
-			return false;
+		//look into the array with data
+		index_start = prefix_file_buf[pattern_prefix_value];
+		index_stop = prefix_file_buf[pattern_prefix_value + 1] - 1;
 	}
-	return false;
+
+	return BinarySearch(index_start, index_stop, kmer, count, pattern_offset);
 }
 
 //-----------------------------------------------------------------------------------------------
@@ -341,15 +352,30 @@ bool CKMCFile::Eof(void)
 {
 	return end_of_file;	
 }
+
+bool CKMCFile::ReadNextKmer(CKmerAPI &kmer, float &count)
+{
+	uint32 int_counter;
+	if (ReadNextKmer(kmer, int_counter))
+	{
+		if (mode == 0)
+			count = (float)int_counter;
+		else
+			memcpy(&count, &int_counter, counter_size);
+		return true;
+	}
+	return false;
+
+}
 //-----------------------------------------------------------------------------------------------
 // Read next kmer
 // OUT: kmer - next kmer
 // OUT: count - kmer's counter
 // RET: true - if not EOF
 //-----------------------------------------------------------------------------------------------
-bool CKMCFile::ReadNextKmer(CKmerAPI &kmer, float &count)
+bool CKMCFile::ReadNextKmer(CKmerAPI &kmer, uint32 &count)
 {
-	uint32 int_counter;
+	uint64 prefix_mask = (1 << 2 * lut_prefix_length) - 1; //for kmc2 db
 
 	if(is_opened != opened_for_listing)
 		return false;
@@ -368,7 +394,7 @@ bool CKMCFile::ReadNextKmer(CKmerAPI &kmer, float &count)
 	
 		uint32 off = (sizeof(prefix_index) * 8) - (lut_prefix_length * 2) - kmer.byte_alignment * 2;
 			
-		uint64 temp_prefix = prefix_index << off;	// shift prefix towards MSD
+		uint64 temp_prefix = (prefix_index & prefix_mask) << off;	// shift prefix towards MSD. "& prefix_mask" necessary for kmc2 db format
 		
 		kmer.kmer_data[0] = temp_prefix;			// store prefix in an object CKmerAPI
 
@@ -403,7 +429,7 @@ bool CKMCFile::ReadNextKmer(CKmerAPI &kmer, float &count)
 		if(index_in_partial_buf == part_size)
 			Reload_sufix_file_buf();
 		
-		int_counter = sufix_file_buf[index_in_partial_buf++];
+		count = sufix_file_buf[index_in_partial_buf++];
 
 		for(uint32 b = 1; b < counter_size; b++)
 		{
@@ -412,18 +438,24 @@ bool CKMCFile::ReadNextKmer(CKmerAPI &kmer, float &count)
 			
 			uint32 aux = 0x000000ff & sufix_file_buf[index_in_partial_buf++];
 			aux = aux << 8 * ( b);
-			int_counter = aux | int_counter;
+			count = aux | count;
 		}
-	
-		if(mode == 0)
-			count = (float)int_counter;
-		else
-			memcpy(&count, &int_counter, counter_size);
-	
+			
 		sufix_number++;
 	
 		if(sufix_number == total_kmers)
 			end_of_file = true;
+
+		if (mode != 0)
+		{
+			float float_counter;
+			memcpy(&float_counter, &count, counter_size);
+			if ((float_counter < min_count) || (float_counter > max_count))
+				continue;
+			else
+				break;
+		}
+
 	}
 	while((count < min_count) || (count > max_count));
 
@@ -568,7 +600,7 @@ uint32 CKMCFile::KmerLength(void)
 //----------------------------------------------------------------------------------------
 bool CKMCFile::IsKmer(CKmerAPI &kmer)
 {
-	float _count;
+	uint32 _count;
 	if(CheckKmer(kmer, _count))
 		return true;
 	else
@@ -654,7 +686,10 @@ bool CKMCFile::Info(uint32 &_kmer_length, uint32 &_mode, uint32 &_counter_size,
 		_mode = mode;
 		_counter_size = counter_size;
 		_lut_prefix_length = lut_prefix_length;
-		_signature_len = signature_len;
+		if (kmc_version == 0x200)
+			_signature_len = signature_len;
+		else
+			_signature_len = 0; //for kmc1 there is no signature_len
 		_min_count = min_count;
 		_max_count = max_count;
 		_total_kmers = total_kmers;
@@ -663,4 +698,396 @@ bool CKMCFile::Info(uint32 &_kmer_length, uint32 &_mode, uint32 &_counter_size,
 	return false;
 };
 
+
+//---------------------------------------------------------------------------------
+// Get counters from read
+// OUT	:	counters    	- vector of counters of each k-mer in read (of size read_len - kmer_len + 1), if some k-mer is invalid (i.e. contains 'N') the counter is equal to 0
+// IN   :   read			- 
+// RET	: true if success
+//---------------------------------------------------------------------------------
+bool CKMCFile::GetCountersForRead(const std::string& read, std::vector<uint32>& counters)
+{
+	if (is_opened != opened_for_RA)
+		return false;
+	if (kmc_version == 0x200)
+		return GetCountersForRead_kmc2(read, counters);
+	else if (kmc_version == 0)
+		return GetCountersForRead_kmc1(read, counters);
+	else
+		return false; //never should be here
+}
+
+//---------------------------------------------------------------------------------
+// Get counters from read
+// OUT	:	counters    	- vector of counters of each k-mer in read (of size read_len - kmer_len + 1), if some k-mer is invalid (i.e. contains 'N') the counter is equal to 0
+// IN   :   read			- 
+// RET	: true if success
+//---------------------------------------------------------------------------------
+bool CKMCFile::GetCountersForRead(const std::string& read, std::vector<float>& counters)
+{
+	if (is_opened != opened_for_RA)
+		return false;
+	std::vector<uint32> uint32_v;
+	if (GetCountersForRead(read, uint32_v))
+	{
+		counters.clear();
+		counters.resize(uint32_v.size());
+		if (mode == 0)
+		{
+			for (uint32 i = 0; i < uint32_v.size(); ++i)
+				counters[i] = static_cast<float>(uint32_v[i]);
+		}
+		else
+		{
+			for (uint32 i = 0; i < uint32_v.size(); ++i)
+				memcpy(&counters[i], &uint32_v[i], counter_size);
+		}
+
+		return true;
+	}
+	return false;
+}
+
+//---------------------------------------------------------------------------------
+// Auxiliary function.
+//---------------------------------------------------------------------------------
+uint32 CKMCFile::count_for_kmer_kmc1(CKmerAPI& kmer)
+{
+	//recognize a prefix:
+
+	uint64 pattern_prefix_value = kmer.kmer_data[0];
+
+	uint32 pattern_offset = (sizeof(pattern_prefix_value)* 8) - (lut_prefix_length * 2) - (kmer.byte_alignment * 2);
+
+	pattern_prefix_value = pattern_prefix_value >> pattern_offset;  //complements with 0
+	if (pattern_prefix_value >= prefix_file_buf_size)
+		return false;
+	//look into the array with data
+
+	int64 index_start = prefix_file_buf[pattern_prefix_value];
+	int64 index_stop = prefix_file_buf[pattern_prefix_value + 1] - 1;
+
+	uint32 counter = 0;
+	if (BinarySearch(index_start, index_stop, kmer, counter, pattern_offset))
+		return counter;
+	return 0;
+}
+
+//---------------------------------------------------------------------------------
+// Auxiliary function.
+//---------------------------------------------------------------------------------
+uint32 CKMCFile::count_for_kmer_kmc2(CKmerAPI& kmer, uint32 bin_start_pos)
+{
+	//recognize a prefix:
+	uint64 pattern_prefix_value = kmer.kmer_data[0];
+
+	uint32 pattern_offset = (sizeof(pattern_prefix_value)* 8) - (lut_prefix_length * 2) - (kmer.byte_alignment * 2);
+
+	pattern_prefix_value = pattern_prefix_value >> pattern_offset;  //complements with 0
+	if (pattern_prefix_value >= prefix_file_buf_size)
+		return false;
+	//look into the array with data
+
+	int64 index_start = *(prefix_file_buf + bin_start_pos + pattern_prefix_value);
+	int64 index_stop = *(prefix_file_buf + bin_start_pos + pattern_prefix_value + 1) - 1;
+
+	uint32 counter = 0;
+	if (BinarySearch(index_start, index_stop, kmer, counter, pattern_offset))
+		return counter;
+	return 0;
+}
+
+//---------------------------------------------------------------------------------
+// Auxiliary function.
+//---------------------------------------------------------------------------------
+bool CKMCFile::GetCountersForRead_kmc1(const std::string& read, std::vector<uint32>& counters)
+{	
+	uint32 read_len = static_cast<uint32>(read.length());
+	counters.resize(read.length() - kmer_length + 1);
+	std::string transformed_read = read;
+	for (char& c : transformed_read)
+		c = CKmerAPI::num_codes[(uchar)c];
+
+	uint32 i = 0;
+	CKmerAPI kmer(kmer_length);
+	uint32 pos = 0;
+	
+	uint32 counters_pos = 0;
+
+	while (i + kmer_length - 1 < read_len)
+	{
+		bool contains_N = false;
+		while (i < read_len && pos < kmer_length)
+		{
+			if (CKmerAPI::num_codes[(uchar)read[i]] < 0)
+			{
+				pos = 0;
+				kmer.clear();
+				++i;
+				uint32 wrong_kmers = MIN(i - counters_pos, static_cast<uint32>(counters.size()) - counters_pos);
+				fill_n(counters.begin() + counters_pos, wrong_kmers, 0);
+				counters_pos += wrong_kmers;
+				contains_N = true;
+				break;
+			}
+			else
+				kmer.insert2bits(pos++, CKmerAPI::num_codes[(uchar)read[i++]]);
+		}
+		if (contains_N)
+			continue;
+		if (pos == kmer_length)
+		{			
+			counters[counters_pos++] = count_for_kmer_kmc1(kmer);
+		}
+		else
+			break;
+
+		while (i < read_len)
+		{
+			if (CKmerAPI::num_codes[(uchar)read[i]] < 0)
+			{
+				pos = 0;
+				break;
+			}
+			kmer.SHL_insert2bits(CKmerAPI::num_codes[(uchar)read[i++]]);
+			counters[counters_pos++] = count_for_kmer_kmc1(kmer);
+		}
+	}
+	if (counters_pos < counters.size())
+	{
+		fill_n(counters.begin() + counters_pos, counters.size() - counters_pos, 0);
+		counters_pos = static_cast<uint32>(counters.size());
+	}
+	return true;
+}
+//---------------------------------------------------------------------------------
+// Auxiliary function.
+//---------------------------------------------------------------------------------
+bool CKMCFile::GetCountersForRead_kmc2(const std::string& read, std::vector<uint32>& counters)
+{	
+counters.resize(read.length() - kmer_length + 1);
+	std::string transformed_read = read;
+	for (char& c : transformed_read)
+		c = CKmerAPI::num_codes[(uchar)c];
+	uint32 i = 0;
+	uint32 len = 0; //length of super k-mer
+	uint32 signature_start_pos;
+	CMmer current_signature(signature_len), end_mmer(signature_len);
+
+	using super_kmers_t = std::vector<std::tuple<uint32, uint32, uint32>>;//start_pos, len, bin_no, 
+	super_kmers_t super_kmers;
+
+	while (i + kmer_length - 1 < read.length())
+	{
+		bool contains_N = false;
+		//building first signature after 'N' or at the read beginning
+		for (uint32 j = 0; j < signature_len; ++j, ++i)
+		{
+			if (transformed_read[i] < 0)//'N'
+			{
+				contains_N = true;
+				break;
+			}
+		}
+		//signature must be shorter than k-mer so if signature contains 'N', k-mer will contains it also
+		if (contains_N)
+		{
+			++i;
+			continue;
+		}
+		len = signature_len;
+		signature_start_pos = i - signature_len;
+		current_signature.insert(transformed_read.c_str() + signature_start_pos); 
+		end_mmer.set(current_signature);
+
+		for (; i < transformed_read.length(); ++i)
+		{
+			if (transformed_read[i] < 0)//'N'
+			{
+				if (len >= kmer_length)
+				{
+					super_kmers.push_back(std::make_tuple(i - len, len, signature_map[current_signature.get()]));
+				}
+				len = 0;
+				++i;
+				break;
+			}
+			end_mmer.insert(transformed_read[i]);
+			if (end_mmer < current_signature)//signature at the end of current k-mer is lower than current
+			{
+				if (len >= kmer_length)
+				{
+					super_kmers.push_back(std::make_tuple(i - len, len, signature_map[current_signature.get()]));
+					len = kmer_length - 1;
+				}
+				current_signature.set(end_mmer);
+				signature_start_pos = i - signature_len + 1;
+			}
+			else if (end_mmer == current_signature)
+			{
+				current_signature.set(end_mmer);
+				signature_start_pos = i - signature_len + 1;
+			}
+			else if (signature_start_pos + kmer_length - 1 < i)//need to find new signature
+			{
+				super_kmers.push_back(std::make_tuple(i - len, len, signature_map[current_signature.get()]));
+				len = kmer_length - 1;
+				//looking for new signature
+				++signature_start_pos;
+				//building first signature in current k-mer
+				end_mmer.insert(transformed_read.c_str() + signature_start_pos);
+				current_signature.set(end_mmer);
+				for (uint32 j = signature_start_pos + signature_len; j <= i; ++j)
+				{
+					end_mmer.insert(transformed_read[j]);
+					if (end_mmer <= current_signature)
+					{
+						current_signature.set(end_mmer);
+						signature_start_pos = j - signature_len + 1;
+					}
+				}
+			}
+			++len;
+		}
+	}
+	if (len >= kmer_length)//last one in read
+	{
+		super_kmers.push_back(std::make_tuple(i - len, len, signature_map[current_signature.get()]));
+	}
+
+	uint32 counters_pos = 0;
+	if (super_kmers.empty())
+	{
+		fill_n(counters.begin(), counters.size(), 0);
+		return true;
+	}
+
+	CKmerAPI kmer(kmer_length);
+
+	uint32 last_end = 0;
+
+	//'N' somewhere in first k-mer
+	if (std::get<0>(super_kmers.front()) > 0)
+	{
+		fill_n(counters.begin(), std::get<0>(super_kmers.front()), 0);
+		last_end = std::get<0>(super_kmers.front());
+		counters_pos = std::get<0>(super_kmers.front());
+	}
+	for (auto& super_kmer : super_kmers)
+	{
+		//'N's between super k-mers
+		if (last_end < std::get<0>(super_kmer))
+		{
+			uint32 gap = std::get<0>(super_kmer) -last_end;
+			fill_n(counters.begin() + counters_pos, kmer_length + gap - 1, 0);
+			counters_pos += kmer_length + gap - 1;
+		}
+		last_end = std::get<0>(super_kmer) + std::get<1>(super_kmer);
+
+		kmer.clear();
+		kmer.from_binary(transformed_read.c_str() + std::get<0>(super_kmer));
+
+		uint32 bin_start_pos = std::get<2>(super_kmer) * single_LUT_size;
+		counters[counters_pos++] = count_for_kmer_kmc2(kmer, bin_start_pos);
+
+		for (uint32 i = std::get<0>(super_kmer) +kmer_length; i < std::get<0>(super_kmer) +std::get<1>(super_kmer); ++i)
+		{
+			kmer.SHL_insert2bits(transformed_read[i]);
+			counters[counters_pos++] = count_for_kmer_kmc2(kmer, bin_start_pos);
+		}
+	}
+	//'N's at the end of read
+	if (counters_pos < counters.size())
+	{
+		fill_n(counters.begin() + counters_pos, counters.size() - counters_pos, 0);
+		counters_pos = static_cast<uint32>(counters.size());
+	}
+
+	return true;
+}
+
+
+//---------------------------------------------------------------------------------
+// Auxiliary function.
+//---------------------------------------------------------------------------------
+bool CKMCFile::BinarySearch(int64 index_start, int64 index_stop, const CKmerAPI& kmer, uint32& counter, uint32 pattern_offset)
+{
+	uchar *sufix_byte_ptr = nullptr;
+	uint64 sufix = 0;
+
+	//sufix_offset is always 56
+	uint32 sufix_offset = 56;			// the ofset of a sufix is for shifting the sufix towards MSB, to compare the sufix with a pattern
+	// Bytes of a pattern to search are always shifted towards MSB
+
+	uint32 row_index = 0;				// the number of a current row in an array kmer_data
+
+	bool found = false;
+
+	while (index_start <= index_stop)
+	{
+		int64 mid_index = (index_start + index_stop) / 2;
+		sufix_byte_ptr = &sufix_file_buf[mid_index * sufix_rec_size];
+
+		uint64 pattern = 0;
+
+		pattern_offset = (lut_prefix_length + kmer.byte_alignment) * 2;
+
+		row_index = 0;
+		for (uint32 a = 0; a < sufix_size; a++)		//check byte by byte
+		{
+			pattern = kmer.kmer_data[row_index];
+			pattern = pattern << pattern_offset;
+			pattern = pattern & 0xff00000000000000;
+
+			sufix = sufix_byte_ptr[a];
+			sufix = sufix << sufix_offset;
+
+			if (pattern != sufix)
+				break;
+
+			pattern_offset += 8;
+
+			if (pattern_offset == 64)				//the end of a word
+			{
+				pattern_offset = 0;
+				row_index++;
+			}
+		}
+
+		if (pattern == sufix)
+		{
+			found = true;
+			break;
+		}
+		if (sufix < pattern)
+			index_start = mid_index + 1;
+		else
+			index_stop = mid_index - 1;
+	}
+
+	if (found)
+	{
+		sufix_byte_ptr += sufix_size;
+
+		counter = *sufix_byte_ptr;
+
+		for (uint32 b = 1; b < counter_size; b++)
+		{
+			uint32 aux = 0x000000ff & *(sufix_byte_ptr + b);
+
+			aux = aux << 8 * (b);
+			counter = aux | counter;
+		}
+		if (mode != 0)
+		{
+			float float_counter;
+			memcpy(&float_counter, &counter, counter_size);
+			return (float_counter >= min_count) && (float_counter <= max_count);
+		}
+		return (counter >= min_count) && (counter <= max_count);
+	}
+	return false;
+}
+
+
 // ***** EOF
diff --git a/kmc_api/kmc_file.h b/kmc_api/kmc_file.h
index e92ae7a..73676f9 100644
--- a/kmc_api/kmc_file.h
+++ b/kmc_api/kmc_file.h
@@ -4,8 +4,8 @@
 
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _KMC_FILE_H
@@ -14,6 +14,7 @@
 #include "kmer_defs.h"
 #include "kmer_api.h"
 #include <string>
+#include <vector>
 
 class CKMCFile
 {
@@ -46,6 +47,7 @@ class CKMCFile
 	uint32 max_count;
 	uint64 total_kmers;
 
+	uint32 kmc_version;
 	uint32 sufix_size;		// sufix's size in bytes 
 	uint32 sufix_rec_size;  // sufix_size + counter_size
 
@@ -54,6 +56,8 @@ class CKMCFile
 
 	static uint64 part_size; // the size of a block readed to sufix_file_buf, in listing mode 
 	
+	bool BinarySearch(int64 index_start, int64 index_stop, const CKmerAPI& kmer, uint32& counter, uint32 pattern_offset);
+
 	// Open a file, recognize its size and check its marker. Auxiliary function.
 	bool OpenASingleFile(const std::string &file_name, FILE *&file_handler, uint64 &size, char marker[]);	
 
@@ -63,6 +67,11 @@ class CKMCFile
 	// Reload a contents of an array "sufix_file_buf" for listing mode. Auxiliary function. 
 	void Reload_sufix_file_buf();
 
+	// Implementation of GetCountersForRead for kmc1 database format
+	bool GetCountersForRead_kmc1(const std::string& read, std::vector<uint32>& counters);
+
+	// Implementation of GetCountersForRead for kmc2 database format
+	bool GetCountersForRead_kmc2(const std::string& read, std::vector<uint32>& counters);
 public:
 		
 	CKMCFile();
@@ -77,6 +86,7 @@ public:
 	// Return next kmer in CKmerAPI &kmer. Return its counter in float &count. Return true if not EOF
 	bool ReadNextKmer(CKmerAPI &kmer, float &count);
 
+	bool ReadNextKmer(CKmerAPI &kmer, uint32 &count);
 	// Release memory and close files in case they were opened 
 	bool Close();
 
@@ -107,6 +117,8 @@ public:
 	// Return true if kmer exists. In this case return kmer's counter in count
 	bool CheckKmer(CKmerAPI &kmer, float &count);
 
+	bool CheckKmer(CKmerAPI &kmer, uint32 &count);
+
 	// Return true if kmer exists
 	bool IsKmer(CKmerAPI &kmer);
 
@@ -115,6 +127,13 @@ public:
 
 	// Get current parameters from kmer_database
 	bool Info(uint32 &_kmer_length, uint32 &_mode, uint32 &_counter_size, uint32 &_lut_prefix_length, uint32 &_signature_len, uint32 &_min_count, uint32 &_max_count, uint64 &_total_kmers);
+	
+	// Get counters for all k-mers in read
+	bool GetCountersForRead(const std::string& read, std::vector<uint32>& counters);
+	bool GetCountersForRead(const std::string& read, std::vector<float>& counters);
+	private:
+		uint32 count_for_kmer_kmc1(CKmerAPI& kmer);
+		uint32 count_for_kmer_kmc2(CKmerAPI& kmer, uint32 bin_start_pos);
 };
 
 #endif
diff --git a/kmc_api/kmer_api.cpp b/kmc_api/kmer_api.cpp
index d475a26..befd9fe 100644
--- a/kmc_api/kmer_api.cpp
+++ b/kmc_api/kmer_api.cpp
@@ -4,8 +4,8 @@
 
   Authors: Sebastian Deorowicz and Agnieszka Debudaj-Grabysz
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 
@@ -19,5 +19,30 @@ using namespace std;
 const char CKmerAPI::char_codes[] = {'A','C', 'G', 'T'};	
 char CKmerAPI::num_codes[];
 CKmerAPI::_si CKmerAPI::_init; 
+uchar CKmerAPI::rev_comp_bytes_LUT[] = {
+    0xff, 0xbf, 0x7f, 0x3f, 0xef, 0xaf, 0x6f, 0x2f, 0xdf, 0x9f, 0x5f, 0x1f, 0xcf, 0x8f, 0x4f, 0x0f,
+    0xfb, 0xbb, 0x7b, 0x3b, 0xeb, 0xab, 0x6b, 0x2b, 0xdb, 0x9b, 0x5b, 0x1b, 0xcb, 0x8b, 0x4b, 0x0b,
+    0xf7, 0xb7, 0x77, 0x37, 0xe7, 0xa7, 0x67, 0x27, 0xd7, 0x97, 0x57, 0x17, 0xc7, 0x87, 0x47, 0x07,
+    0xf3, 0xb3, 0x73, 0x33, 0xe3, 0xa3, 0x63, 0x23, 0xd3, 0x93, 0x53, 0x13, 0xc3, 0x83, 0x43, 0x03,
+    0xfe, 0xbe, 0x7e, 0x3e, 0xee, 0xae, 0x6e, 0x2e, 0xde, 0x9e, 0x5e, 0x1e, 0xce, 0x8e, 0x4e, 0x0e,
+    0xfa, 0xba, 0x7a, 0x3a, 0xea, 0xaa, 0x6a, 0x2a, 0xda, 0x9a, 0x5a, 0x1a, 0xca, 0x8a, 0x4a, 0x0a,
+    0xf6, 0xb6, 0x76, 0x36, 0xe6, 0xa6, 0x66, 0x26, 0xd6, 0x96, 0x56, 0x16, 0xc6, 0x86, 0x46, 0x06,
+    0xf2, 0xb2, 0x72, 0x32, 0xe2, 0xa2, 0x62, 0x22, 0xd2, 0x92, 0x52, 0x12, 0xc2, 0x82, 0x42, 0x02,
+    0xfd, 0xbd, 0x7d, 0x3d, 0xed, 0xad, 0x6d, 0x2d, 0xdd, 0x9d, 0x5d, 0x1d, 0xcd, 0x8d, 0x4d, 0x0d,
+    0xf9, 0xb9, 0x79, 0x39, 0xe9, 0xa9, 0x69, 0x29, 0xd9, 0x99, 0x59, 0x19, 0xc9, 0x89, 0x49, 0x09,
+    0xf5, 0xb5, 0x75, 0x35, 0xe5, 0xa5, 0x65, 0x25, 0xd5, 0x95, 0x55, 0x15, 0xc5, 0x85, 0x45, 0x05,
+    0xf1, 0xb1, 0x71, 0x31, 0xe1, 0xa1, 0x61, 0x21, 0xd1, 0x91, 0x51, 0x11, 0xc1, 0x81, 0x41, 0x01,
+    0xfc, 0xbc, 0x7c, 0x3c, 0xec, 0xac, 0x6c, 0x2c, 0xdc, 0x9c, 0x5c, 0x1c, 0xcc, 0x8c, 0x4c, 0x0c,
+    0xf8, 0xb8, 0x78, 0x38, 0xe8, 0xa8, 0x68, 0x28, 0xd8, 0x98, 0x58, 0x18, 0xc8, 0x88, 0x48, 0x08,
+    0xf4, 0xb4, 0x74, 0x34, 0xe4, 0xa4, 0x64, 0x24, 0xd4, 0x94, 0x54, 0x14, 0xc4, 0x84, 0x44, 0x04,
+    0xf0, 0xb0, 0x70, 0x30, 0xe0, 0xa0, 0x60, 0x20, 0xd0, 0x90, 0x50, 0x10, 0xc0, 0x80, 0x40, 0x00
+};
+uint64 CKmerAPI::alignment_mask[] = {
+    0xFFFFFFFFFFFFFFFFULL,
+    0x3FFFFFFFFFFFFFFFULL,
+    0x0FFFFFFFFFFFFFFFULL,
+    0x03FFFFFFFFFFFFFFULL,
+    0x00FFFFFFFFFFFFFFULL
+};
 
 // ***** EOF
diff --git a/kmc_api/kmer_api.h b/kmc_api/kmer_api.h
index 2446b8d..e652aa2 100644
--- a/kmc_api/kmer_api.h
+++ b/kmc_api/kmer_api.h
@@ -1,11 +1,11 @@
 /*
-  This file is a part of KMC software distributed under GNU GPL 3 licence.
-  The homepage of the KMC project is http://sun.aei.polsl.pl/kmc
+This file is a part of KMC software distributed under GNU GPL 3 licence.
+The homepage of the KMC project is http://sun.aei.polsl.pl/kmc
 
-  Authors: Sebastian Deorowicz and Agnieszka Debudaj-Grabysz
+Authors: Sebastian Deorowicz and Agnieszka Debudaj-Grabysz
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+Version: 2.2.0
+Date   : 2015-04-15
 */
 
 #ifndef _KMER_API_H
@@ -18,7 +18,7 @@
 #include "mmer.h"
 class CKMCFile;
 
-class CKmerAPI 
+class CKmerAPI
 {
 protected:
 
@@ -32,14 +32,217 @@ protected:
 	uint32 no_of_rows;				// A number of 64-bits words allocated for kmer_data 	
 
 	friend class CKMCFile;
+	
+	//----------------------------------------------------------------------------------
+	inline void clear()
+	{
+		memset(kmer_data, 0, sizeof(*kmer_data) * no_of_rows);
+	}
+
+	//----------------------------------------------------------------------------------
+	inline void insert2bits(uint32 pos, uchar val)
+	{
+		kmer_data[(pos + byte_alignment) >> 5] += (uint64)val << (62 - (((pos + byte_alignment) & 31) * 2));
+	}
+
+	inline uchar extract2bits(uint32 pos)
+	{
+		return (kmer_data[(pos + byte_alignment) >> 5] >> (62 - (((pos + byte_alignment) & 31) * 2))) & 3;
+	}
+	//----------------------------------------------------------------------------------
+	inline void SHL_insert2bits(uchar val)
+	{
+		kmer_data[0] <<= 2;
+		if (byte_alignment)
+		{
+			uint64 mask = ~(((1ull << 2 * byte_alignment) - 1) << (64 - 2 * byte_alignment));
+			kmer_data[0] &= mask;
+		}
+		for (uint32 i = 1; i < no_of_rows; ++i)
+		{
+			kmer_data[i - 1] += kmer_data[i] >> 62;
+			kmer_data[i] <<= 2;
+		}
+		kmer_data[no_of_rows - 1] += (uint64)val << (62 - (((kmer_length - 1 + byte_alignment) & 31) * 2));
+	}
+	// ----------------------------------------------------------------------------------
+	inline void from_binary(const char* kmer)
+	{
+		clear();
+		for (uint32 i = 0; i < kmer_length; ++i)
+			insert2bits(i, kmer[i]);
+	}
+
+	// ----------------------------------------------------------------------------------
+	template<typename RandomAccessIterator>
+	inline void to_string_impl(RandomAccessIterator iter)
+	{
+		uchar *byte_ptr;
+		uchar c;
+		uchar temp_byte_alignment = byte_alignment;
+		uint32 cur_string_size = 0;
+		for (uint32 row_counter = 0; row_counter < no_of_rows; row_counter++)
+		{
+			byte_ptr = reinterpret_cast<uchar*>(&kmer_data[row_counter]);
+
+			byte_ptr += 7;					// shift a pointer towards a MSB
+
+			for (uint32 i = 0; (i < kmer_length) && (i < 32); i += 4)		// 32 symbols of any "row" in kmer_data
+			{
+				if ((i == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
+					temp_byte_alignment--;
+				else
+				{
+					c = 0xc0 & *byte_ptr;			//11000000
+					c = c >> 6;
+					*(iter + cur_string_size++) = char_codes[c];
+					if (cur_string_size == kmer_length) break;
+				}
+
+				if ((i == 0) && temp_byte_alignment)				// check if a  byte_alignment placed before a prefix is to be skipped
+					temp_byte_alignment--;
+				else
+				{
+					c = 0x30 & *byte_ptr;			//00110000
+					c = c >> 4;
+					*(iter + cur_string_size++) = char_codes[c];
+					if (cur_string_size == kmer_length) break;
+				}
+
+				if ((i == 0) && temp_byte_alignment)				// check if a  byte_alignment placed before a prefix is to be skipped
+					temp_byte_alignment--;
+				else
+				{
+					c = 0x0c & *byte_ptr;			//00001100
+					c = c >> 2;
+					*(iter + cur_string_size++) = char_codes[c];
+					if (cur_string_size == kmer_length) break;
+				}
+				// no need to check byte alignment as its length is at most 3 
+				c = 0x03 & *byte_ptr;			//00000011
+				*(iter + cur_string_size++) = char_codes[c];
+				if (cur_string_size == kmer_length) break;
 
+				byte_ptr--;
+			}
+		}
+	}
+	
+	// ----------------------------------------------------------------------------------
+	template<typename RandomAccessIterator>
+	inline bool from_string_impl(const RandomAccessIterator iter, uint32 len)
+	{
+		unsigned char c_char;
+		uchar c_binary;
+		uchar temp_byte_alignment;
+		if (kmer_length != len)
+		{
+			if (kmer_length && kmer_data)
+				delete[] kmer_data;
+
+			kmer_length = len;
+
+			if (kmer_length % 4)
+				byte_alignment = 4 - (kmer_length % 4);
+			else
+				byte_alignment = 0;
+
+
+			if (kmer_length != 0)
+			{
+				no_of_rows = (((kmer_length + byte_alignment) % 32) ? (kmer_length + byte_alignment) / 32 + 1 : (kmer_length + byte_alignment) / 32);
+				//no_of_rows = (int)ceil((double)(kmer_length + byte_alignment) / 32);
+				kmer_data = new uint64[no_of_rows];
+				//memset(kmer_data, 0, sizeof(*kmer_data) * no_of_rows);
+			}
+		}
+
+		memset(kmer_data, 0, sizeof(*kmer_data) * no_of_rows);
+		temp_byte_alignment = byte_alignment;
+		uint32 i = 0;
+		uint32 i_in_string = 0;
+		uchar *byte_ptr;
+
+		for (uint32 row_index = 0; row_index < no_of_rows; row_index++)
+		{
+			byte_ptr = reinterpret_cast<uchar*>(&kmer_data[row_index]);
+			byte_ptr += 7;					// shift a pointer towards a MSB
+
+			while (i < kmer_length)
+			{
+				if ((i_in_string == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
+				{
+					temp_byte_alignment--;
+					i++;
+				}
+				else
+				{
+					c_char = *(iter + i_in_string);
+					c_binary = num_codes[c_char];
+					c_binary = c_binary << 6;		//11000000
+					*byte_ptr = *byte_ptr | c_binary;
+					i++;
+					i_in_string++;
+					if (i_in_string == kmer_length) break;
+				}
+
+				if ((i_in_string == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
+				{
+					temp_byte_alignment--;
+					i++;
+				}
+				else
+				{
+					c_char = *(iter + i_in_string);
+					c_binary = num_codes[c_char];
+					c_binary = c_binary << 4;
+					*byte_ptr = *byte_ptr | c_binary;
+					i++;
+					i_in_string++;
+					if (i_in_string == kmer_length) break;
+				}
+
+				//!!!if((i == 0) && temp_byte_alignment)	//poprawka zg3oszona przez Maaka D3ugosza			// check if a byte_alignment placed before a prefix is to be skipped
+				if ((i_in_string == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
+				{
+					temp_byte_alignment--;
+					i++;
+				}
+				else
+				{
+					c_char = *(iter + i_in_string);
+					c_binary = num_codes[c_char];
+					c_binary = c_binary << 2;
+					*byte_ptr = *byte_ptr | c_binary;
+					i++;
+					i_in_string++;
+					if (i_in_string == kmer_length) break;
+				}
+
+				c_char = *(iter + i_in_string);
+				c_binary = num_codes[c_char];
+				*byte_ptr = *byte_ptr | c_binary;
+				i++;
+				i_in_string++;
+				if (i_in_string == kmer_length) break;
+
+				if (i % 32 == 0)
+					break; //check if a new "row" is to be started
+				byte_ptr--;
+			}
+		};
+		return true;
+	}
 public:
 	static const char char_codes[];
 	static char num_codes[256];
+	static uchar rev_comp_bytes_LUT[];
+	static uint64 alignment_mask[];
 	struct _si  
-    {   _si()
-        {
-            for(int i = 0; i < 256; i++)
+	{
+		_si()
+		{
+			for (int i = 0; i < 256; i++)
                 num_codes[i] = -1;
 			num_codes['A'] = num_codes['a'] = 0;
 			num_codes['C'] = num_codes['c'] = 1;
@@ -200,311 +403,163 @@ public:
 
 	};
 
-//-----------------------------------------------------------------------
-// Convert kmer into string (an alphabet ACGT)
-// RET	: string kmer
-//-----------------------------------------------------------------------
+	//-----------------------------------------------------------------------
+	// Convert kmer into string (an alphabet ACGT)
+	// RET	: string kmer
+	//-----------------------------------------------------------------------
 	inline std::string to_string()
 	{
-		std::string string_kmer;
-		uchar *byte_ptr;
-		uchar c;
-		uchar temp_byte_alignment = byte_alignment;
-		uint32 cur_string_size = 0;
+		std::string string_kmer;		
+		string_kmer.resize(kmer_length);
+		to_string_impl(string_kmer.begin());	
+		return string_kmer;
+	};
+	//-----------------------------------------------------------------------
+	// Convert kmer into string (an alphabet ACGT). The function assumes enough memory was allocated
+	// OUT	: str - string kmer. 
+	//-----------------------------------------------------------------------
+	inline void to_string(char *str)
+	{
+		to_string_impl(str);
+		str[kmer_length] = '\0';
+	};
 
-		string_kmer.reserve(kmer_length + 1);
-		string_kmer.resize(kmer_length + 1);
-		
+	//-----------------------------------------------------------------------
+	// Convert kmer into string (an alphabet ACGT)
+	// OUT 	: str - string kmer
+	//-----------------------------------------------------------------------
+	inline void to_string(std::string &str)
+	{	
+		str.resize(kmer_length);
+		to_string_impl(str.begin());
+	};
 
-		for(uint32 row_counter = 0; row_counter < no_of_rows; row_counter++)
+	//-----------------------------------------------------------------------
+	// Convert a string of an alphabet ACGT into a kmer of a CKmerAPI
+	// IN	: kmer_string	- a string of an alphabet ACGT
+	// RET	: true			- if succesfull
+	//-----------------------------------------------------------------------
+	inline bool from_string(const char* kmer_string)
+	{
+		uint32 len = 0;
+		for (;  kmer_string[len] != '\0' ; ++len)
 		{
-			byte_ptr = reinterpret_cast<uchar*>(&kmer_data[row_counter]);
-
-			byte_ptr += 7;					// shift a pointer towards a MSB
-		
-			for(uint32 i = 0; (i < kmer_length) && (i < 32); i += 4)		// 32 symbols of any "row" in kmer_data
-			{				
-				if((i == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
-					temp_byte_alignment--;						
-				else
-				{
-					c = 0xc0 & *byte_ptr;			//11000000
-					c = c >> 6;
-					string_kmer[cur_string_size++] = char_codes[c];
-					if (cur_string_size == kmer_length) break;
-				}
-
-				if((i == 0) && temp_byte_alignment)				// check if a  byte_alignment placed before a prefix is to be skipped
-					temp_byte_alignment--;						
-				else
-				{
-					c = 0x30 & *byte_ptr;			//00110000
-					c = c >> 4;
-					string_kmer[cur_string_size++] = char_codes[c];
-					if (cur_string_size == kmer_length) break;
-				}
-				
-				if((i == 0) && temp_byte_alignment)				// check if a  byte_alignment placed before a prefix is to be skipped
-					temp_byte_alignment--;						
-				else
-				{
-					c = 0x0c & *byte_ptr;			//00001100
-					c = c >> 2;
-					string_kmer[cur_string_size++] = char_codes[c];
-					if (cur_string_size == kmer_length) break;
-				}
-																// no need to check byte alignment as its length is at most 3 
-				c = 0x03 & *byte_ptr;			//00000011
-				string_kmer[cur_string_size++] = char_codes[c];
-				if (cur_string_size == kmer_length) break;
+			if (num_codes[(uchar)kmer_string[len]] == -1)
+				return false;
+		}
+		return from_string_impl(kmer_string, len);
+	}
 
-				byte_ptr--;
-			}
+	//-----------------------------------------------------------------------
+	// Convert a string of an alphabet ACGT into a kmer of a CKmerAPI
+	// IN	: kmer_string	- a string of an alphabet ACGT
+	// RET	: true			- if succesfull
+	//-----------------------------------------------------------------------
+	inline bool from_string(const std::string& kmer_string)
+	{					
+		for (uint32 ii = 0; ii < kmer_string.size(); ++ii)
+		{
+			if (num_codes[(uchar)kmer_string[ii]] == -1)
+				return false;
 		}
-		string_kmer[cur_string_size] = '\0';
-		return string_kmer;
-	};
-//-----------------------------------------------------------------------
-// Convert kmer into string (an alphabet ACGT). The function assumes enough memory was allocated
-// OUT	: str - string kmer. 
-//-----------------------------------------------------------------------
-	inline void to_string(char *str)
+		return from_string_impl(kmer_string.begin(), static_cast<uint32>(kmer_string.length()));		
+	}
+
+	//-----------------------------------------------------------------------
+	// Convert k-mer to its reverse complement
+	//-----------------------------------------------------------------------
+	inline bool reverse()
 	{
-		uchar *byte_ptr;
-		uchar c;
-		uchar temp_byte_alignment = byte_alignment;
-		uchar cur_string_size = 0;
-		
+		if (kmer_data == NULL)
+		{
+			return false;
+		}
+
+		// number of bytes used to store the k-mer in the 0-th row
+		const uint32 size_in_byte = ((kmer_length + byte_alignment) / 4) / no_of_rows;
+		uchar* byte1;
+		uchar* byte2;
 
-		for(uint32 row_counter = 0; row_counter < no_of_rows; row_counter++)
+		if (no_of_rows == 1)
 		{
-			byte_ptr = reinterpret_cast<uchar*>(&kmer_data[row_counter]);
+			*kmer_data <<= 2 * byte_alignment;
+			byte1 = reinterpret_cast<uchar*>(kmer_data)+8 - size_in_byte;
+			byte2 = reinterpret_cast<uchar*>(kmer_data)+7;
 
-			byte_ptr += 7;					// shift a pointer towards a MSB
-		
-			for(uint32 i = 0; (i < kmer_length) && (i < 32); i += 4)		// 32 symbols of any "row" in kmer_data
+			for (uint32 i_bytes = 0; i_bytes < size_in_byte / 2; ++i_bytes)
 			{
-				
-				if((i == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
-					temp_byte_alignment--;						
-				else
-				{
-					c = 0xc0 & *byte_ptr;			//11000000
-					c = c >> 6;
-					str[cur_string_size++] = char_codes[c];
-					if (cur_string_size == kmer_length) break;
-				}
+				unsigned char temp = rev_comp_bytes_LUT[*byte1];
+				*byte1 = rev_comp_bytes_LUT[*byte2];
+				*byte2 = temp;
 
-				if((i == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
-					temp_byte_alignment--;						
-				else
-				{
-					c = 0x30 & *byte_ptr;			//00110000
-					c = c >> 4;
-					str[cur_string_size++] = char_codes[c];
-					if (cur_string_size == kmer_length) break;
-				}
-				
-				if((i == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
-					temp_byte_alignment--;						
-				else
-				{
-					c = 0x0c & *byte_ptr;			//00001100
-					c = c >> 2;
-					str[cur_string_size++] = char_codes[c];
-					if (cur_string_size == kmer_length) break;
-				}
-																// no need to check byte alignment as its length is at most 3  
-				c = 0x03 & *byte_ptr;			//00000011
-				str[cur_string_size++] = char_codes[c];
-				if (cur_string_size == kmer_length) break;
+				++byte1;
+				--byte2;
+			}
 
-				byte_ptr--;
+			if (size_in_byte % 2)
+			{
+				*byte1 = rev_comp_bytes_LUT[*byte1];
 			}
 		}
-		str[cur_string_size] = '\0';
-	};
-
-//-----------------------------------------------------------------------
-// Convert kmer into string (an alphabet ACGT)
-// OUT 	: str - string kmer
-//-----------------------------------------------------------------------
-	 inline void to_string(std::string &str) 
-	 {
-		uchar *byte_ptr;
-		uchar c;
-		uchar temp_byte_alignment = byte_alignment;
-		uint32 cur_string_size = 0;
+		else
+		{
+			for (uint32 i_rows = no_of_rows - 1; i_rows > 0; --i_rows)
+			{
+				kmer_data[i_rows] >>= 64 - 8 * size_in_byte - 2 * byte_alignment;
 
-		str.reserve(kmer_length + 1);
-		str.resize(kmer_length + 1);
-		
+				// more significant row
+				uint64 previous = kmer_data[i_rows - 1];
+				previous <<= 8 * size_in_byte + 2 * byte_alignment;
+				kmer_data[i_rows] |= previous;
 
-		for(uint32 row_counter = 0; row_counter < no_of_rows; row_counter++)
-		{
-			byte_ptr = reinterpret_cast<uchar*>(&kmer_data[row_counter]);
+				byte1 = reinterpret_cast<uchar*>(kmer_data + i_rows);
+				byte2 = reinterpret_cast<uchar*>(kmer_data + i_rows) + 7;
 
-			byte_ptr += 7;					// shift a pointer towards a MSB
-		
-			for(uint32 i = 0; (i < kmer_length) && (i < 32); i += 4)		// 32 symbols of any "row" in kmer_data
-			{
-				
-				if((i == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
-					temp_byte_alignment--;						
-				else
+				for (int i_bytes = 0; i_bytes < 4; ++i_bytes)
 				{
-					c = 0xc0 & *byte_ptr;			//11000000
-					c = c >> 6;
-					str[cur_string_size++] = char_codes[c];
-					if (cur_string_size == kmer_length) break;
-				}
+					unsigned char temp = rev_comp_bytes_LUT[*byte1];
+					*byte1 = rev_comp_bytes_LUT[*byte2];
+					*byte2 = temp;
 
-				if((i == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
-					temp_byte_alignment--;						
-				else
-				{
-					c = 0x30 & *byte_ptr;			//00110000
-					c = c >> 4;
-					str[cur_string_size++] = char_codes[c];
-					if (cur_string_size == kmer_length) break;
+					++byte1;
+					--byte2;
 				}
-				
-				if((i == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
-					temp_byte_alignment--;						
-				else
-				{
-					c = 0x0c & *byte_ptr;			//00001100
-					c = c >> 2;
-					str[cur_string_size++] = char_codes[c];
-					if (cur_string_size == kmer_length) break;
-				}
-																// no need to check byte alignment as its length is at most 3 
-				c = 0x03 & *byte_ptr;			//00000011
-				str[cur_string_size++] = char_codes[c];
-				if (cur_string_size == kmer_length) break;
-
-				byte_ptr--;
 			}
-		}
-		str[cur_string_size] = '\0';
-	 };
 
-//-----------------------------------------------------------------------
-// Convert a string of an alphabet ACGT into a kmer of a CKmerAPI
-// IN	: kmer_string	- a string of an alphabet ACGT
-// RET	: true			- if succesfull
-//-----------------------------------------------------------------------
-	 inline bool from_string(std::string kmer_string)
-	 {
-		 unsigned char c_char;
-		 uchar c_binary;
-		 uchar temp_byte_alignment;
+			// clear less significant bits
+			kmer_data[0] >>= 64 - 8 * size_in_byte - 2 * byte_alignment;
+			kmer_data[0] <<= 64 - 8 * size_in_byte;
 
-		 for (uint32 ii = 0; ii < kmer_string.size(); ++ii)
-		 {
-		 if (num_codes[(uchar)kmer_string[ii]] == -1)
-			 return false;
-		 }
-		
+			byte1 = reinterpret_cast<uchar*>(kmer_data)+8 - size_in_byte;
+			byte2 = reinterpret_cast<uchar*>(kmer_data)+7;
 
-		if(kmer_length != kmer_string.size())	
-		{
-			if(kmer_length && kmer_data)
-				delete [] kmer_data;
-		
-			kmer_length = (uint32)kmer_string.size();
+			for (uint32 i_bytes = 0; i_bytes < size_in_byte / 2; ++i_bytes)
+			{
+				unsigned char temp = rev_comp_bytes_LUT[*byte1];
+				*byte1 = rev_comp_bytes_LUT[*byte2];
+				*byte2 = temp;
 
-			if(kmer_length % 4)
-				byte_alignment = 4 - (kmer_length % 4);	
-			else
-				byte_alignment = 0;
+				++byte1;
+				--byte2;
+			}
 
-			
-			if(kmer_length != 0)
+			if (size_in_byte % 2)
 			{
-				no_of_rows = (((kmer_length + byte_alignment) % 32) ? (kmer_length + byte_alignment) / 32 + 1 : (kmer_length + byte_alignment) / 32);
-				//no_of_rows = (int)ceil((double)(kmer_length + byte_alignment) / 32);
-				kmer_data = new uint64[no_of_rows];
-				//memset(kmer_data, 0, sizeof(*kmer_data) * no_of_rows);
+				*byte1 = rev_comp_bytes_LUT[*byte1];
 			}
-		}
-
-		memset(kmer_data, 0, sizeof(*kmer_data) * no_of_rows);
-		temp_byte_alignment = byte_alignment;
-		uint32 i = 0;
-		uint32 i_in_string = 0;
-		uchar *byte_ptr;
 
-		for(uint32 row_index = 0; row_index < no_of_rows; row_index++)
-		{
-			byte_ptr = reinterpret_cast<uchar*>(&kmer_data[row_index]);
-			byte_ptr += 7;					// shift a pointer towards a MSB
-
-			while(i < kmer_length)
+			for (uint32 i_rows = 0; i_rows < no_of_rows / 2; ++i_rows)
 			{
-				if((i_in_string == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
-				{															
-					temp_byte_alignment--;						
-					i++;
-				}
-				else
-				{
-					c_char = kmer_string[i_in_string];
-					c_binary = num_codes[c_char];
-					c_binary = c_binary << 6;		//11000000
-					*byte_ptr = *byte_ptr | c_binary;
-					i++;
-					i_in_string++;
-					if(i_in_string == kmer_length) break;
-				}
-
-				if((i_in_string == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
-				{
-					temp_byte_alignment--;						
-					i++;
-				}
-				else
-				{
-					c_char = kmer_string[i_in_string];
-					c_binary = num_codes[c_char];
-					c_binary = c_binary << 4;
-					*byte_ptr = *byte_ptr | c_binary;
-					i++;
-					i_in_string++;
-					if(i_in_string == kmer_length) break;
-				}
-
-				//!!!if((i == 0) && temp_byte_alignment)	//poprawka zg3oszona przez Maaka D3ugosza			// check if a byte_alignment placed before a prefix is to be skipped
-				if ((i_in_string == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
-				{
-					temp_byte_alignment--;						
-					i++;
-				}
-				else
-				{
-					c_char = kmer_string[i_in_string];
-					c_binary = num_codes[c_char];
-					c_binary = c_binary << 2;
-					*byte_ptr = *byte_ptr | c_binary;
-					i++;
-					i_in_string++;
-					if(i_in_string == kmer_length) break;
-				}
+				std::swap(kmer_data[i_rows], kmer_data[no_of_rows - i_rows - 1]);
+			}
+		}
 
-				c_char = kmer_string[i_in_string];
-				c_binary = num_codes[c_char];
-				*byte_ptr = *byte_ptr | c_binary;
-				i++;
-				i_in_string++;
-				if(i_in_string == kmer_length) break;
+		// clear alignment
+		*kmer_data &= alignment_mask[byte_alignment];
 
-				if( i % 32 == 0) 
-					break; //check if a new "row" is to be started
-				byte_ptr--;
-			}
-		};
 		return true;
 	}
+
 //-----------------------------------------------------------------------
 // Counts a signature of an existing kmer
 // IN	: sig_len	- the length of a signature
@@ -532,6 +587,7 @@ public:
 		 return min_mmr.get();
 	 }
 	
+	 
 };
 
 
diff --git a/kmc_api/kmer_defs.h b/kmc_api/kmer_defs.h
index 28cb709..e4b2b80 100644
--- a/kmc_api/kmer_defs.h
+++ b/kmc_api/kmer_defs.h
@@ -4,16 +4,16 @@
 
   Authors: Sebastian Deorowicz and Agnieszka Debudaj-Grabysz
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 
 #ifndef _KMER_DEFS_H
 #define _KMER_DEFS_H
 
-#define KMC_VER		"2.1.1"
-#define KMC_DATE	"2015-01-22"
+#define KMC_VER		"2.2.0"
+#define KMC_DATE	"2015-04-15"
 
 #define MIN(x,y)	((x) < (y) ? (x) : (y))
 
diff --git a/kmc_api/mmer.cpp b/kmc_api/mmer.cpp
index 7b5ecd1..ed3ea11 100644
--- a/kmc_api/mmer.cpp
+++ b/kmc_api/mmer.cpp
@@ -5,8 +5,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "../kmc_api/mmer.h"
diff --git a/kmc_api/mmer.h b/kmc_api/mmer.h
index 6ae7b63..79187f8 100644
--- a/kmc_api/mmer.h
+++ b/kmc_api/mmer.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _MMER_H
@@ -101,7 +101,7 @@ public:
 	inline void clear();
 	inline bool operator<=(const CMmer& x);
 	inline void set(const CMmer& x);
-	inline void insert(char* seq);
+	inline void insert(const char* seq);
 	
 };
 
@@ -155,7 +155,7 @@ inline void CMmer::set(const CMmer& x)
 }
 
 //--------------------------------------------------------------------------
-inline void CMmer::insert(char* seq)
+inline void CMmer::insert(const char* seq)
 {
 	switch (len)
 	{
diff --git a/kmc_dump/kmc_dump.cpp b/kmc_dump/kmc_dump.cpp
index fb59743..807dee6 100644
--- a/kmc_dump/kmc_dump.cpp
+++ b/kmc_dump/kmc_dump.cpp
@@ -7,8 +7,8 @@
 
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "stdafx.h"
@@ -90,7 +90,7 @@ int _tmain(int argc, char* argv[])
 
 		kmer_data_base.Info(_kmer_length, _mode, _counter_size, _lut_prefix_length, _signature_len, _min_count, _max_count, _total_kmers);
 
-		float counter;
+		
 		//std::string str;
 		char str[1024];
 		uint32 counter_len;
@@ -104,24 +104,31 @@ int _tmain(int argc, char* argv[])
 		if (!(kmer_data_base.SetMaxCount(max_count_to_set)))
 				return EXIT_FAILURE;	
 
-		while (kmer_data_base.ReadNextKmer(kmer_object, counter))
+		if (_mode) //quake compatible mode
 		{
-			kmer_object.to_string(str);
-
-			str[_kmer_length] = '\t';
-			if (_mode)
-				counter_len = CNumericConversions::Double2PChar(counter, 6, (uchar*)str + _kmer_length + 1);
-			else
-				counter_len = CNumericConversions::Int2PChar((uint64)counter, (uchar*)str + _kmer_length + 1);
-
-			str[_kmer_length + 1 + counter_len] = '\n';
-			fwrite(str, 1, _kmer_length + counter_len + 2, out_file);
-
-			/*if(_mode)		
-				fprintf(out_file, "%s\t%f\n", str.c_str(), counter);
-			else
-				fprintf(out_file, "%s\t%d\n", str.c_str(), (int)counter);*/
+			float counter;
+			while (kmer_data_base.ReadNextKmer(kmer_object, counter))
+			{
+				kmer_object.to_string(str);
+				str[_kmer_length] = '\t';				
+				counter_len = CNumericConversions::Double2PChar(counter, 6, (uchar*)str + _kmer_length + 1);				
+				str[_kmer_length + 1 + counter_len] = '\n';
+				fwrite(str, 1, _kmer_length + counter_len + 2, out_file);			
+			}
 		}
+		else
+		{
+			uint32 counter;
+			while (kmer_data_base.ReadNextKmer(kmer_object, counter))
+			{
+				kmer_object.to_string(str);
+				str[_kmer_length] = '\t';
+				counter_len = CNumericConversions::Int2PChar(counter, (uchar*)str + _kmer_length + 1);
+				str[_kmer_length + 1 + counter_len] = '\n';
+				fwrite(str, 1, _kmer_length + counter_len + 2, out_file);
+			}
+		}
+		
 	
 		fclose(out_file);
 		kmer_data_base.Close();
diff --git a/kmc_dump/nc_utils.cpp b/kmc_dump/nc_utils.cpp
index 935866c..049ce18 100644
--- a/kmc_dump/nc_utils.cpp
+++ b/kmc_dump/nc_utils.cpp
@@ -7,8 +7,8 @@
 
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "stdafx.h"
diff --git a/kmc_dump/nc_utils.h b/kmc_dump/nc_utils.h
index fbd57d3..fd0ebb3 100644
--- a/kmc_dump/nc_utils.h
+++ b/kmc_dump/nc_utils.h
@@ -7,8 +7,8 @@
 
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include <string>
diff --git a/kmc_dump_sample/kmc_dump_sample.cpp b/kmc_dump_sample/kmc_dump_sample.cpp
index 65a2448..afe878e 100644
--- a/kmc_dump_sample/kmc_dump_sample.cpp
+++ b/kmc_dump_sample/kmc_dump_sample.cpp
@@ -7,8 +7,8 @@
 
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "stdafx.h"
@@ -88,9 +88,6 @@ int _tmain(int argc, char* argv[])
 
 		kmer_data_base.Info(_kmer_length, _mode, _counter_size, _lut_prefix_length, _signature_len, _min_count, _max_count, _total_kmers);
 
-		float counter;
-		std::string str;
-		
 		CKmerAPI kmer_object(_kmer_length);
 		
 		if(min_count_to_set)
@@ -100,15 +97,27 @@ int _tmain(int argc, char* argv[])
 		if (!(kmer_data_base.SetMaxCount(max_count_to_set)))
 				return EXIT_FAILURE;	
 
-		while (kmer_data_base.ReadNextKmer(kmer_object, counter))
+		
+		std::string str;
+		if (_mode) //quake compatible mode
 		{
-			kmer_object.to_string(str);
-
-			if(_mode)		
-				fprintf(out_file, "%s\t%f\n", str.c_str(), counter);
-			else
-				fprintf(out_file, "%s\t%d\n", str.c_str(), (int)counter);
+			float counter;			
+			while (kmer_data_base.ReadNextKmer(kmer_object, counter))
+			{
+				kmer_object.to_string(str);	
+				fprintf(out_file, "%s\t%f\n", str.c_str(), counter);			
+			}
+		}
+		else 
+		{
+			uint32 counter;			
+			while (kmer_data_base.ReadNextKmer(kmer_object, counter))
+			{
+				kmer_object.to_string(str);
+				fprintf(out_file, "%s\t%u\n", str.c_str(), counter);
+			}
 		}
+		
 	
 		fclose(out_file);
 		kmer_data_base.Close();
diff --git a/kmer_counter.sln b/kmer_counter.sln
index df02101..dec003e 100644
--- a/kmer_counter.sln
+++ b/kmer_counter.sln
@@ -51,7 +51,7 @@ Global
 		{17823F37-86DE-4E58-B354-B84DA9EDA6A1}.Release|Mixed Platforms.Build.0 = Release|x64
 		{17823F37-86DE-4E58-B354-B84DA9EDA6A1}.Release|Win32.ActiveCfg = Release|Win32
 		{17823F37-86DE-4E58-B354-B84DA9EDA6A1}.Release|Win32.Build.0 = Release|Win32
-		{17823F37-86DE-4E58-B354-B84DA9EDA6A1}.Release|x64.ActiveCfg = Release|Win32
+		{17823F37-86DE-4E58-B354-B84DA9EDA6A1}.Release|x64.ActiveCfg = Release|x64
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/kmer_counter/asmlib_wrapper.h b/kmer_counter/asmlib_wrapper.h
index 3fe9147..2fd2794 100644
--- a/kmer_counter/asmlib_wrapper.h
+++ b/kmer_counter/asmlib_wrapper.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _ASMLIB_WRAPPER_H
diff --git a/kmer_counter/bkb_merger.h b/kmer_counter/bkb_merger.h
index 4cbf3db..3b95462 100644
--- a/kmer_counter/bkb_merger.h
+++ b/kmer_counter/bkb_merger.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _HBH_MERGER_H
diff --git a/kmer_counter/bkb_reader.cpp b/kmer_counter/bkb_reader.cpp
index 49df3c3..67d77c4 100644
--- a/kmer_counter/bkb_reader.cpp
+++ b/kmer_counter/bkb_reader.cpp
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "stdafx.h"
diff --git a/kmer_counter/bkb_reader.h b/kmer_counter/bkb_reader.h
index ec5baba..b04e8c3 100644
--- a/kmer_counter/bkb_reader.h
+++ b/kmer_counter/bkb_reader.h
@@ -5,8 +5,8 @@ The homepage of the KMC project is http://sun.aei.polsl.pl/kmc
 
 Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
 
-Version: 2.1.1
-Date   : 2015-01-22
+Version: 2.2.0
+Date   : 2015-04-15
 */
 
 #ifndef _BKB_READER_H_
diff --git a/kmer_counter/bkb_sorter.h b/kmer_counter/bkb_sorter.h
index f60254d..e52d45a 100644
--- a/kmer_counter/bkb_sorter.h
+++ b/kmer_counter/bkb_sorter.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _BKB_SORTER_H
diff --git a/kmer_counter/bkb_subbin.h b/kmer_counter/bkb_subbin.h
index 8f164c9..c814852 100644
--- a/kmer_counter/bkb_subbin.h
+++ b/kmer_counter/bkb_subbin.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _BKB_SUBBIN_H
diff --git a/kmer_counter/bkb_uncompactor.h b/kmer_counter/bkb_uncompactor.h
index 9e728f7..ab375e0 100644
--- a/kmer_counter/bkb_uncompactor.h
+++ b/kmer_counter/bkb_uncompactor.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _BKB_UNCOMPACTOR_H
diff --git a/kmer_counter/bkb_writer.cpp b/kmer_counter/bkb_writer.cpp
index 455cff9..c86d66b 100644
--- a/kmer_counter/bkb_writer.cpp
+++ b/kmer_counter/bkb_writer.cpp
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "stdafx.h"
diff --git a/kmer_counter/bkb_writer.h b/kmer_counter/bkb_writer.h
index 3e49838..5d064da 100644
--- a/kmer_counter/bkb_writer.h
+++ b/kmer_counter/bkb_writer.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _BKB_WRITER_H
diff --git a/kmer_counter/defs.h b/kmer_counter/defs.h
index cbfd2c4..dc10c50 100644
--- a/kmer_counter/defs.h
+++ b/kmer_counter/defs.h
@@ -4,15 +4,15 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _DEFS_H
 #define _DEFS_H
 
-#define KMC_VER		"2.1.1"
-#define KMC_DATE	"2015-01-22"
+#define KMC_VER		"2.2.0"
+#define KMC_DATE	"2015-04-15"
 
 #define _CRT_SECURE_NO_WARNINGS
 
diff --git a/kmer_counter/develop.cpp b/kmer_counter/develop.cpp
new file mode 100644
index 0000000..dd10a26
--- /dev/null
+++ b/kmer_counter/develop.cpp
@@ -0,0 +1,142 @@
+#include "stdafx.h"
+
+#include "develop.h"
+#include "params.h"
+#include <iostream>
+using namespace std;
+
+void map_log(uint32 signature_len, uint32 map_size, int32* signature_map)
+{
+	#ifdef MAP_LOG_SRC
+		FILE* mapLogFile = fopen(MAP_LOG_SRC, "w");
+		char ACGT[10];
+		ACGT[signature_len] = '\0';
+		char symbols[] = { 'A', 'C', 'G', 'T' };
+		if (!mapLogFile)
+		{
+			cout << "Cannot save map log to file";
+			exit(1);
+		}
+		fprintf(mapLogFile, "SIGNMATURE | ACGT | BIN NO\n");
+		for (uint32 i = 0; i < map_size; ++i)
+		{
+	
+			for (int j = signature_len - 1; j >= 0; --j)
+				ACGT[signature_len - j - 1] = symbols[(i >> 2 * j) & 3];
+	
+			if (signature_map[i] >= 0)
+				fprintf(mapLogFile, "%i\t\t%s\t%i\n", i, ACGT, signature_map[i]);
+			else
+				fprintf(mapLogFile, "%i\t\t%s\tDISABLED_SIGNATURE\n", i, ACGT);
+		}
+	
+		fclose(mapLogFile);
+	#endif
+}
+
+
+
+void save_bins_stats(CKMCQueues& Queues, CKMCParams& Params, uint32 kmer_size, uint32 quality_size, uint64 n_reads)
+{
+#ifdef KMERS_PER_BIN_LOG_FILE
+	int32 bin_id;
+	CMemDiskFile *file;
+	string name;
+	uint64 n_rec;
+	uint64 n_plus_x_recs;
+	uint64 n_super_kmers;
+	uint64 size;
+
+	Queues.bd->reset_reading();
+	FILE* stats_file = fopen(KMERS_PER_BIN_LOG_FILE, "w");
+	uint64 sum_size, sum_n_rec, sum_n_plus_x_recs, sum_n_super_kmers;
+	sum_size = sum_n_rec = sum_n_plus_x_recs = sum_n_super_kmers = 0;
+	if (!stats_file)
+	{
+		cout << "cannot open file to store kmers per bin: " << KMERS_PER_BIN_LOG_FILE << "\n";
+		exit(1);
+	}
+	fprintf(stats_file, "%12s%12s%12s%12s%12s\n", "bin_id", "n_rec", "n_super_kmers", "size", "sorted mem");
+	while ((bin_id = Queues.bd->get_next_bin()) >= 0)
+	{
+		Queues.bd->read(bin_id, file, name, size, n_rec, n_plus_x_recs, n_super_kmers);
+
+
+
+
+		// Reserve memory necessary to process the current bin at all next stages
+		uint64 input_kmer_size;
+		int64 kxmer_counter_size;
+		uint32 kxmer_symbols;
+		if (Params.max_x && !Params.use_quake)
+		{
+			input_kmer_size = n_plus_x_recs * kmer_size;
+			kxmer_counter_size = n_plus_x_recs * sizeof(uint32);
+			kxmer_symbols = Params.kmer_len + Params.max_x + 1;
+		}
+		else
+		{
+			input_kmer_size = n_rec * kmer_size;
+			kxmer_counter_size = 0;
+			kxmer_symbols = Params.kmer_len;
+		}
+		uint64 max_out_recs = (n_rec + 1) / max(Params.cutoff_min, 1);
+
+		std::function<int64(int64)> round_up_to_alignment = [](int64 x){ return (x + ALIGNMENT - 1) / ALIGNMENT * ALIGNMENT; };
+
+
+		uint64 counter_size = min(BYTE_LOG(Params.cutoff_max), BYTE_LOG(Params.counter_max));
+		if (quality_size > counter_size)
+			counter_size = quality_size;
+
+		uint32 kmer_symbols = Params.kmer_len - Params.lut_prefix_len;
+		uint64 kmer_bytes = kmer_symbols / 4;
+		uint64 out_buffer_size = max_out_recs * (kmer_bytes + counter_size);
+
+		uint32 rec_len = (kxmer_symbols + 3) / 4;
+
+		uint64 lut_recs = 1 << (2 * Params.lut_prefix_len);
+		uint64 lut_size = lut_recs * sizeof(uint64);
+
+
+		size = round_up_to_alignment(size);
+		input_kmer_size = round_up_to_alignment(input_kmer_size);
+		out_buffer_size = round_up_to_alignment(out_buffer_size);
+		kxmer_counter_size = round_up_to_alignment(kxmer_counter_size);
+		lut_size = round_up_to_alignment(lut_size);
+
+
+		int64 part1_size;
+		int64 part2_size;
+
+		if (rec_len % 2 == 0)
+		{
+			part1_size = input_kmer_size + kxmer_counter_size;
+			part2_size = max(max(size, input_kmer_size), out_buffer_size + lut_size);
+		}
+		else
+		{
+			part1_size = max(input_kmer_size + kxmer_counter_size, size);
+			part2_size = max(input_kmer_size, out_buffer_size + lut_size);
+		}
+		int64 req_size = part1_size + part2_size;
+
+
+
+
+		fprintf(stats_file, "%12i%12llu%12llu%12llu%12llu\n", bin_id, n_rec, n_super_kmers, size, (uint64)req_size);
+		sum_size += size;
+		sum_n_rec += n_rec;
+		sum_n_plus_x_recs += n_plus_x_recs;
+		sum_n_super_kmers += n_super_kmers;
+	}
+
+	fprintf(stats_file, "%12s%12llu%12llu%12llu\n", "SUMMARY", sum_n_rec, sum_n_super_kmers, sum_size);
+	fprintf(stats_file, "n_reads: %llu\n", n_reads);
+
+	fclose(stats_file);
+
+	exit(1);
+#endif
+}
+
diff --git a/kmer_counter/develop.h b/kmer_counter/develop.h
new file mode 100644
index 0000000..903a2a4
--- /dev/null
+++ b/kmer_counter/develop.h
@@ -0,0 +1,16 @@
+#ifndef _DEVELOP_H
+#define _DEVELOP_H
+
+#include "defs.h"
+
+#define MAP_LOG_SRC "map.log"
+#define KMERS_PER_BIN_LOG_FILE "kmers_per_bin.log"
+
+void map_log(uint32 signature_len, uint32 map_size, int32* signature_map);
+
+struct CKMCQueues;
+struct CKMCParams;
+void save_bins_stats(CKMCQueues& Queues, CKMCParams& Params, uint32 kmer_size, uint32 quality_size, uint64 n_reads);
+
+
+#endif
\ No newline at end of file
diff --git a/kmer_counter/fastq_reader.cpp b/kmer_counter/fastq_reader.cpp
index 3a6efe6..844a113 100644
--- a/kmer_counter/fastq_reader.cpp
+++ b/kmer_counter/fastq_reader.cpp
@@ -5,8 +5,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include <algorithm>
diff --git a/kmer_counter/fastq_reader.h b/kmer_counter/fastq_reader.h
index e815dbe..5132d23 100644
--- a/kmer_counter/fastq_reader.h
+++ b/kmer_counter/fastq_reader.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _FASTQ_READER_H
diff --git a/kmer_counter/kb_collector.h b/kmer_counter/kb_collector.h
index 2a36bd2..1b2278b 100644
--- a/kmer_counter/kb_collector.h
+++ b/kmer_counter/kb_collector.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _KB_COLLECTOR_H
diff --git a/kmer_counter/kb_completer.cpp b/kmer_counter/kb_completer.cpp
index a5c1540..babf0fa 100644
--- a/kmer_counter/kb_completer.cpp
+++ b/kmer_counter/kb_completer.cpp
@@ -5,8 +5,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 #include <algorithm>
 #include <numeric>
diff --git a/kmer_counter/kb_completer.h b/kmer_counter/kb_completer.h
index ef1c55d..fd01f5c 100644
--- a/kmer_counter/kb_completer.h
+++ b/kmer_counter/kb_completer.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 #ifndef _KB_COMPLETER_H
 #define _KB_COMPLETER_H
diff --git a/kmer_counter/kb_reader.h b/kmer_counter/kb_reader.h
index 54bef28..e91f3f9 100644
--- a/kmer_counter/kb_reader.h
+++ b/kmer_counter/kb_reader.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _KB_READER_H
diff --git a/kmer_counter/kb_sorter.h b/kmer_counter/kb_sorter.h
index 4816d20..8feb565 100644
--- a/kmer_counter/kb_sorter.h
+++ b/kmer_counter/kb_sorter.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _KB_SORTER_H
diff --git a/kmer_counter/kb_storer.cpp b/kmer_counter/kb_storer.cpp
index 179fde6..7cccf1d 100644
--- a/kmer_counter/kb_storer.cpp
+++ b/kmer_counter/kb_storer.cpp
@@ -5,8 +5,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 #include <algorithm>
 #include <numeric>
diff --git a/kmer_counter/kb_storer.h b/kmer_counter/kb_storer.h
index 96512ed..4067116 100644
--- a/kmer_counter/kb_storer.h
+++ b/kmer_counter/kb_storer.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _KB_STORER_H
diff --git a/kmer_counter/kmc.h b/kmer_counter/kmc.h
index b4f9865..a11241f 100644
--- a/kmer_counter/kmc.h
+++ b/kmer_counter/kmc.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _KMC_H
diff --git a/kmer_counter/kmer.cpp b/kmer_counter/kmer.cpp
index b6e5a59..6779a84 100644
--- a/kmer_counter/kmer.cpp
+++ b/kmer_counter/kmer.cpp
@@ -5,8 +5,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "defs.h"
diff --git a/kmer_counter/kmer.h b/kmer_counter/kmer.h
index 764ad32..be0e4a5 100644
--- a/kmer_counter/kmer.h
+++ b/kmer_counter/kmer.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _KMER_H
diff --git a/kmer_counter/kmer_counter.cpp b/kmer_counter/kmer_counter.cpp
index 24ae01a..df805dc 100644
--- a/kmer_counter/kmer_counter.cpp
+++ b/kmer_counter/kmer_counter.cpp
@@ -5,8 +5,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include <fstream>
@@ -137,7 +137,7 @@ void usage()
 	cout << "Options:\n";
 	cout << "  -v - verbose mode (shows all parameter settings); default: false\n";
 	cout << "  -k<len> - k-mer length (k from " << MIN_K << " to " << MAX_K << "; default: 25)\n";
-	cout << "  -m<size> - max amount of RAM in GB (from 4 to 1024); default: 12\n";
+	cout << "  -m<size> - max amount of RAM in GB (from 1 to 1024); default: 12\n";
 	cout << "  -sm - use strict memory mode (memory limit from -m<n> switch will not be exceeded)\n";
 	cout << "  -p<par> - signature length (5, 6, 7, 8); default: 7\n";
 	cout << "  -f<a/q/m> - input in FASTA format (-fa), FASTQ format (-fq) or mulit FASTA (-fm); default: FASTQ\n";
diff --git a/kmer_counter/kmer_counter.vcxproj b/kmer_counter/kmer_counter.vcxproj
index 4f34344..207867f 100644
--- a/kmer_counter/kmer_counter.vcxproj
+++ b/kmer_counter/kmer_counter.vcxproj
@@ -171,6 +171,7 @@
     <ClInclude Include="bkb_subbin.h" />
     <ClInclude Include="bkb_writer.h" />
     <ClInclude Include="defs.h" />
+    <ClInclude Include="develop.h" />
     <ClInclude Include="fastq_reader.h" />
     <ClInclude Include="bkb_uncompactor.h" />
     <ClInclude Include="kb_collector.h" />
@@ -202,6 +203,7 @@
   <ItemGroup>
     <ClCompile Include="bkb_reader.cpp" />
     <ClCompile Include="bkb_writer.cpp" />
+    <ClCompile Include="develop.cpp" />
     <ClCompile Include="fastq_reader.cpp" />
     <ClCompile Include="kb_completer.cpp" />
     <ClCompile Include="kb_storer.cpp" />
diff --git a/kmer_counter/kxmer_set.h b/kmer_counter/kxmer_set.h
index ef62c43..df0b800 100644
--- a/kmer_counter/kxmer_set.h
+++ b/kmer_counter/kxmer_set.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 #ifndef _KXMER_SET_
 #define _KXMER_SET_
diff --git a/kmer_counter/mem_disk_file.cpp b/kmer_counter/mem_disk_file.cpp
index fb82ec1..3ea4774 100644
--- a/kmer_counter/mem_disk_file.cpp
+++ b/kmer_counter/mem_disk_file.cpp
@@ -5,8 +5,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "mem_disk_file.h"
diff --git a/kmer_counter/mem_disk_file.h b/kmer_counter/mem_disk_file.h
index 7f95d10..9ee816d 100644
--- a/kmer_counter/mem_disk_file.h
+++ b/kmer_counter/mem_disk_file.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _MEM_DISK_FILE_H
diff --git a/kmer_counter/meta_oper.h b/kmer_counter/meta_oper.h
index 6bd0b20..9d82a1d 100644
--- a/kmer_counter/meta_oper.h
+++ b/kmer_counter/meta_oper.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _META_OPER_H
diff --git a/kmer_counter/mmer.cpp b/kmer_counter/mmer.cpp
index 69f0d1a..814467d 100644
--- a/kmer_counter/mmer.cpp
+++ b/kmer_counter/mmer.cpp
@@ -5,8 +5,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "mmer.h"
diff --git a/kmer_counter/mmer.h b/kmer_counter/mmer.h
index ad72a45..b4e40c1 100644
--- a/kmer_counter/mmer.h
+++ b/kmer_counter/mmer.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _MMER_H
@@ -101,7 +101,7 @@ public:
 	inline void clear();
 	inline bool operator<=(const CMmer& x);
 	inline void set(const CMmer& x);
-	inline void insert(char* seq);
+	inline void insert(const char* seq);
 	
 };
 
@@ -155,7 +155,7 @@ inline void CMmer::set(const CMmer& x)
 }
 
 //--------------------------------------------------------------------------
-inline void CMmer::insert(char* seq)
+inline void CMmer::insert(const char* seq)
 {
 	switch (len)
 	{
diff --git a/kmer_counter/params.h b/kmer_counter/params.h
index eb451ec..77c6cab 100644
--- a/kmer_counter/params.h
+++ b/kmer_counter/params.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _PARAMS_H
diff --git a/kmer_counter/queues.h b/kmer_counter/queues.h
index 5efe94b..b3b9611 100644
--- a/kmer_counter/queues.h
+++ b/kmer_counter/queues.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _QUEUES_H
diff --git a/kmer_counter/radix.cpp b/kmer_counter/radix.cpp
index 7ad20bc..b2c07a2 100644
--- a/kmer_counter/radix.cpp
+++ b/kmer_counter/radix.cpp
@@ -5,8 +5,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include <stdio.h>
diff --git a/kmer_counter/radix.h b/kmer_counter/radix.h
index 203e6fc..62efcad 100644
--- a/kmer_counter/radix.h
+++ b/kmer_counter/radix.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 #ifndef _RADIX_H
 #define _RADIX_H
diff --git a/kmer_counter/rev_byte.cpp b/kmer_counter/rev_byte.cpp
index 496b4c7..66ec8c0 100644
--- a/kmer_counter/rev_byte.cpp
+++ b/kmer_counter/rev_byte.cpp
@@ -5,8 +5,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #include "rev_byte.h"
diff --git a/kmer_counter/rev_byte.h b/kmer_counter/rev_byte.h
index 29add6a..ecf481f 100644
--- a/kmer_counter/rev_byte.h
+++ b/kmer_counter/rev_byte.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _REV_BYTE_H
diff --git a/kmer_counter/s_mapper.h b/kmer_counter/s_mapper.h
index e93566b..ca444c8 100644
--- a/kmer_counter/s_mapper.h
+++ b/kmer_counter/s_mapper.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _S_MAPPER_H
diff --git a/kmer_counter/splitter.h b/kmer_counter/splitter.h
index 69b68a1..e81582d 100644
--- a/kmer_counter/splitter.h
+++ b/kmer_counter/splitter.h
@@ -4,8 +4,8 @@
   
   Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
   
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _SPLITTER_H
diff --git a/kmer_counter/timer.cpp b/kmer_counter/timer.cpp
index 2c04f6a..d9dfbff 100644
--- a/kmer_counter/timer.cpp
+++ b/kmer_counter/timer.cpp
@@ -6,8 +6,8 @@
   The source codes are based on codes written by Dennis and published:
     http://allmybrain.com/2008/06/10/timing-cc-code-on-linux/
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifdef WIN32
diff --git a/kmer_counter/timer.h b/kmer_counter/timer.h
index da7c435..784fb25 100644
--- a/kmer_counter/timer.h
+++ b/kmer_counter/timer.h
@@ -5,8 +5,8 @@
   The source codes are based on codes written by Dennis and published:
     http://allmybrain.com/2008/06/10/timing-cc-code-on-linux/
 
-  Version: 2.1.1
-  Date   : 2015-01-22
+  Version: 2.2.0
+  Date   : 2015-04-15
 */
 
 #ifndef _TIMER_H

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/kmc.git



More information about the debian-med-commit mailing list