limit fstBC to 30bp in Python3 ver.
[GalaxyCodeBases.git] / BGI / soap_src / soap_builder / DNACount.h
blob5aec4518cb33564ca5de1df812dfcbdf64060906
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 4
33 #define DNA_CHAR_PER_WORD 16
34 #define DNA_BIT_PER_CHAR 2
36 // DNA occurrence count table
37 #define DNA_OCC_CNT_TABLE_SIZE_IN_WORD 65536
38 #define DNA_OCC_SUM_EXCEPTION(sum) ((sum & 0xfefefeff) == 0)
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 int *dnaDecodeTable);
51 // The following functions can only count up to 255 characters
52 unsigned int ForwardDNAOccCount(const unsigned int* dna, const unsigned int index, const unsigned int character, const unsigned int* dnaDecodeTable);
53 unsigned int BackwardDNAOccCount(const unsigned int* dna, const unsigned int index, const unsigned int character, const unsigned int* dnaDecodeTable);
54 void ForwardDNAAllOccCount(const unsigned int* dna, const unsigned int index, unsigned int* __restrict occCount, const unsigned int* dnaDecodeTable);
55 void BackwardDNAAllOccCount(const unsigned int* dna, const unsigned int index, unsigned int* __restrict occCount, const unsigned int* dnaDecodeTable);
56 unsigned int Forward1OccCount(const unsigned int* bitVector, const unsigned int index, const unsigned int* dnaDecodeTable); // Count number of 1 bit
57 unsigned int Backward1OccCount(const unsigned int* bitVector, const unsigned int index, const unsigned int* dnaDecodeTable); // Count number of 1 bit
59 // The following functions have no limit on the number of characters
60 unsigned int ForwardDNAOccCountNoLimit(const unsigned int* dna, const unsigned int index, const unsigned int character, const unsigned int* dnaDecodeTable);
61 unsigned int BackwardDNAOccCountNoLimit(const unsigned int* dna, const unsigned int index, const unsigned int character, const unsigned int* dnaDecodeTable);
62 void ForwardDNAAllOccCountNoLimit(const unsigned int* dna, const unsigned int index, unsigned int* __restrict occCount, const unsigned int* dnaDecodeTable);
63 void BackwardDNAAllOccCountNoLimit(const unsigned int* dna, const unsigned int index, unsigned int* __restrict occCount, const unsigned int* dnaDecodeTable);
66 void GenerateDNA_NOccCountTable(unsigned int *dnaDecodeTable);
68 // The following functions have no limit on the number of characters
69 unsigned int ForwardDNA_NOccCount(const unsigned int* dna, const unsigned int index, const unsigned int character, const unsigned int* dnaDecodeTable);
70 unsigned int BackwardDNA_NOccCount(const unsigned int* dna, const unsigned int index, const unsigned int character, const unsigned int* dnaDecodeTable);
71 void ForwardDNA_NAllOccCount(const unsigned int* dna, const unsigned int index, unsigned int* __restrict occCount, const unsigned int* dnaDecodeTable);
72 void BackwardDNA_NAllOccCount(const unsigned int* dna, const unsigned int index, unsigned int* __restrict occCount, const unsigned int* dnaDecodeTable);
74 // The following functions have no limit on the number of characters
75 unsigned int ForwardDNAnOccCountNoLimit(const unsigned int* dna, const unsigned int index, const unsigned int character, const unsigned int* dnaDecodeTable);
76 unsigned int BackwardDNA_NOccCountNoLimit(const unsigned int* dna, const unsigned int index, const unsigned int character, const unsigned int* dnaDecodeTable);
77 void ForwardDNA_NAllOccCountNoLimit(const unsigned int* dna, const unsigned int index, unsigned int* __restrict occCount, const unsigned int* dnaDecodeTable);
78 void BackwardDNA_NAllOccCountNoLimit(const unsigned int* dna, const unsigned int index, unsigned int* __restrict occCount, const unsigned int* 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 int ForwardOccCount(const unsigned int* packed, const unsigned int index, const unsigned int character, const unsigned int alphabetSize);
85 unsigned int BackwardOccCount(const unsigned int* packed, const unsigned int index, const unsigned int character, const unsigned int alphabetSize);
86 void ForwardAllOccCount(const unsigned int* packed, const unsigned int index, const unsigned int alphabetSize, unsigned int* occCount);
87 void BackwardAllOccCount(const unsigned int* packed, const unsigned int index, const unsigned int alphabetSize, unsigned int* occCount);
90 #endif