-
Notifications
You must be signed in to change notification settings - Fork 8
/
coreStruct.h
164 lines (141 loc) · 3.65 KB
/
coreStruct.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef _ASC_CORESTRUCT_H_
#define _ASC_CORESTRUCT_H_
#include "definitions.h"
#include "SimpleMemoryPool.h"
#pragma pack(1)
typedef struct SnpCounter
{
unsigned short weightedCount1;
unsigned short weightedCount2;
union
{
struct
{
unsigned char posStrandCount1;
unsigned char negStrandCount1;
unsigned char posStrandCount2;
unsigned char negStrandCount2;
} strandCounts;
unsigned int arrayIndex;
} data;
#ifdef ENABLE_SOFTCLIP_COUNTER
unsigned char softClipCount;
#endif
} SnpCounter;
#pragma pack()
#pragma pack(4)
typedef struct SnpOverflowCounter
{
#ifndef AMPLICON
unsigned short weightedCount[ALPHABET_SIZE];
unsigned short posStrandCount[ALPHABET_SIZE];
unsigned short negStrandCount[ALPHABET_SIZE];
#else
unsigned int weightedCount[ALPHABET_SIZE];
unsigned int posStrandCount[ALPHABET_SIZE];
unsigned int negStrandCount[ALPHABET_SIZE];
#endif
union
{
struct
{
unsigned char insertSeq[3];
unsigned char lqCount;
} counters;
unsigned int ptr;
} insertion;
union
{
struct
{
unsigned char deletionLength;
unsigned char hqCount;
unsigned char lqCount;
} counters;
unsigned int ptr;
} deletion;
} SnpOverflowCounter;
#pragma pack()
#pragma pack(4)
typedef struct SnpOverflowCounterArray
{
SnpOverflowCounter *counters;
unsigned int size;
unsigned int limit;
} SnpOverflowCounterArray;
#pragma pack()
#pragma pack(1)
typedef struct SnpDirectionalSoftclip
{
unsigned int ambPosition;
char leftOrRight;
} SnpDirectionalSoftClip;
#pragma pack()
#pragma pack(2)
typedef struct SnpDirectionalSoftclipCounter
{
unsigned int ambPosition;
unsigned int leftSoftclipCount;
unsigned int rightSoftclipCount;
} SnpDirectionalSoftclipCounter;
#pragma pack()
#pragma pack(4)
typedef struct LongSoftClipPositionArray
{
unsigned int *positions;
unsigned int size;
unsigned int limit;
} LongSoftClipPositionArray;
#pragma pack()
#pragma pack(1)
typedef struct LongSoftClipCounter
{
unsigned int position;
unsigned char count;
} LongSoftClipCounter;
#pragma pack()
#pragma pack(4)
typedef struct SnpBundle
{
SnpCounter *snpCounter;
SnpOverflowCounterArray *snpOverflowCounterArray;
int numOfCPUThreads;
unsigned int *invalidSnpCounterPos;
MemoryPool *snpMemoryPool;
SnpDirectionalSoftclipCounter *snpDirectionalSoftclipCounter;
unsigned int textLength;
unsigned int snpDirectionalSoftclipCounterSize;
unsigned int snpDirectionalSoftclipCounterCapacity;
} SnpBundle;
#pragma pack()
#pragma pack(1)
typedef struct SnpSetting
{
unsigned int dnaLength;
unsigned int mapqThreshold;
unsigned int trimSize;
unsigned int softClipThreshold;
unsigned char *weightMap;
unsigned char indelWeightThreshold;
char enableQualityCorrection;
} VcSetting;
#pragma pack()
__inline__ unsigned int findRegionByPosition(unsigned int position, unsigned int textLength, int numOfCPUThreads)
{
int i = 0;
for (i = 0; i < numOfCPUThreads - 1; ++i)
{
if (position < (textLength / numOfCPUThreads) * (i + 1))
{
return i;
}
}
return i;
}
#define SORT_DIGIT_BY_VAR(array, var, shift_bits, num_elements, buckets, buffer, record_type) \
do { memset(buckets, 0, NUM_BUCKETS * sizeof(unsigned int)); \
for (unsigned int i=0; i<num_elements; ++i) buckets[((array)[i].var>>shift_bits)&0xFFFF]++; \
for (unsigned int b=0, acc=0; b<NUM_BUCKETS; ++b) {unsigned int t=acc; acc+=buckets[b]; buckets[b]=t;} \
for (unsigned int i=0; i<num_elements; ++i) buffer[buckets[((array)[i].var>>shift_bits)&0xFFFF]++] = array[i]; \
{ record_type *t = buffer; buffer = array; array = t; } } while (0)
#endif