/* Philip T.L.C. Clausen Jan 2017 plan@dtu.dk */

/*
 Copyright (c) 2017, Philip Clausen, Technical University of Denmark
 All rights reserved.

 Licensed 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.
*/


Introduction

KmerResistance correlates mapped genes with the predicted species of WGS
samples, where this this allows for identification of genes in samples which 
have been poorly sequenced or high accuracy predictions for samples with
contamination.
KmerResistance has one dependency, namely KMA to perform the mapping, which is 
also freely available.

If you use KmerResistance for your published research, then please cite the 
KmerResistance and KMA paper.


Compilation

Any c-compiler can be used, here GCC.
gcc -O3 -o kmerresistance KmerResistance.c -lm


Indexing
Databases has to set up with KMA. The resistance genes needs standard indexing
while the species database needs to Sparse.

# Templates, e.g. resistance genes:
kma_index -i ResFinder.fsa -o ResFinder

# Species database (or other host database):
kma_index -i bacteria.fsa -o bacteria -Sparse ATG


Mapping with KmerResistance

# KmerResistance-2.0 correlates genes to species from WGS data, by mapping reads with KMA
# Options are:		Desc:							Default:		Requirements:
#
#	-i				Input/query file name							REQUIRED
#	-o				Output file										REQUIRED
#	-t_db			Template DB										REQUIRED
#	-s_db			Species DB										REQUIRED
#	-t_k			Template kmersize				16
#	-s_k			Species kmersize				16
#	-id				ID threshhold					80.0
#	-dct			Depth correction				0.1
#	-kma			alternative KMA					kma
#
# KMA options:		Desc:							Default:		Requirements:
#	-i				Input/query file name			None			REQUIRED
#	-o				Output file						None			REQUIRED
#	-t_db			Template DB						None			REQUIRED
#	-k				Kmersize						16
#	-e				evalue							0.05
#	-delta			Allocation size for sequences	512
#	-mem_mode		Use kmers to choose best
#					template, and save memory		False
#	-ex_mode		Searh kmers exhaustively		False
#	-deCon			Remove contamination			False
#	-dense			Do not allow insertions
#					in assembly						False
#	-ref_fsa		Consensus sequnce will
#					have "n" instead of gaps		False
#	-matrix			Print assembly matrix			False
#	-mp				Minimum phred score				30
#	-5p				Cut a constant number of
#					nucleotides from the 5 prime.	0
#	-CS				Chain size						8 MB
#	-MS				Max chain size					14 GB
#	-Sparse			Run KmerFinder					False
#	-ID				Minimum ID						1.0%
#	-ss				Sparse sorting (q,c,d)			q
#	-NW				Use Needleman-Wunsch			False
#	-shm			Use shared DB made by kma_ssm	False
#	-1t1			Skip HMM						False
#	-mrs			Minimum alignment score score,
#					normalized to alignment length	0.0
#	-h				Shows this help message
#


Mapping reads against resistance genes:
kmerresistance -i sample_1.fastq sample_2.fastq -o out /
-t_db ResFinder -s_db bacteria


Output:
*.KmerRes	KmerResistance output
*.res		Result file, containing summary of output.
*.aln		Consensus alignment.
*.fsa		Consensus sequences drawn from mappings.
*.frag		Information about each mapping read, containing:
			Read, #matches, aln score, start, end, template, read name
*.mat.gz	Count of each called nucleotide on each position in all mapped 
			templates, requires that the "-matrix" option is enabled when 
			mapping. The columns are:
			Ref. nucleotide, #A, #T, #C, #G, #N, #-.


Questions
If you have any questions regarding KmerResistance or KMA, or wishes for 
changes in future versions of KmerResistance or KMA, then feel free to mail me 
at: plan@dtu.dk.

