-
Notifications
You must be signed in to change notification settings - Fork 9
/
Util.h
105 lines (85 loc) · 2.89 KB
/
Util.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
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
#ifndef UTIL_H
#define UTIL_H
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
#include <iterator>
#include <ctime>
#include <vector>
#include <omp.h>
struct PhasingElement{
// i.e. 0|1 or 1|0
std::string RAstatus;
int block;
};
typedef std::map<std::string,PhasingElement> PhasingResult;
typedef std::map<std::string,PhasingResult> ChrPhasingResult;
/**
* Merges phasing results from all chromosomes into one result.
*
* @param allChrPhasingResults Contains phasing results for each chromosome.
* @param mergedPhasingResult A map to store the combined phasing results.
*
* The function combines the phasing elements from each chromosome into mergedPhasingResult.
*/
void mergeAllChrPhasingResult(const ChrPhasingResult& allChrPhasingResults, PhasingResult& mergedPhasingResult);
/**
* Configures thread counts for chromosome processing and BAM parsing.
*
* @param defaultThreads Initial thread count for chromosome processing.
* @param availableThreads Total threads available for processing
* @param chrnumThreads Set to the number of threads for chromosome processing.
* @param bamParsernumThreads Set to the number of threads for BAM parsing.
*/
void setPhasingNumThreads(const int& defaultChrThreads,const int& availableThreads, int& chrnumThreads, int& bamParsernumThreads);
/**
* Configures thread counts for chromosome processing and BAM parsing.
*
* @param availableThreads Total threads available for processing
* @param chrnumThreads Set to the number of threads for chromosome processing.
* @param bamParsernumThreads Set to the number of threads for BAM parsing.
*/
void setModcallNumThreads(const int& availableThreads, int& chrNumThreads, int& bamParserNumThreads);
// use for parsing
struct Variant{
Variant(int position, int allele, int quality):
position(position),
allele(allele),
quality(quality){};
int position;
int allele;
int quality;
bool underHomopolymer;
};
struct ReadVariant{
// init function
ReadVariant(): read_name(""),
mapping_quality(0),
source_id(""),
sample_id(""),
reference_start(0),
BX_tag(""){}
std::string read_name;
int mapping_quality;
std::string source_id;
std::string sample_id;
int reference_start;
std::string BX_tag;
bool is_reverse;
std::vector<Variant> variantVec;
void sort();
};
struct less_than_key
{
inline bool operator() (const Variant& v1, const Variant& v2)
{
return (v1.position < v2.position);
}
};
std::string getTargetString(std::string line, std::string start_sign, std::string end_sign);
int homopolymerLength(int snp_pos, const std::string &ref_string);
#endif