-
Notifications
You must be signed in to change notification settings - Fork 6
dont put haplotypes in ReferencePathOverlays #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,11 +42,17 @@ class ReferencePathOverlay : public PathPositionHandleGraph { | |
|
|
||
| public: | ||
|
|
||
| /// Create a ReferencePathOverlay indexing all non-hidden paths in the | ||
| /// backing graph (which show up in for_each_path_handle()). For path names | ||
| /// in extra_path_names, look them up and index them too, even if they are | ||
| /// hidden. | ||
| ReferencePathOverlay(const PathHandleGraph* graph, const std::unordered_set<std::string>& extra_path_names = {}); | ||
| /// Create a ReferencePathOverlay indexing paths in the backing graph. | ||
| /// If all_paths is true, indexes all paths visible via for_each_path_handle(). | ||
| /// If false (default), indexes only REFERENCE and GENERIC sense paths. | ||
| /// For path names in extra_path_names, look them up and index them too, | ||
| /// even if they are hidden. | ||
| ReferencePathOverlay(const PathHandleGraph* graph, bool all_paths = false); | ||
|
|
||
| /// Same, but also indexes hidden paths listed in extra_path_names. | ||
| ReferencePathOverlay(const PathHandleGraph* graph, | ||
| const std::unordered_set<std::string>& extra_path_names, | ||
| bool all_paths = false); | ||
|
Comment on lines
+54
to
+55
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
| ReferencePathOverlay() = default; | ||
| ~ReferencePathOverlay() = default; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,26 +13,39 @@ namespace bdsg { | |
| using namespace std; | ||
| using namespace handlegraph; | ||
|
|
||
| ReferencePathOverlay::ReferencePathOverlay(const PathHandleGraph* graph, const std::unordered_set<std::string>& extra_path_names) : graph(graph) { | ||
|
|
||
| // Get step counts for all paths we want to process, once. | ||
| ReferencePathOverlay::ReferencePathOverlay(const PathHandleGraph* graph, bool all_paths) | ||
| : ReferencePathOverlay(graph, std::unordered_set<std::string>{}, all_paths) { | ||
| } | ||
|
|
||
| ReferencePathOverlay::ReferencePathOverlay(const PathHandleGraph* graph, | ||
| const std::unordered_set<std::string>& extra_path_names, | ||
| bool all_paths) : graph(graph) { | ||
|
|
||
| std::unordered_map<path_handle_t, size_t> cached_step_counts; | ||
| graph->for_each_path_handle([&](const path_handle_t& path) { | ||
| // Find and measure all the non-hidden paths. | ||
| // TODO: If we made the overlay transparent so we could access paths | ||
| // that didn't get indexed, we wouldn't be weirdly indexing haplotype | ||
| // paths from backends that don't hide them in the "reference" path | ||
| // overlay. | ||
|
Comment on lines
-22
to
-25
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now all the backends are like that; I think I forgot to address that here when I made that change. |
||
| cached_step_counts[path] = graph->get_step_count(path); | ||
| }); | ||
|
|
||
| if (all_paths) { | ||
| // Index ALL visible paths | ||
| graph->for_each_path_handle([&](const path_handle_t& path) { | ||
| cached_step_counts[path] = graph->get_step_count(path); | ||
| return true; | ||
| }); | ||
| } else { | ||
| // Only index REFERENCE and GENERIC paths (the default) | ||
| std::unordered_set<PathSense> senses = {PathSense::REFERENCE, PathSense::GENERIC}; | ||
| graph->for_each_path_matching(&senses, nullptr, nullptr, [&](const path_handle_t& path) { | ||
| cached_step_counts[path] = graph->get_step_count(path); | ||
| return true; | ||
| }); | ||
| } | ||
|
|
||
| for (auto& path_name : extra_path_names) { | ||
| // Also index hidden paths that the user is asking for by name. | ||
| if (graph->has_path(path_name)) { | ||
| // The graph actually has this path. | ||
| path_handle_t path = graph->get_path_handle(path_name); | ||
| auto found = cached_step_counts.find(path); | ||
| if (found == cached_step_counts.end()) { | ||
| // And it's not already reference sense. | ||
| // And it's not already indexed. | ||
| // Count steps and remember it | ||
| cached_step_counts.emplace_hint(found, path, graph->get_step_count(path)); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't/shouldn't have a concept of a path being "hidden" anymore.