Skip to content

Commit bcde36d

Browse files
clang changes
Signed-off-by: AdityaPandeyCN <[email protected]>
1 parent 4c9ed4a commit bcde36d

File tree

10 files changed

+340
-313
lines changed

10 files changed

+340
-313
lines changed

benchmark/generate_sam_benchmark.cxx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
#include "generate_sam_benchmark.h"
33
#include <cstdio>
44

5-
static void BM_GenerateSAM(benchmark::State& state) {
6-
int num_reads = state.range(0);
7-
for (auto _ : state) {
8-
GenerateSAMFile("benchmark_temp.sam", num_reads);
9-
std::remove("benchmark_temp.sam");
10-
}
5+
static void BM_GenerateSAM(benchmark::State &state)
6+
{
7+
int num_reads = state.range(0);
8+
for (auto _ : state) {
9+
GenerateSAMFile("benchmark_temp.sam", num_reads);
10+
std::remove("benchmark_temp.sam");
11+
}
1112

12-
state.counters["reads_per_second"] = benchmark::Counter(
13-
num_reads, benchmark::Counter::kIsRate);
14-
state.counters["bytes_per_second"] = benchmark::Counter(
15-
num_reads * 200, benchmark::Counter::kIsRate);
13+
state.counters["reads_per_second"] = benchmark::Counter(num_reads, benchmark::Counter::kIsRate);
14+
state.counters["bytes_per_second"] = benchmark::Counter(num_reads * 200, benchmark::Counter::kIsRate);
1615
}
1716

1817
BENCHMARK(BM_GenerateSAM)->Range(100, 10000);
1918
BENCHMARK_MAIN();
20-

benchmark/region_query_benchmark.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,3 @@ BENCHMARK_REGISTER_F(RegionQueryFixture, TTree)->DenseRange(0, 17, 1)->Unit(benc
100100
BENCHMARK_REGISTER_F(RegionQueryFixture, RNTuple)->DenseRange(0, 17, 1)->Unit(benchmark::kSecond);
101101

102102
BENCHMARK_MAIN();
103-

inc/ramcore/SamToNTuple.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ void samtoramntuple_split_by_chromosome(const char *datafile, const char *output
1616
const std::vector<std::string> &only_chromosomes = {});
1717

1818
#endif
19-

src/ramcore/RAMNTupleView.cxx

Lines changed: 54 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#include "ramcore/RAMNTupleView.h"
2-
#include <iostream>
2+
3+
#include <cstdint>
34
#include <cstring>
5+
#include <iostream>
46
#include <limits>
7+
#include <string>
8+
59
#include <ROOT/RNTuple.hxx>
610
#include <ROOT/RNTupleReader.hxx>
711
#include <ROOT/RNTupleView.hxx>
@@ -20,16 +24,16 @@ Long64_t ramntupleview(const char *file, const char *query, bool cache, bool per
2024
printf("ramntupleview: failed to open file %s\n", file);
2125
return 0;
2226
}
23-
27+
2428
std::string region = query;
2529
if (region.empty() || region == "*") {
26-
stopwatch.Print();
27-
return reader->GetNEntries();
30+
stopwatch.Print();
31+
return reader->GetNEntries();
2832
}
2933

3034
TString rname;
3135
Int_t range_start = 1;
32-
Int_t range_end = std::numeric_limits<Int_t>::max();
36+
Int_t range_end = std::numeric_limits<Int_t>::max();
3337

3438
int chrDelimiterPos = region.find(":");
3539
if (chrDelimiterPos == std::string::npos) {
@@ -53,22 +57,22 @@ Long64_t ramntupleview(const char *file, const char *query, bool cache, bool per
5357

5458
auto refs = RAMNTupleRecord::GetRnameRefs();
5559
auto refid = refs->GetRefId(rname.Data());
56-
60+
5761
if (refid < 0) {
58-
if (rname.BeginsWith("chr")) {
59-
TString stripped_rname = rname(3, rname.Length() - 3);
60-
refid = refs->GetRefId(stripped_rname.Data());
61-
}
62-
if (refid < 0 && (rname == "chrM" || rname == "M")) {
63-
refid = refs->GetRefId("MT");
64-
}
62+
if (rname.BeginsWith("chr")) {
63+
TString stripped_rname = rname(3, rname.Length() - 3);
64+
refid = refs->GetRefId(stripped_rname.Data());
65+
}
66+
if (refid < 0 && (rname == "chrM" || rname == "M")) {
67+
refid = refs->GetRefId("MT");
68+
}
6569
}
66-
70+
6771
if (refid < 0) {
68-
std::cerr << "Error: Reference name '" << rname.Data() << "' not found in file.\n";
69-
return 0;
72+
std::cerr << "Error: Reference name '" << rname.Data() << "' not found in file.\n";
73+
return 0;
7074
}
71-
75+
7276
auto index = RAMNTupleRecord::GetIndex();
7377
auto flagView = reader->GetView<uint16_t>("record.flag");
7478
auto refidView = reader->GetView<int32_t>("record.refid");
@@ -77,18 +81,18 @@ Long64_t ramntupleview(const char *file, const char *query, bool cache, bool per
7781

7882
Long64_t count = 0;
7983
const Long64_t totalEntries = reader->GetNEntries();
80-
81-
const int FLAG_FILTER = 0x904;
84+
85+
const int FLAG_FILTER = 0x904;
8286
const Int_t rs0 = (range_start > 0) ? (range_start - 1) : 0;
8387
const Int_t re0 = (range_end > 0) ? (range_end - 1) : 0;
84-
constexpr int kMaxRefSpanHeuristic = 10000;
88+
constexpr int kMaxRefSpanHeuristic = 10000;
8589

8690
auto computeRefSpan = [](const std::vector<uint32_t> &cigarOps) -> int {
8791
int span = 0;
8892
for (uint32_t op : cigarOps) {
8993
int len = static_cast<int>(op >> 4);
9094
int code = static_cast<int>(op & 0xF);
91-
95+
9296
if (code == 0 || code == 2 || code == 3 || code == 7 || code == 8) {
9397
span += len;
9498
}
@@ -97,22 +101,25 @@ Long64_t ramntupleview(const char *file, const char *query, bool cache, bool per
97101
};
98102

99103
if (!index || index->Size() == 0) {
100-
104+
101105
bool seenRef = false;
102106
for (auto i : reader->GetEntryRange()) {
103107
const auto flag = flagView(i);
104-
if (flag & FLAG_FILTER) continue;
105-
108+
if (flag & FLAG_FILTER)
109+
continue;
110+
106111
const auto curRef = refidView(i);
107112
if (curRef == refid) {
108113
seenRef = true;
109114
} else {
110-
if (seenRef && curRef > refid) break;
115+
if (seenRef && curRef > refid)
116+
break;
111117
continue;
112118
}
113119
const auto curPos = posView(i);
114-
if (curPos > re0) break;
115-
120+
if (curPos > re0)
121+
break;
122+
116123
int read_start = curPos;
117124
if (read_start >= rs0) {
118125
count++;
@@ -124,29 +131,35 @@ Long64_t ramntupleview(const char *file, const char *query, bool cache, bool per
124131
const auto &cigarOps = cigarView(i);
125132
int refSpan = computeRefSpan(cigarOps);
126133
int read_end = (refSpan > 0) ? (read_start + refSpan - 1) : read_start;
127-
134+
128135
if (read_start <= re0 && read_end >= rs0) {
129136
count++;
130137
}
131138
}
132139
} else {
133-
140+
134141
auto start_entry = index->GetRow(refid, rs0);
135-
136-
if (start_entry < 0) start_entry = index->GetRow(refid, 0);
137-
if (start_entry < 0) start_entry = 0;
142+
143+
if (start_entry < 0)
144+
start_entry = index->GetRow(refid, 0);
145+
if (start_entry < 0)
146+
start_entry = 0;
138147

139148
for (Long64_t j = start_entry; j < totalEntries; j++) {
140149
const auto flag = flagView(j);
141-
if (flag & FLAG_FILTER) continue;
142-
150+
if (flag & FLAG_FILTER)
151+
continue;
152+
143153
const auto curRef = refidView(j);
144-
if (curRef < refid) continue;
145-
if (curRef > refid) break;
146-
154+
if (curRef < refid)
155+
continue;
156+
if (curRef > refid)
157+
break;
158+
147159
const auto curPos = posView(j);
148-
if (curPos > re0) break;
149-
160+
if (curPos > re0)
161+
break;
162+
150163
int read_start = curPos;
151164
if (read_start >= rs0) {
152165
count++;
@@ -158,14 +171,14 @@ Long64_t ramntupleview(const char *file, const char *query, bool cache, bool per
158171
const auto &cigarOps = cigarView(j);
159172
int refSpan = computeRefSpan(cigarOps);
160173
int read_end = (refSpan > 0) ? (read_start + refSpan - 1) : read_start;
161-
174+
162175
if (read_end >= rs0) {
163176
count++;
164177
}
165178
}
166179
}
167180

168181
stopwatch.Print();
182+
std::cout << "Found " << static_cast<long long>(count) << " records in region " << (query ? query : "") << std::endl;
169183
return count;
170184
}
171-

0 commit comments

Comments
 (0)