ContextSV v1.0.0
Loading...
Searching...
No Matches
sv_object.h
Go to the documentation of this file.
1#ifndef SV_OBJECT_H
2#define SV_OBJECT_H
3
4#include <vector>
5#include <memory>
6#include <string>
7#include <set>
8#include <stdexcept>
9#include <unordered_map>
10#include <string_view>
11
12#include "sv_types.h"
13
14using namespace sv_types;
15
16struct SVCall {
17 uint32_t start = 0;
18 uint32_t end = 0;
19 SVType sv_type = SVType::UNKNOWN;
20 std::string alt_allele = ".";
21 // SVDataType data_type = SVDataType::UNKNOWN;
23 Genotype genotype = Genotype::UNKNOWN;
24 double hmm_likelihood = 0.0;
25 int cn_state = 0; // Copy number state
26 int aln_offset = 0; // Alignment offset (read vs. reference distance factor)
27 int cluster_size = 0; // Number of SV calls in the cluster
28
29 bool operator<(const SVCall& other) const;
30
31 SVCall() = default;
32
35};
36
37void addSVCall(std::vector<SVCall>& sv_calls, SVCall& sv_call);
38
39// Merge SVs with identical start positions, and sum the cluster sizes
40void mergeDuplicateSVs(std::vector<SVCall>& sv_calls);
41
42uint32_t getSVCount(const std::vector<SVCall>& sv_calls);
43
44// Merge SVs using DBSCAN clustering
45void mergeSVs(std::vector<SVCall> &sv_calls, double epsilon, int min_pts, bool keep_noise, const std::string& json_filepath = "");
46
47// Save clusters of SV calls to a JSON file
48void saveClustersToJSON(const std::string& filename, const std::map<int, std::vector<SVCall>>& clusters);
49
50#endif // SV_OBJECT_H
Definition sv_types.h:13
SVType
Definition sv_types.h:16
std::bitset< 10 > SVEvidenceFlags
Definition sv_types.h:79
Genotype
Definition sv_types.h:50
Definition sv_object.h:16
SVEvidenceFlags aln_type
Definition sv_object.h:22
SVCall(uint32_t start, uint32_t end, SVType sv_type, const std::string &alt_allele, SVEvidenceFlags aln_type, Genotype genotype, double hmm_likelihood, int cn_state, int aln_offset, int cluster_size)
Definition sv_object.h:33
Genotype genotype
Definition sv_object.h:23
bool operator<(const SVCall &other) const
Definition sv_object.cpp:17
uint32_t end
Definition sv_object.h:18
uint32_t start
Definition sv_object.h:17
int aln_offset
Definition sv_object.h:26
SVCall()=default
double hmm_likelihood
Definition sv_object.h:24
SVType sv_type
Definition sv_object.h:19
int cn_state
Definition sv_object.h:25
std::string alt_allele
Definition sv_object.h:20
int cluster_size
Definition sv_object.h:27
uint32_t getSVCount(const std::vector< SVCall > &sv_calls)
Definition sv_object.cpp:35
void mergeDuplicateSVs(std::vector< SVCall > &sv_calls)
Definition sv_object.cpp:324
void mergeSVs(std::vector< SVCall > &sv_calls, double epsilon, int min_pts, bool keep_noise, const std::string &json_filepath="")
Definition sv_object.cpp:45
void saveClustersToJSON(const std::string &filename, const std::map< int, std::vector< SVCall > > &clusters)
Definition sv_object.cpp:271
void addSVCall(std::vector< SVCall > &sv_calls, SVCall &sv_call)
Definition sv_object.cpp:22