ContextSV v1.0.0
Loading...
Searching...
No Matches
sv_types.h
Go to the documentation of this file.
1#ifndef SV_TYPES_H
2#define SV_TYPES_H
3
5#include <string>
6#include <map>
7#include <set>
8#include <unordered_map>
9#include <tuple>
10#include <bitset>
12
13namespace sv_types {
14
15 // Define constants for SV types
16 enum class SVType {
17 UNKNOWN = -1,
18 DEL = 0,
19 DUP = 1,
20 INV = 2,
21 INS = 3,
22 BND = 4,
23 NEUTRAL = 5, // Neutral copy number with unknown type
24 LOH = 6 // Loss of heterozygosity
25 };
26
27 // Mapping of SV types to strings
28 const std::unordered_map<SVType, std::string> SVTypeString = {
29 {SVType::UNKNOWN, "UNKNOWN"},
30 {SVType::DEL, "DEL"},
31 {SVType::DUP, "DUP"},
32 {SVType::INV, "INV"},
33 {SVType::INS, "INS"},
34 {SVType::BND, "BND"},
35 {SVType::NEUTRAL, "NEUTRAL"},
36 {SVType::LOH, "LOH"}
37 };
38
39 // Mapping of SV types to symbols
40 const std::unordered_map<SVType, std::string> SVTypeSymbol = {
41 {SVType::UNKNOWN, "."},
42 {SVType::DEL, "<DEL>"},
43 {SVType::DUP, "<DUP>"},
44 {SVType::INV, "<INV>"},
45 {SVType::INS, "<INS>"},
46 {SVType::BND, "<BND>"},
47 };
48
49 // Define constants for genotypes
50 enum class Genotype {
52 HETEROZYGOUS = 1,
54 UNKNOWN = 3
55 };
56
57 // Mapping of genotypes to strings
58 const std::unordered_map<Genotype, std::string> GenotypeString = {
62 {Genotype::UNKNOWN, "./."}
63 };
64
65 // Define constants for SV data types (evidence types)
66 enum class SVDataType {
67 CIGARINS = 0,
68 CIGARDEL = 1,
69 CIGARCLIP = 2,
70 SPLIT = 3,
71 SPLITDIST1 = 4,
72 SPLITDIST2 = 5,
73 SPLITINV = 6,
74 SUPPINV = 7,
75 HMM = 8,
76 UNKNOWN = 9
77 };
78
79 using SVEvidenceFlags = std::bitset<10>; // Bitset for SV data types
80
81 // Mapping of SV data types to strings
82 const std::unordered_map<SVDataType, std::string> SVDataTypeString = {
83 {SVDataType::CIGARINS, "CIGARINS"},
84 {SVDataType::CIGARDEL, "CIGARDEL"},
85 {SVDataType::CIGARCLIP, "CIGARCLIP"},
86 {SVDataType::SPLIT, "SPLIT"},
87 {SVDataType::SPLITDIST1, "SPLITDIST1"},
88 {SVDataType::SPLITDIST2, "SPLITDIST2"},
89 {SVDataType::SPLITINV, "SPLITINV"},
90 {SVDataType::SUPPINV, "SUPPINV"},
91 {SVDataType::HMM, "HMM"},
92 {SVDataType::UNKNOWN, "UNKNOWN"}
93 };
94
95 // Mapping of 6 copy number states to SV types
96 const std::unordered_map<int, SVType> CNVTypeMap = {
97 {0, SVType::UNKNOWN},
98 {1, SVType::DEL},
99 {2, SVType::DEL},
100 {3, SVType::NEUTRAL},
101 {4, SVType::LOH},
102 {5, SVType::DUP},
103 {6, SVType::DUP}
104 };
105
106 // Function to get the SV type string
107 inline std::string getSVTypeString(SVType sv_type) {
108 return SVTypeString.at(sv_type);
109 }
110
111 // Function to get the SV alignment type string from the bitset
112 inline std::string getSVAlignmentTypeString(SVEvidenceFlags aln_type) {
113 std::string result;
114 for (size_t i = 0; i < SVDataTypeString.size(); ++i) {
115 if (aln_type.test(i)) {
116 result += SVDataTypeString.at(static_cast<SVDataType>(i)) + ",";
117 }
118 }
119 if (!result.empty()) {
120 result.pop_back(); // Remove the trailing comma
121 }
122 return result;
123 }
124
125 // Function to get the SV type from the CNV state
126 inline SVType getSVTypeFromCNState(int cn_state) {
127 return CNVTypeMap.at(cn_state);
128 }
129
130 // Function to get the genotype string
131 inline std::string getGenotypeString(Genotype genotype) {
132 return GenotypeString.at(genotype);
133 }
134
135 // Function to get the SV data type string
136 // inline std::string getSVDataTypeString(SVDataType data_type) {
137 // return SVDataTypeString.at(data_type);
138 // }
139
140 // Function to get the SV type symbol
141 inline std::string getSVTypeSymbol(SVType sv_type) {
142 return SVTypeSymbol.at(sv_type);
143 }
144
145 // Function to check if an SV type is a valid update from copy number predictions
146 inline bool isValidCopyNumberUpdate(SVType sv_type, SVType updated_sv_type) {
147 if (updated_sv_type == SVType::UNKNOWN) {
148 return false;
149 } else if (sv_type == SVType::DEL && updated_sv_type != SVType::DEL) {
150 return false;
151 } else if (sv_type == SVType::INS && updated_sv_type != SVType::DUP) {
152 return false;
153 }
154 return true;
155 }
156}
157
158#endif // SV_TYPES_H
Definition sv_types.h:13
const std::unordered_map< int, SVType > CNVTypeMap
Definition sv_types.h:96
const std::unordered_map< SVType, std::string > SVTypeString
Definition sv_types.h:28
std::string getSVAlignmentTypeString(SVEvidenceFlags aln_type)
Definition sv_types.h:112
std::string getSVTypeSymbol(SVType sv_type)
Definition sv_types.h:141
SVType
Definition sv_types.h:16
const std::unordered_map< SVDataType, std::string > SVDataTypeString
Definition sv_types.h:82
SVDataType
Definition sv_types.h:66
SVType getSVTypeFromCNState(int cn_state)
Definition sv_types.h:126
bool isValidCopyNumberUpdate(SVType sv_type, SVType updated_sv_type)
Definition sv_types.h:146
std::bitset< 10 > SVEvidenceFlags
Definition sv_types.h:79
std::string getGenotypeString(Genotype genotype)
Definition sv_types.h:131
const std::unordered_map< SVType, std::string > SVTypeSymbol
Definition sv_types.h:40
Genotype
Definition sv_types.h:50
std::string getSVTypeString(SVType sv_type)
Definition sv_types.h:107
const std::unordered_map< Genotype, std::string > GenotypeString
Definition sv_types.h:58