Skip to content

Commit 757c1a1

Browse files
committed
Modernize code
* All APIs should be callable with size parameters.
1 parent 404bf6b commit 757c1a1

File tree

3 files changed

+421
-437
lines changed

3 files changed

+421
-437
lines changed

src/example.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
// Last revision by Mengyao Zhao on 2023-Apr-21
99
// ==========================
1010

11+
#include <algorithm>
1112
#include <iostream>
12-
#include <string.h>
13+
#include <string>
1314

1415
#include "ssw_cpp.h"
1516

16-
using std::string;
1717
using std::cout;
1818
using std::endl;
1919

2020
static void PrintAlignment(const StripedSmithWaterman::Alignment& alignment);
2121

2222
int main() {
23-
const string ref = "CAGCCTTTCTGACCCGGAAATCAAAATAGGCACAACAAA";
24-
const string query = "CTGAGCCGGTAAATC";
25-
int32_t maskLen = strlen(query.c_str())/2;
26-
maskLen = maskLen < 15 ? 15 : maskLen;
23+
const std::string ref("CAGCCTTTCTGACCCGGAAATCAAAATAGGCACAACAAA");
24+
const std::string query("CTGAGCCGGTAAATC");
25+
const int32_t maskLen = std::max(query.size() / 2, size_t(15));
2726

2827
// Declares a default Aligner
2928
StripedSmithWaterman::Aligner aligner;
@@ -32,14 +31,14 @@ int main() {
3231
// Declares an alignment that stores the result
3332
StripedSmithWaterman::Alignment alignment;
3433
// Aligns the query to the ref
35-
aligner.Align(query.c_str(), ref.c_str(), ref.size(), filter, &alignment, maskLen);
34+
aligner.Align(query.c_str(), query.size(), ref.c_str(), ref.size(), filter, alignment, maskLen);
3635

3736
PrintAlignment(alignment);
3837

3938
return 0;
4039
}
4140

42-
static void PrintAlignment(const StripedSmithWaterman::Alignment& alignment){
41+
static void PrintAlignment(const StripedSmithWaterman::Alignment& alignment) {
4342
cout << "===== SSW result =====" << endl;
4443
cout << "Best Smith-Waterman score:\t" << alignment.sw_score << endl
4544
<< "Next-best Smith-Waterman score:\t" << alignment.sw_score_next_best << endl

0 commit comments

Comments
 (0)