-
Notifications
You must be signed in to change notification settings - Fork 0
/
PairHMMTest.java
194 lines (166 loc) · 7.14 KB
/
PairHMMTest.java
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import java.io.*;
import com.intel.gkl.pairhmm.IntelPairHmm;
import com.intel.gkl.pairhmm.IntelPairHmmOMP;
import org.broadinstitute.gatk.nativebindings.pairhmm.PairHMMNativeArguments;
import org.broadinstitute.gatk.nativebindings.pairhmm.PairHMMNativeBinding;
import org.broadinstitute.gatk.nativebindings.pairhmm.ReadDataHolder;
import org.broadinstitute.gatk.nativebindings.pairhmm.HaplotypeDataHolder;
public class PairHMMTest {
public static void main (String[] args) {
PairHMMRun pairHMMRun = new PairHMMRun();
pairHMMRun.run_pairHMM();
NewThread thread1 = new NewThread();
NewThread thread2 = new NewThread();
NewThread thread3 = new NewThread();
NewThread thread4 = new NewThread();
thread1.start();
thread2.start();
thread3.start();
thread4.start();
try {
thread1.join();
} catch (Exception e) {
}
try {
thread2.join();
} catch (Exception e) {
}
try {
thread3.join();
} catch (Exception e) {
}
try {
thread4.join();
} catch (Exception e) {
}
}
}
class NewThread extends Thread {
public void run() {
PairHMMRun pairHMMRun = new PairHMMRun();
pairHMMRun.run_pairHMM();
}
}
class PairHMMRun {
private final int numReadRepeat = 1000;
private final int numHapRepeat = 100;
private ReadDataHolder[] readDataArray;
private HaplotypeDataHolder[] mHaplotypeDataArray;
private double[] mLogLikelihoodArray;
private PairHMMNativeBinding piarhmm;
private int FAIL_TO_START_PAIRHMM_ENGINE = 1;
private int NUM_THRED_FOR_PAIRHMM = 2;
private byte[] read = {
'A', 'G', 'C', 'T', 'C', 'G', 'A', 'G', 'G', 'G',
'A', 'G', 'A', 'G', 'A', 'G', 'T', 'T', 'T', 'T',
'A', 'T', 'T', 'C', 'A', 'G', 'A', 'A', 'T', 'G',
'G', 'G', 'A', 'A', 'A', 'C', 'T', 'T', 'A', 'C',
'C', 'A', 'A', 'G', 'G', 'A', 'G', 'A', 'C', 'T',
'A', 'C', 'T', 'A', 'T', 'G', 'A', 'A', 'T', 'C',
'A', 'C', 'G', 'A', 'T', 'A', 'C', 'T', 'A', 'C',
'G', 'A', 'T', 'G', 'A', 'T', 'C', 'C', 'T', 'C',
'G', 'G', 'G', 'A', 'A', 'T', 'A', 'C', 'A', 'G',
'G', 'G', 'A', 'T', 'T', 'A', 'C'
};
private byte[] q = {
28, 30, 31, 31, 30, 23, 30, 32, 31, 31,
30, 32, 29, 32, 30, 32, 28, 30, 30, 30,
29, 29, 30, 30, 30, 32, 30, 30, 29, 31,
30, 30, 30, 31, 31, 30, 31, 30, 29, 31,
29, 30, 31, 32, 31, 30, 33, 30, 31, 31,
29, 31, 31, 29, 30, 32, 30, 31, 30, 31,
31, 31, 24, 31, 30, 30, 32, 32, 29, 33,
25, 29, 29, 33, 29, 31, 31, 31, 32, 31,
26, 32, 32, 30, 31, 29, 28, 33, 30, 31,
30, 29, 25, 24, 25, 24, 29
};
private byte[] i = {
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 39, 39, 39, 37, 37,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 38, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 39, 39,
38, 39, 40, 40, 40, 40, 42
};
private byte[] d = {
40, 40, 40, 40, 40, 40, 40, 40, 40, 39,
40, 40, 40, 40, 40, 39, 39, 39, 33, 33,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 34, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 41
};
private byte[] c = {
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10
};
private byte[] hap = {
'A', 'G', 'C', 'T', 'C', 'G', 'A', 'G', 'G', 'G',
'A', 'G', 'A', 'G', 'A', 'G', 'T', 'T', 'T', 'T',
'A', 'T', 'T', 'C', 'A', 'G', 'A', 'A', 'T', 'G',
'G', 'G', 'A', 'A', 'A', 'C', 'T', 'T', 'A', 'C',
'C', 'A', 'A', 'G', 'G', 'A', 'G', 'A', 'C', 'T',
'A', 'C', 'T', 'A', 'T', 'G', 'A', 'A', 'T', 'C',
'A', 'C', 'G', 'A', 'T', 'A', 'C', 'T', 'A', 'C',
'G', 'A', 'T', 'G', 'A', 'T', 'C', 'C', 'T', 'C',
'G', 'G', 'G', 'A', 'A', 'T', 'A', 'C', 'A', 'G',
'G', 'G', 'A', 'T', 'T', 'A', 'C', 'A', 'G', 'G',
'A', 'A', 'T', 'G', 'A', 'T', 'C', 'C', 'T', 'T',
'A', 'T', 'G', 'A', 'A', 'C', 'A', 'A', 'G', 'A',
'T', 'A', 'T', 'T', 'A', 'G', 'G', 'G', 'A', 'A',
'T', 'A', 'T', 'A', 'G', 'T', 'T', 'A', 'C', 'A',
'G', 'G', 'C', 'A', 'A', 'A', 'A', 'A', 'A', 'T',
'A', 'A', 'C', 'A', 'A', 'A', 'G', 'A', 'G', 'A',
'A', 'C', 'G', 'T', 'G', 'A', 'A', 'A', 'G', 'A',
'T', 'T', 'T', 'G', 'A', 'G', 'T', 'C', 'T', 'G',
'A', 'C', 'C', 'G', 'G', 'G', 'A', 'C', 'A', 'G',
'A', 'G', 'A', 'C', 'C', 'A', 'T', 'G', 'A', 'G',
'A', 'G', 'G', 'A', 'G', 'G', 'C', 'C', 'G', 'A',
'T', 'T', 'G', 'A', 'A', 'C', 'G', 'A', 'A', 'G',
'T', 'C', 'A', 'A', 'A', 'G', 'T'
};
public void run_pairHMM() {
readDataArray = new ReadDataHolder[numReadRepeat];
mHaplotypeDataArray = new HaplotypeDataHolder[numHapRepeat];
mLogLikelihoodArray = new double[numReadRepeat * numHapRepeat];
piarhmm = new IntelPairHmmOMP();
if (!piarhmm.load(null)) {
System.exit(FAIL_TO_START_PAIRHMM_ENGINE);
}
PairHMMNativeArguments args = new PairHMMNativeArguments();
args.maxNumberOfThreads = NUM_THRED_FOR_PAIRHMM;
args.useDoublePrecision = false;
piarhmm.initialize(args);
for (int j = 0; j < numReadRepeat; ++j) {
readDataArray[j] = new ReadDataHolder();
readDataArray[j].readBases = read;
readDataArray[j].readQuals = q;
readDataArray[j].insertionGOP = i;
readDataArray[j].deletionGOP = d;
readDataArray[j].overallGCP = c;
}
for (int j = 0; j < numHapRepeat; ++j) {
mHaplotypeDataArray[j] = new HaplotypeDataHolder();
mHaplotypeDataArray[j].haplotypeBases = hap;
}
long beg = System.nanoTime();
piarhmm.computeLikelihoods(readDataArray, mHaplotypeDataArray, mLogLikelihoodArray);
System.out.printf("Cost %fs\n", (double) (System.nanoTime() - beg) / 1000000000.0);
}
}