Skip to content

Commit b2db425

Browse files
committed
dont handle alts in vg_set
1 parent bc9766f commit b2db425

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

src/subcommand/index_main.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ gbwt::vector_type predecessors(const xg::XG& xg_index, const Path& path) {
110110
cerr << "Look for predecessors of node " << first_node << " " << is_reverse << " which is first in alt path" << endl;
111111
#endif
112112

113-
xg_index.follow_edges(xg_index.get_handle(first_node), true, [&] (handle_t next) {
113+
xg_index.follow_edges(xg_index.get_handle(first_node), !is_reverse, [&] (handle_t next) {
114114
if (xg_index.get_id(next) != first_node) {
115115
result.push_back(gbwt::Node::encode(xg_index.get_id(next), xg_index.get_is_reverse(next)));
116116
}
@@ -533,7 +533,15 @@ int main_index(int argc, char** argv) {
533533
return 1;
534534
}
535535
VGset graphs(file_names);
536-
graphs.to_xg(*xg_index, false, Paths::is_alt, index_haplotypes ? &alt_paths : nullptr);
536+
graphs.to_xg(*xg_index);
537+
if (index_haplotypes) {
538+
xg_index->for_each_path_handle([&](path_handle_t path_handle) {
539+
string path_name = xg_index->get_path_name(path_handle);
540+
if (Paths::is_alt(path_name)) {
541+
alt_paths[path_name] = path_from_path_handle(*xg_index, path_handle);
542+
}
543+
});
544+
}
537545
if (show_progress) {
538546
cerr << "Built base XG index" << endl;
539547
}
@@ -733,7 +741,7 @@ int main_index(int argc, char** argv) {
733741
xg_index->for_each_path_handle([&](path_handle_t path_handle) {
734742
path_handles[path_rank++] = path_handle;
735743
});
736-
for (path_rank = 1; path_rank < path_handles.size(); ++path_rank) {
744+
for (path_rank = 1; path_rank <= max_path_rank; path_rank++) {
737745
string path_name = xg_index->get_path_name(path_handles[path_rank]);
738746
string vcf_contig_name = path_to_vcf.count(path_name) ? path_to_vcf[path_name] : path_name;
739747
if (show_progress) {

src/vg_set.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,7 @@ int64_t VGset::merge_id_space(void) {
7474
return max_node_id;
7575
}
7676

77-
void VGset::to_xg(xg::XG& index, bool store_threads) {
78-
// Send a predicate to match nothing
79-
to_xg(index, store_threads, [](const string& ignored) {
80-
return false;
81-
});
82-
}
83-
84-
void VGset::to_xg(xg::XG& index, bool store_threads, const function<bool(const string&)>& paths_to_take, map<string, Path>* removed_paths) {
77+
void VGset::to_xg(xg::XG& index) {
8578

8679
// We need to recostruct full removed paths from fragmentary paths encountered in each chunk.
8780
// This maps from path name to all the Mappings in the path in the order we encountered them

src/vg_set.hpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,7 @@ class VGset {
3838
int64_t merge_id_space(void);
3939

4040
/// Transforms to a succinct, queryable representation
41-
void to_xg(xg::XG& index, bool store_threads = false);
42-
/// As above, except paths with names matching the given predicate are removed.
43-
/// They are returned separately by inserting them into the provided map if not null.
44-
void to_xg(xg::XG& index, bool store_threads, const function<bool(const string&)>& paths_to_take,
45-
map<string, Path>* removed_paths = nullptr);
46-
/// As above, except paths with names matching the given regex are removed.
47-
/// They are returned separately by inserting them into the provided map if not null.
48-
void to_xg(xg::XG& index, bool store_threads, const regex& paths_to_take, map<string, Path>* removed_paths = nullptr);
41+
void to_xg(xg::XG& index);
4942

5043
// stores the nodes in the VGs identified by the filenames into the index
5144
void store_in_index(Index& index);

0 commit comments

Comments
 (0)