modified: nfig1.py
[GalaxyCodeBases.git] / BGI / BASE / src / 2bwt / DNACount.h
blob6d961eb352572cd6622a2dfdf059dbba6e65270c
1 /*
3 DNACount.h DNA Count
5 This module contains DNA occurrence counting functions. The DNA must be
6 in word-packed format.
8 Copyright (C) 2004, Wong Chi Kwong.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #ifndef __DNA_COUNT_H__
27 #define __DNA_COUNT_H__
29 #include "TypeNLimit.h"
31 // DNA
32 #define DNA_ALPHABET_SIZE 8
33 #define DNA_CHAR_PER_WORD 8
34 #define DNA_BIT_PER_CHAR 4
36 // DNA occurrence count table
37 #define DNA_OCC_CNT_TABLE_SIZE_IN_WORD 65536
38 #define DNA_OCC_SUM_EXCEPTION(sum) ((sum & 0xeeeeeeeeeeeeeeef) == 0) //fefefeff
40 // DNA with 'n'
41 #define DNA_N_ALPHABET_SIZE 5
42 #define DNA_N_CHAR_PER_WORD 10
43 #define DNA_N_BIT_PER_CHAR 3
45 // DNA with 'n' occurrence count table
46 #define DNA_N_OCC_CNT_TABLE_SIZE_IN_WORD 32786
49 void GenerateDNAOccCountTable(unsigned long long *dnaDecodeTable);
51 // The following functions can only count up to 255 characters
52 unsigned long long ForwardDNAOccCount(const unsigned int* dna, const unsigned long long index, const unsigned int character, const unsigned long long* dnaDecodeTable);
53 unsigned long long BackwardDNAOccCount(const unsigned int* dna, const unsigned long long index, const unsigned int character, const unsigned long long* dnaDecodeTable);
54 void ForwardDNAAllOccCount(const unsigned int* dna, const unsigned long long index, unsigned long long* __restrict occCount, const unsigned long long* dnaDecodeTable);
55 void BackwardDNAAllOccCount(const unsigned int* dna, const unsigned long long index, unsigned long long* __restrict occCount, const unsigned long long* dnaDecodeTable);
56 unsigned long long Forward1OccCount(const unsigned int* bitVector, const unsigned long long index, const unsigned long long* dnaDecodeTable); // Count number of 1 bit
57 unsigned long long Backward1OccCount(const unsigned int* bitVector, const unsigned long long index, const unsigned long long* dnaDecodeTable); // Count number of 1 bit
59 // The following functions have no limit on the number of characters
60 unsigned long long ForwardDNAOccCountNoLimit(const unsigned int* dna, const unsigned long long index, const unsigned int character, const unsigned long long* dnaDecodeTable);
61 unsigned long long BackwardDNAOccCountNoLimit(const unsigned int* dna, const unsigned long long index, const unsigned int character, const unsigned long long* dnaDecodeTable);
62 void ForwardDNAAllOccCountNoLimit(const unsigned int* dna, const unsigned long long index, unsigned long long* __restrict occCount, const unsigned long long* dnaDecodeTable);
63 void BackwardDNAAllOccCountNoLimit(const unsigned int* dna, const unsigned long long index, unsigned long long* __restrict occCount, const unsigned long long* dnaDecodeTable);
66 void GenerateDNA_NOccCountTable(unsigned int *dnaDecodeTable);
68 // The following functions have no limit on the number of characters
69 unsigned long long ForwardDNA_NOccCount(const unsigned int* dna, const unsigned long long index, const unsigned int character, const unsigned long long* dnaDecodeTable);
70 unsigned long long BackwardDNA_NOccCount(const unsigned int* dna, const unsigned long long index, const unsigned int character, const unsigned long long* dnaDecodeTable);
71 void ForwardDNA_NAllOccCount(const unsigned int* dna, const unsigned long long index, unsigned long long* __restrict occCount, const unsigned long long* dnaDecodeTable);
72 void BackwardDNA_NAllOccCount(const unsigned int* dna, const unsigned long long index, unsigned long long* __restrict occCount, const unsigned long long* dnaDecodeTable);
74 // The following functions have no limit on the number of characters
75 unsigned long long ForwardDNAnOccCountNoLimit(const unsigned int* dna, const unsigned long long index, const unsigned int character, const unsigned long long* dnaDecodeTable);
76 unsigned long long BackwardDNA_NOccCountNoLimit(const unsigned int* dna, const unsigned long long index, const unsigned int character, const unsigned long long* dnaDecodeTable);
77 void ForwardDNA_NAllOccCountNoLimit(const unsigned int* dna, const unsigned long long index, unsigned long long* __restrict occCount, const unsigned long long* dnaDecodeTable);
78 void BackwardDNA_NAllOccCountNoLimit(const unsigned int* dna, const unsigned long long index, unsigned long long* __restrict occCount, const unsigned long long* dnaDecodeTable);
80 // The first character from startAddr is indexed as 1
81 // DNA_NAllOccCount only count occurrence from character 0 to 3
83 // The following functions work for any word packed text
84 unsigned long long ForwardOccCount(const unsigned int* packed, const unsigned long long index, const unsigned int character, const unsigned int alphabetSize);
85 unsigned long long BackwardOccCount(const unsigned int* packed, const unsigned long long index, const unsigned int character, const unsigned int alphabetSize);
86 void ForwardAllOccCount(const unsigned int* packed, const unsigned long long index, const unsigned int alphabetSize, unsigned long long* occCount);
87 void BackwardAllOccCount(const unsigned int* packed, const unsigned long long index, const unsigned int alphabetSize, unsigned long long* occCount);
90 #endif