-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helper.h
65 lines (53 loc) · 1.77 KB
/
Helper.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
#ifndef HELPER_H
#define HELPER_H
#include "api/BamReader.h"
#include <string>
#include <set>
//
// Functions
//
std::string stripFilename(const std::string& filename);
std::string stripExtension(const std::string& filename);
std::string stripDirectories(const std::string& filename);
int numOfTheLongestPrefix(const std::string& s1, const std::string& s2);
int numOfThelongestSuffix(const std::string& s1, const std::string& s2);
int extend(const std::string& read, int offset, int leftOrigin, int rightOrigin);
template<class T, class Compare>
void cluster(const std::vector<T>& orig, std::vector<std::vector<T> >& clusters, Compare comp) {
std::vector<T> buffer;
auto first = orig.begin();
auto last = orig.end();
buffer.push_back(*first);
while (++first != last) {
if (!comp(*first, buffer[0])) {
clusters.push_back(buffer);
buffer.clear();
}
buffer.push_back(*first);
}
if (!buffer.empty()) clusters.push_back(buffer);
}
template<class T, class Compare>
void merge(const std::vector<T>& orig, std::vector<T>& results, Compare comp) {
std::vector<bool> removed(orig.size(), false);
for (size_t i = 0; i < orig.size() - 1; ++i) {
for (size_t j = i + 1; j < orig.size(); ++j) {
if (!removed[j] && comp(orig[i], orig[j])) {
removed[j] = true;
}
}
}
for (size_t i = 0; i < removed.size(); ++i) {
if (!removed[i]) {
results.push_back(orig[i]);
}
}
}
namespace Helper {
std::string getReferenceName(BamTools::BamReader& reader, int referenceId);
const int SVLEN_THRESHOLD = -50;
const int CONFLICT_THRESHOLD = 13;
//std::set<std::string> forwardEClipNames;
//std::set<std::string> reverseBClipNames;
}
#endif // HELPER_H