Skip to content

Commit c1e00a3

Browse files
author
Your Name
committed
commit mig her
1 parent 288c16a commit c1e00a3

2 files changed

Lines changed: 7 additions & 56 deletions

File tree

shared.cpp

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,6 @@
1414
#include <map> // for operator!=, __map_iterator, operator==
1515
#include <vector> // for vector
1616

17-
static int decode_nt16_acgt(uint8_t nt16) {
18-
if (nt16 == 1) return 0; // A
19-
if (nt16 == 2) return 1; // C
20-
if (nt16 == 4) return 2; // G
21-
if (nt16 == 8) return 3; // T
22-
return -1;
23-
}
24-
25-
double dust_score_nt16(const uint8_t *seq, int32_t l, int32_t window) {
26-
const int32_t WLEN = 3;
27-
const int32_t WTOT = 64;
28-
const int32_t WMASK = WTOT - 1;
29-
if (window < WLEN || window > 64)
30-
return -1.0;
31-
32-
int32_t wCount[WTOT];
33-
int32_t wSeq[64];
34-
memset(wCount, 0, sizeof(wCount));
35-
memset(wSeq, 0, sizeof(wSeq));
36-
37-
int64_t score = 0;
38-
int64_t maxScore = 0;
39-
int32_t t = 0;
40-
int32_t n = -WLEN;
41-
42-
for (int32_t i = 0; i < l; ++i) {
43-
const int b = decode_nt16_acgt(bam_seqi(seq, i));
44-
if (b < 0)
45-
continue; // ignore N/ambiguous
46-
47-
t = ((t << 2) | b) & WMASK;
48-
if (++n >= 0) {
49-
const int32_t k = n % window;
50-
if (n >= window) {
51-
const int32_t x = wSeq[k];
52-
if (wCount[x] > 0)
53-
score -= --wCount[x];
54-
score += wCount[t]++;
55-
if (score > maxScore)
56-
maxScore = score;
57-
} else {
58-
score += wCount[t]++;
59-
}
60-
wSeq[k] = t;
61-
}
62-
}
63-
64-
if (n <= 0)
65-
return 0.0;
66-
if (n >= window)
67-
return (200.0 * (double)maxScore) / (window * (window - 1));
68-
return (200.0 * (double)score) / (n * (n + 1));
69-
}
70-
7117

7218
int file_is_older(const char *file1, const char *file2) {
7319
struct stat st1, st2;

test/testAll2.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,14 @@ test_dust_unit() {
116116
local unit_src="test_dust_score.cpp"
117117
local unit_bin="output/test_dust_score_unit"
118118

119+
# Build the shared dust-score object via top-level make rules so include/link
120+
# settings match the main build (works with both bundled and system htslib).
121+
run_logged "Building dust score object" \
122+
make -C .. dust_score.o
123+
119124
run_logged "Compiling dust unit test" \
120-
c++ -O2 -Wall -Wextra -I.. "${unit_src}" ../shared.o \
121-
-o "${unit_bin}" -lz -lm -lpthread -lhts
125+
c++ -O2 -Wall -Wextra -I.. "${unit_src}" ../dust_score.o \
126+
-o "${unit_bin}"
122127

123128
if [[ -x "${unit_bin}" ]]; then
124129
run_logged "Running dust unit test" "${unit_bin}"

0 commit comments

Comments
 (0)