1 /*
2 Copyright 2007, 2008, 2009 Daniel Zerbino (zerbino@ebi.ac.uk)
3 
4     This file is part of Velvet.
5 
6     Velvet is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10 
11     Velvet is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with Velvet; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 
20 */
21 #ifndef _KMER_H_
22 #define _KMER_H_
23 
24 #include <stdint.h>
25 
26 #include "globals.h"
27 
28 void copyKmers(Kmer* k1, Kmer* k2);
29 
30 void pushNucleotide(Kmer * kmer, Nucleotide nucleotide);
31 Nucleotide popNucleotide(Kmer * kmer);
32 
33 int compareKmers(Kmer* k1, Kmer* k2);
34 
35 void reversePushNucleotide(Kmer * kmer, Nucleotide nucleotide);
36 
37 KmerKey getKmerKey(Kmer * kmer);
38 
39 void printKmer(Kmer * kmer);
40 
41 void clearKmer(Kmer * kmer);
42 
43 void resetWordFilter(int wordLength);
44 void resetKeyFilter(int keyLength);
45 
46 #define KMER_QUOTIENT (MAXKMERLENGTH / 4)
47 #define KMER_REMAINDER (MAXKMERLENGTH % 4)
48 #if KMER_REMAINDER
49 #define KMER_BYTE_SIZE (KMER_QUOTIENT + 1)
50 #else
51 #define KMER_BYTE_SIZE KMER_QUOTIENT
52 #endif
53 #define KMER_LONGLONGS (KMER_BYTE_SIZE / 8)
54 #define KMER_LONGS ((KMER_BYTE_SIZE % 8) / 4)
55 #define KMER_INTS ((KMER_BYTE_SIZE % 4) / 2)
56 #define KMER_CHARS (KMER_BYTE_SIZE % 2)
57 
58 struct kmer_st {
59 #if KMER_LONGLONGS
60 	uint64_t longlongs[KMER_LONGLONGS];
61 #endif
62 #if KMER_LONGS
63 	uint32_t longs;
64 #endif
65 #if KMER_INTS
66 	uint16_t ints;
67 #endif
68 #if KMER_CHARS
69 	uint8_t chars;
70 #endif
71 }  ATTRIBUTE_PACKED;
72 
73 #endif
74