From 8dd5b41b3545a7f5593fd243776dade391a41fa6 Mon Sep 17 00:00:00 2001 From: faithokamoto Date: Fri, 12 Jun 2026 15:10:19 -0700 Subject: [PATCH] rip out vg join --- src/subcommand/join_main.cpp | 93 ------------------------------------ src/vg.cpp | 45 ----------------- src/vg.hpp | 6 --- 3 files changed, 144 deletions(-) delete mode 100644 src/subcommand/join_main.cpp diff --git a/src/subcommand/join_main.cpp b/src/subcommand/join_main.cpp deleted file mode 100644 index 8e7f2d845e6..00000000000 --- a/src/subcommand/join_main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/** \file join_main.cpp - * - * Defines the "vg join" subcommand, which attaches graphs together. - */ - - -#include -#include -#include - -#include - -#include "subcommand.hpp" - -#include "../vg.hpp" - -using namespace std; -using namespace vg; -using namespace vg::subcommand; - -void help_join(char** argv) { - cerr << "usage: " << argv[0] << " join [options] [graph2.vg ...] >joined.vg" << endl - << "Joins graphs and sub-graphs into a single variant graph by connecting their" << endl - << "heads to a single root node with sequence 'N'." << endl - << "Assumes a single id namespace for all graphs to join." << endl - << " -h, --help print this help message to stderr and exit" << endl; -} - -int main_join(int argc, char** argv) { - - if (argc == 2) { - help_join(argv); - return 1; - } - - int c; - optind = 2; // force optind past command positional argument - while (true) { - static struct option long_options[] = - { - {"help", no_argument, 0, 'h'}, - {0, 0, 0, 0} - }; - - int option_index = 0; - c = getopt_long (argc, argv, "h?", - long_options, &option_index); - - // Detect the end of the options. - if (c == -1) - break; - - switch (c) - { - case 'h': - case '?': - help_join(argv); - exit(1); - break; - - default: - abort (); - } - } - - list graphs; - - while (optind < argc) { - VG* graph; - get_input_file(optind, argc, argv, [&](istream& in) { - graph = new VG(in); - }); - graphs.push_back(graph); - } - - VG joined; - for (list::iterator g = graphs.begin(); g != graphs.end(); ++g) { - // Stick all the graphs together, complaining if they use the same node IDs (since they probably shouldn't). - joined.extend(**g, true); - } - - // combine all subgraphs - joined.join_heads(); - - // output - joined.serialize_to_ostream(std::cout); - - return 0; -} - -// Register subcommand -static Subcommand vg_join("join", "combine graphs via a new head", DEPRECATED, main_join); - diff --git a/src/vg.cpp b/src/vg.cpp index f0206908dfd..2faaf84fb26 100644 --- a/src/vg.cpp +++ b/src/vg.cpp @@ -4880,51 +4880,6 @@ void VG::connect_nodes_to_node(vector& nodes, NodeTraversal node) } } -// join all subgraphs together to a "null" head node -Node* VG::join_heads(void) { - // Find the head nodes - vector heads; - head_nodes(heads); - - // Then create the new node (so it isn't picked up as a head) - current_id = max_node_id()+1; - Node* root = create_node("N"); - - // Wire it to all the heads and return - connect_node_to_nodes(root, heads); - return root; -} - -void VG::join_heads(Node* node, bool from_start) { - vector heads; - head_nodes(heads); - - // If the node we have been given shows up as a head, remove it. - for(auto i = heads.begin(); i != heads.end(); ++i) { - if(*i == node) { - heads.erase(i); - break; - } - } - - connect_node_to_nodes(node, heads, from_start); -} - -void VG::join_tails(Node* node, bool to_end) { - vector tails; - tail_nodes(tails); - - // If the node we have been given shows up as a tail, remove it. - for(auto i = tails.begin(); i != tails.end(); ++i) { - if(*i == node) { - tails.erase(i); - break; - } - } - - connect_nodes_to_node(tails, node, to_end); -} - void VG::add_start_end_markers(int length, char start_char, char end_char, Node*& start_node, Node*& end_node, diff --git a/src/vg.hpp b/src/vg.hpp index 9c20f2023e8..7a732136bf4 100644 --- a/src/vg.hpp +++ b/src/vg.hpp @@ -1256,12 +1256,6 @@ class VG : public Progressive, public MutablePathDeletableHandleGraph { /// Collect the subgraph of a Node. TODO: what does that mean? void collect_subgraph(Node* node, set& subgraph); - /// Join head nodes of graph to common null node, creating a new single head. - Node* join_heads(void); - /// Join head nodes of graph to specified node. Optionally from the start/to the end of the new node. - void join_heads(Node* node, bool from_start = false); - /// Join tail nodes of graph to specified node. Optionally from the start/to the end of the new node. - void join_tails(Node* node, bool to_end = false); /// Add singular head and tail null nodes to graph. void wrap_with_null_nodes(void); /// Add a start node and an end node, where all existing heads in the graph