-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathPhasingGraph.h
128 lines (91 loc) · 3.57 KB
/
PhasingGraph.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef PHASINGGRAPH_H
#define PHASINGGRAPH_H
#include "Util.h"
#include "ParsingBam.h"
#include "PhasingProcess.h"
typedef std::pair<int, int> PosAllele;
typedef std::map<std::string, int> ReadBaseMap;
class SubEdge{
private:
int readCount;
// Edge information. The vector store next pos
// < next position, read name >
std::map<int, std::vector<std::string> > *refRead;
std::map<int, std::vector<std::string> > *altRead;
// sum of edge pair quality, pos1 quality + pos2 quality
// < next position, quality sum >
std::map<int, int> *refQuality;
std::map<int, int> *altQuality;
// < next position, read count >
std::map<int, float> *refReadCount;
std::map<int, float> *altReadCount;
public:
SubEdge();
~SubEdge();
void destroy();
void addSubEdge(int currentQuality, Variant connectNode, std::string readName, int baseQuality, double edgeWeight);
std::pair<float,float> BestPair(int targetPos);
float getRefReadCount(int targetPos);
float getAltReadCount(int targetPos);
std::vector<std::string> showEdge(std::string message);
std::vector<std::pair<int,int>> getConnectPos();
int getQuality(PosAllele targetPos);
int getAvgQuality(PosAllele targetPos);
};
struct VariantEdge{
int currPos;
SubEdge* alt;
SubEdge* ref;
VariantEdge(int currPos);
// node pair
std::pair<PosAllele,PosAllele> findBestEdgePair(int targetPos, bool isONT, double diffRatioThreshold, bool debug);
// number of read of two node. AA and AB combination
std::pair<int,int> findNumberOfRead(int targetPos);
};
struct BlockRead{
std::map<std::string,int> readVec;
void recordRead(std::string readName);
};
struct EdgeResult{
int rr;
int ra;
int ar;
int aa;
};
class VairiantGraph{
private:
PhasingParameters *params;
std::string *ref;
std::vector<std::string> dotResult;
std::vector<ReadVariant> *readVariant;
// By default, a Map in C++ is sorted in increasing order based on its key.
// position, edge
std::map<int,VariantEdge*> *edgeList;
// Each position will record the included reads and their corresponding base qualities.
// position, < read name, quality>
std::map<int,ReadBaseMap*> *totalVariantInfo;
// position, type < 0=SNP 1=SV 2=MOD 3=INDEL >
std::map<int,int> *variantType;
// phasing result
// PosAllele , block_start
std::map<PosAllele,int> *bkResult;
// record each position haplotype
std::map<PosAllele,int> *subNodeHP;
// store phased read and read's haplotype
std::map<std::string,int> *readHpMap;
// produce PS tag and determine phased GT tag
void storeResultPath();
void readCorrection();
void edgeConnectResult();
public:
VairiantGraph(std::string &ref, PhasingParameters ¶ms);
~VairiantGraph();
void addEdge(std::vector<ReadVariant> &in_readVariant);
void phasingProcess();
void writingDotFile(std::string dotPrefix);
std::map<std::string,int>* getReadHP();
void exportResult(std::string chrName, PhasingResult &result);
int totalNode();
void destroy();
};
#endif