annotate pyPRADA_1.2/tools/bwa-0.5.7-mh/bwt_gen/bwt_gen.h @ 3:f17965495ec9 draft default tip

Uploaded
author siyuan
date Tue, 11 Mar 2014 12:14:01 -0400
parents acc2ca1a3ba4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
1 /*
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
2
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
3 BWTConstruct.h BWT-Index Construction
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
4
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
5 This module constructs BWT and auxiliary data structures.
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
6
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
7 Copyright (C) 2004, Wong Chi Kwong.
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
8
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
9 This program is free software; you can redistribute it and/or
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
10 modify it under the terms of the GNU General Public License
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
11 as published by the Free Software Foundation; either version 2
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
12 of the License, or (at your option) any later version.
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
13
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
17 GNU General Public License for more details.
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
18
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
20 along with this program; if not, write to the Free Software
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
22
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
23 */
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
24
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
25 #ifndef BWT_GEN_H
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
26 #define BWT_GEN_H
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
27
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
28 #define ALPHABET_SIZE 4
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
29 #define BIT_PER_CHAR 2
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
30 #define CHAR_PER_WORD 16
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
31 #define CHAR_PER_BYTE 4
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
32
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
33 #define BITS_IN_WORD 32
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
34 #define BITS_IN_BYTE 8
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
35 #define BYTES_IN_WORD 4
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
36
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
37 #define ALL_ONE_MASK 0xFFFFFFFF
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
38 #define DNA_OCC_CNT_TABLE_SIZE_IN_WORD 65536
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
39
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
40 #define BITS_PER_OCC_VALUE 16
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
41 #define OCC_VALUE_PER_WORD 2
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
42 #define OCC_INTERVAL 256
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
43 #define OCC_INTERVAL_MAJOR 65536
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
44
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
45 #define TRUE 1
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
46 #define FALSE 0
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
47
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
48 #define BWTINC_INSERT_SORT_NUM_ITEM 7
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
49
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
50 #define average(value1, value2) ( ((value1) & (value2)) + ((value1) ^ (value2)) / 2 )
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
51 #define min(value1, value2) ( ((value1) < (value2)) ? (value1) : (value2) )
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
52 #define max(value1, value2) ( ((value1) > (value2)) ? (value1) : (value2) )
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
53 #define med3(a, b, c) ( a<b ? (b<c ? b : a<c ? c : a) : (b>c ? b : a>c ? c : a))
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
54 #define swap(a, b, t); t = a; a = b; b = t;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
55 #define truncateLeft(value, offset) ( (value) << (offset) >> (offset) )
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
56 #define truncateRight(value, offset) ( (value) >> (offset) << (offset) )
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
57 #define DNA_OCC_SUM_EXCEPTION(sum) ((sum & 0xfefefeff) == 0)
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
58
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
59 typedef struct SaIndexRange {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
60 unsigned int startSaIndex;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
61 unsigned int endSaIndex;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
62 } SaIndexRange;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
63
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
64 typedef struct BWT {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
65 unsigned int textLength; // length of the text
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
66 unsigned int saInterval; // interval between two SA values stored explicitly
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
67 unsigned int inverseSaInterval; // interval between two inverse SA stored explicitly
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
68 unsigned int inverseSa0; // SA-1[0]
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
69 unsigned int *cumulativeFreq; // cumulative frequency
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
70 unsigned int *bwtCode; // BWT code
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
71 unsigned int *occValue; // Occurrence values stored explicitly
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
72 unsigned int *occValueMajor; // Occurrence values stored explicitly
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
73 unsigned int *saValue; // SA values stored explicitly
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
74 unsigned int *inverseSa; // Inverse SA stored explicitly
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
75 SaIndexRange *saIndexRange; // SA index range
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
76 int saIndexRangeNumOfChar; // Number of characters indexed in SA index range
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
77 unsigned int *saValueOnBoundary; // Pre-calculated frequently referred data
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
78 unsigned int *decodeTable; // For decoding BWT by table lookup
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
79 unsigned int decodeTableGenerated; // == TRUE if decode table is generated on load and will be freed
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
80 unsigned int bwtSizeInWord; // Temporary variable to hold the memory allocated
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
81 unsigned int occSizeInWord; // Temporary variable to hold the memory allocated
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
82 unsigned int occMajorSizeInWord; // Temporary variable to hold the memory allocated
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
83 unsigned int saValueSize; // Temporary variable to hold the memory allocated
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
84 unsigned int inverseSaSize; // Temporary variable to hold the memory allocated
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
85 unsigned int saIndexRangeSize; // Temporary variable to hold the memory allocated
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
86 } BWT;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
87
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
88 typedef struct BWTInc {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
89 BWT *bwt;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
90 unsigned int numberOfIterationDone;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
91 unsigned int *cumulativeCountInCurrentBuild;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
92 unsigned int availableWord;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
93 unsigned int targetTextLength;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
94 float targetNBit;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
95 unsigned int buildSize;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
96 unsigned int initialMaxBuildSize;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
97 unsigned int incMaxBuildSize;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
98 unsigned int firstCharInLastIteration;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
99 unsigned int *workingMemory;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
100 unsigned int *packedText;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
101 unsigned char *textBuffer;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
102 unsigned int *packedShift;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
103 } BWTInc;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
104
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
105 #endif