Skip to content

Commit

Permalink
Merge pull request #4353 from vgteam/deconstruct
Browse files Browse the repository at this point in the history
Use batch path deletion interface in vg paths -d
  • Loading branch information
glennhickey committed Jul 23, 2024
2 parents 95fd1da + 2f317a0 commit c560498
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ void delete_nodes_and_chop_paths(MutablePathMutableHandleGraph* graph, const uno
vector<path_handle_t> path_handles;
graph->for_each_path_handle([&](path_handle_t path_handle) {
path_handles.push_back(path_handle);
});
});
vector<path_handle_t> paths_to_destroy;
for (path_handle_t& path_handle : path_handles) {

string path_name = graph->get_path_name(path_handle);
Expand Down Expand Up @@ -257,10 +258,13 @@ void delete_nodes_and_chop_paths(MutablePathMutableHandleGraph* graph, const uno
}

if (was_chopped) {
graph->destroy_path(path_handle);
paths_to_destroy.push_back(path_handle);
}
}

// delete the paths
graph->destroy_paths(paths_to_destroy);

DeletableHandleGraph* del_graph = dynamic_cast<DeletableHandleGraph*>(graph);
// delete the edges
for (edge_t edge : edges_to_delete) {
Expand Down
12 changes: 4 additions & 8 deletions src/subcommand/paths_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,21 +578,17 @@ int main_paths(int argc, char** argv) {
exit(1);
}

vector<string> to_destroy;
vector<path_handle_t> to_destroy;
if (drop_paths) {
for_each_selected_path([&](const path_handle_t& path_handle) {
string name = graph->get_path_name(path_handle);
to_destroy.push_back(name);
to_destroy.push_back(path_handle);
});
} else {
for_each_unselected_path([&](const path_handle_t& path_handle) {
string name = graph->get_path_name(path_handle);
to_destroy.push_back(name);
to_destroy.push_back(path_handle);
});
}
for (string& path_name : to_destroy) {
mutable_graph->destroy_path(graph->get_path_handle(path_name));
}
mutable_graph->destroy_paths(to_destroy);

// output the graph
serializable_graph->serialize(cout);
Expand Down

1 comment on commit c560498

@adamnovak
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vg CI tests complete for merge to master. View the full report here.

16 tests passed, 0 tests failed and 0 tests skipped in 17358 seconds

Please sign in to comment.