-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathgraph_pack_helpers.cpp
More file actions
124 lines (95 loc) · 3.58 KB
/
graph_pack_helpers.cpp
File metadata and controls
124 lines (95 loc) · 3.58 KB
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
//***************************************************************************
//* Copyright (c) 2023-2024 SPAdes team
//* Copyright (c) 2018-2022 Saint Petersburg State University
//* All Rights Reserved
//* See file LICENSE for details.
//***************************************************************************
#include "graph_pack_helpers.h"
#include "graph_pack.hpp"
#include "alignment/edge_index.hpp"
#include "alignment/kmer_mapper.hpp"
#include "alignment/long_read_storage.hpp"
#include "assembly_graph/core/graph.hpp"
#include "assembly_graph/graph_support/genomic_quality.hpp"
#include "assembly_graph/handlers/edges_position_handler.hpp"
#include "assembly_graph/paths/bidirectional_path_container.hpp"
#include "paired_info/paired_info.hpp"
#include "sequence/genome_storage.hpp"
#include "visualization/position_filler.hpp"
namespace graph_pack {
using namespace debruijn_graph;
void FillQuality(GraphPack& gp) {
const auto &index = gp.get<EdgeIndex<Graph>>();
const auto &kmer_mapper = gp.get<KmerMapper<Graph>>();
const auto &genome = gp.get<GenomeStorage>();
gp.get_mutable<EdgeQuality<Graph>>().Fill(index, kmer_mapper, genome.GetSequence());
}
//todo remove with usages after checking
void ClearQuality(GraphPack& gp) {
gp.get_mutable<EdgeQuality<Graph>>().clear();
}
void EnsureIndex(GraphPack& gp) {
auto &index = gp.get_mutable<EdgeIndex<Graph>>();
if (index.IsAttached())
return;
INFO("Index refill");
index.Refill();
index.Attach();
}
void EnsureBasicMapping(GraphPack& gp, bool check_mapper) {
EnsureIndex(gp);
if (check_mapper) {
auto &kmer_mapper = gp.get_mutable<KmerMapper<Graph>>();
VERIFY(kmer_mapper.IsAttached());
INFO("Normalizing k-mer map. Total " << kmer_mapper.size() << " kmers to process");
kmer_mapper.Normalize();
INFO("Normalizing done");
}
}
void EnsureQuality(GraphPack& gp) {
auto &edge_qual = gp.get_mutable<EdgeQuality<Graph>>();
if (edge_qual.IsAttached())
return;
ClearQuality(gp);
FillQuality(gp);
edge_qual.Attach();
}
void EnsurePos(GraphPack& gp) {
auto &edge_pos = gp.get_mutable<omnigraph::EdgesPositionHandler<Graph>>();
if (!edge_pos.IsAttached())
edge_pos.Attach();
// Positions are refilled every time
edge_pos.clear();
const auto &genome = gp.get<GenomeStorage>();
visualization::position_filler::FillPos(gp, genome.str(), "ref0");
visualization::position_filler::FillPos(gp, ReverseComplement(genome.str()), "ref1");
}
void EnsureDebugInfo(GraphPack& gp) {
EnsureBasicMapping(gp);
EnsureQuality(gp);
EnsurePos(gp);
}
void InitRRIndices(GraphPack& gp) {
using Indices = omnigraph::de::PairedInfoIndicesT<Graph>;
gp.get_mutable<Indices>("clustered_indices").Init();
gp.get_mutable<Indices>("scaffolding_indices").Init();
}
void ClearRRIndicesAndPaths(GraphPack& gp) {
using UnclusteredIndices = omnigraph::de::UnclusteredPairedInfoIndicesT<Graph>;
using Indices = omnigraph::de::PairedInfoIndicesT<Graph>;
gp.get_mutable<UnclusteredIndices>().Clear();
gp.get_mutable<Indices>("clustered_indices").Clear();
gp.get_mutable<Indices>("scaffolding_indices").Clear();
gp.get_mutable<LongReadContainer<Graph>>().Clear();
gp.get_mutable<path_extend::PathContainer>("exSPAnder paths").clear();
}
void DetachAll(GraphPack& gp) {
gp.DetachAll();
}
void PrepareForStage(GraphPack& gp, const char*) {
gp.get_mutable<Graph>().clear_state();
}
void DetachEdgeIndex(GraphPack& gp) {
gp.get_mutable<EdgeIndex<Graph>>().Detach();
}
} // namespace debruijn_graph