Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into lr-giraffe
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnovak committed Sep 10, 2024
2 parents 1bef104 + 95bcbb4 commit beec239
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions src/subcommand/stats_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void help_stats(char** argv) {
<< " multiple allowed; limit comparison to those provided" << endl
<< " -O, --overlap-all print overlap table for the cartesian product of paths" << endl
<< " -R, --snarls print statistics for each snarl" << endl
<< " --snarl-contents print out a table of <snarl, depth, parent, contained node ids>" << endl
<< " -C, --chains print statistics for each chain" << endl
<< " -F, --format graph format from {VG-Protobuf, PackedGraph, HashGraph, XG}. " <<
"Can't detect Protobuf if graph read from stdin" << endl
Expand Down Expand Up @@ -107,10 +108,14 @@ int main_stats(int argc, char** argv) {
bool overlap_all_paths = false;
bool snarl_stats = false;
bool chain_stats = false;
bool snarl_contents = false;
bool format = false;
bool degree_dist = false;
string distance_index_filename;

// Long options with no corresponding short options.
constexpr int OPT_SNARL_CONTENTS = 1000;

int c;
optind = 2; // force optind past command positional argument
while (true) {
Expand All @@ -137,6 +142,7 @@ int main_stats(int argc, char** argv) {
{"overlap", no_argument, 0, 'o'},
{"overlap-all", no_argument, 0, 'O'},
{"snarls", no_argument, 0, 'R'},
{"snarl-contents", no_argument, 0, OPT_SNARL_CONTENTS},
{"chains", no_argument, 0, 'C'},
{"format", no_argument, 0, 'F'},
{"degree-dist", no_argument, 0, 'D'},
Expand Down Expand Up @@ -236,6 +242,10 @@ int main_stats(int argc, char** argv) {
snarl_stats = true;
break;

case OPT_SNARL_CONTENTS:
snarl_contents = true;
break;

case 'C':
chain_stats = true;
break;
Expand Down Expand Up @@ -305,7 +315,6 @@ int main_stats(int argc, char** argv) {
exit(1);
}
};


if (stats_size) {
require_graph();
Expand Down Expand Up @@ -1130,7 +1139,7 @@ int main_stats(int argc, char** argv) {
// We will track depth for each snarl (used for both snarl and chains stats)
unordered_map<const Snarl*, size_t> depth;

if (snarl_stats || chain_stats) {
if (snarl_stats || chain_stats || snarl_contents) {
// We will go through all the snarls and compute stats.

require_graph();
Expand Down Expand Up @@ -1212,6 +1221,35 @@ int main_stats(int argc, char** argv) {
auto netGraph = manager.net_graph_of(snarl, graph, false);
cout << netGraph.get_node_count() << endl;
}

if (snarl_contents) {
pair<unordered_set<vg::id_t>, unordered_set<vg::edge_t> > contents = manager.deep_contents(snarl, *graph, false);
contents.second.clear();
set<vg::id_t> sorted_nodes(contents.first.begin(), contents.first.end());
// don't bother with trivial snarls
if (!sorted_nodes.empty()) {
cout << (snarl->start().backward() ? "<" : ">") << snarl->start().node_id()
<< (snarl->end().backward() ? "<" : ">") << snarl->end().node_id() << "\t"
<< depth[snarl] << "\t";
if (parent) {
cout << (parent->start().backward() ? "<" : ">") << parent->start().node_id()
<< (parent->end().backward() ? "<" : ">") << parent->end().node_id() << "\t";
} else {
cout << ".\t";
}

bool first = true;
for (vg::id_t node_id : sorted_nodes) {
if (first) {
first = false;
} else {
cout << ",";
}
cout << node_id;
}
cout << "\n";
}
}
});

}
Expand Down

1 comment on commit beec239

@adamnovak
Copy link
Member Author

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 branch lr-giraffe. View the full report here.

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

Please sign in to comment.