Skip to content

Commit

Permalink
Go back to indexing all visible paths as of they were reference, and …
Browse files Browse the repository at this point in the history
…complain about non-transparent overlays
  • Loading branch information
adamnovak committed Oct 28, 2024
1 parent fd5c186 commit 88181db
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
5 changes: 4 additions & 1 deletion bdsg/include/bdsg/overlays/packed_path_position_overlay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ using namespace handlegraph;

/*
* An overlay that adds the PathPositionHandleGraph interface to a static PathHandleGraph
* by augmenting it with compressed index data structures
* by augmenting it with compressed index data structures.
*
* TODO: Make the overlay transparent so that paths hidden in the base graph
* remain accessible through the path metadata queries.
*/
class PackedPositionOverlay : public PathPositionHandleGraph, public ExpandingOverlayGraph {

Expand Down
17 changes: 15 additions & 2 deletions bdsg/include/bdsg/overlays/reference_path_overlay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,26 @@ using namespace handlegraph;
* An overlay that adds fast access to paths in addition to allowing path
* position queries on them. The original graph's handle_t's and path_handle_t's
* remain valid for the overlay, but not the step_t's.
*
* Note that paths that are not indexed as reference paths (i.e. those that are
* hidden from for_each_path_handle by the backing graph and not listed in
* extra_path_names on construction) *will not be accessible through the
* overlay*! You can ask if they exist, but trying to get handles to steps on
* them will not work. To actually look at them you will need to go back to the
* base graph.
*
* TODO: Make the overlay transparent so that paths that don't get indexed in
* the overlay remain accessible but without the (fast versions of?) the
* position queries.
*/
class ReferencePathOverlay : public PathPositionHandleGraph {

public:

/// Create a ReferencePathOverlay. For paths with names in
/// extra_path_names, index them as if they were reference paths.
/// 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 = {});
ReferencePathOverlay() = default;
~ReferencePathOverlay() = default;
Expand Down
10 changes: 7 additions & 3 deletions bdsg/src/reference_path_overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ ReferencePathOverlay::ReferencePathOverlay(const PathHandleGraph* graph, const s

// Get step counts for all paths we want to process, once.
std::unordered_map<path_handle_t, size_t> cached_step_counts;
graph->for_each_path_matching({PathSense::REFERENCE, PathSense::GENERIC}, {}, {}, [&](const path_handle_t& path) {
// Find and measure all the reference and generic paths.
// TODO: Kick out generic paths?
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.
cached_step_counts[path] = graph->get_step_count(path);
});
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);
Expand Down

0 comments on commit 88181db

Please sign in to comment.