Skip to content

Commit

Permalink
Remove debug outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
rlorigro committed Oct 26, 2021
1 parent 45d0e9a commit f281c30
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 143 deletions.
131 changes: 30 additions & 101 deletions src/Bluntifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ using std::to_string;
namespace bluntifier{


void print_paths(handlegraph::PathHandleGraph& gfa_graph){
cerr << "\nPaths in graph: " << '\n';
gfa_graph.for_each_path_handle([&](const handlegraph::path_handle_t& p){
auto name = gfa_graph.get_path_name(p);
cerr << name << ":" << '\n';
gfa_graph.for_each_step_in_path(p, [&](const handlegraph::step_handle_t& s){
auto h = gfa_graph.get_handle_of_step(s);
cerr << '\t' << gfa_graph.get_id(h) << '\t' << gfa_graph.get_sequence(h) << '\n';
});
});
}


ProvenanceInfo::ProvenanceInfo(size_t start, size_t stop, bool reversal):
start(start),
stop(stop),
Expand Down Expand Up @@ -207,22 +220,6 @@ void Bluntifier::splice_subgraphs(){
size_t i = 0;
for (auto& subgraph: subgraphs) {

{
string test_path_prefix = "test_bluntify_subgraph_" + to_string(i);
ofstream test_output(test_path_prefix + ".gfa");
handle_graph_to_gfa(gfa_graph, test_output);
test_output.close();

if (gfa_graph.get_node_count() < 200) {
string command = "vg convert -g " + test_path_prefix + ".gfa -p | vg view -d - | dot -Tpng -o "
+ test_path_prefix + ".png";

cerr << "Running: " << command << '\n';

run_command(command);
}
}

// First, copy the subgraph into the GFA graph
subgraph.graph.increment_node_ids(gfa_graph.max_node_id());
copy_path_handle_graph(&subgraph.graph, &gfa_graph);
Expand All @@ -240,8 +237,6 @@ void Bluntifier::splice_subgraphs(){
bool is_oo_child;
tie(is_oo_parent, is_oo_child) = is_oo_node(node_id);

cerr << node_id << (is_oo_child ? " is_oo_child " : "") << (is_oo_parent ? " is_oo_parent " : "") << '\n';

if (not is_oo_child) {

// Find the path handle for the path that was copied into the GFA graph
Expand All @@ -255,6 +250,7 @@ void Bluntifier::splice_subgraphs(){
}
});

// This can be ignored in the case where there is a full-node overlap
// if (parent_handles.empty() and not is_oo_parent) {
// throw runtime_error("ERROR: biclique terminus does not have any parent: " + to_string(node_id));
// }
Expand All @@ -276,13 +272,12 @@ void Bluntifier::splice_subgraphs(){
}
}
else{
cerr << "Skipping oo child: " << node_id << '\n';
// Do nothing
}

if (subgraph.paths_per_handle[1-side].count(handle) == 0
and subgraph.paths_per_handle[1-side].count(gfa_graph.flip(handle)) == 0) {
to_be_destroyed.emplace(gfa_graph.get_id(handle));
cerr << "To be destroyed: " << gfa_graph.get_id(handle) << '\n';
}
}
}
Expand All @@ -291,7 +286,6 @@ void Bluntifier::splice_subgraphs(){


void Bluntifier::write_provenance(){


ofstream file(provenance_path);

Expand Down Expand Up @@ -535,22 +529,6 @@ void Bluntifier::bluntify(){

gfa_to_handle_graph(gfa_path, gfa_graph, id_map, overlaps);

{
string test_path_prefix = "test_bluntify_start";
ofstream test_output(test_path_prefix + ".gfa");
handle_graph_to_gfa(gfa_graph, test_output);
test_output.close();

if (gfa_graph.get_node_count() < 200) {
string command = "vg convert -g " + test_path_prefix + ".gfa -p | vg view -d - | dot -Tpng -o "
+ test_path_prefix + ".png";

cerr << "Running: " << command << '\n';

run_command(command);
}
}

log_progress("Computing adjacency components...");

// Compute Adjacency Components and store in vector
Expand Down Expand Up @@ -590,67 +568,18 @@ void Bluntifier::bluntify(){
child_to_parent,
overlapping_overlap_nodes);


for (size_t i=0; i<bicliques.size(); i++) {
cout << "Biclique " << i << '\n';
for (auto& edge: bicliques[i]) {
cout << "\t(" << gfa_graph.get_id(edge.first);
cout << (gfa_graph.get_is_reverse(edge.first) ? "-" : "+");
cout << ") -> (" << gfa_graph.get_id(edge.second);
cout << (gfa_graph.get_is_reverse(edge.second) ? "-" : "+") << ") ";
cout << gfa_graph.get_sequence(edge.first) << " " << gfa_graph.get_sequence(edge.second) << '\n';
}
}

log_progress("Duplicating node termini...");

super_duper.duplicate_all_node_termini(gfa_graph);

{
string test_path_prefix = "test_bluntify_duped";
ofstream test_output(test_path_prefix + ".gfa");
handle_graph_to_gfa(gfa_graph, test_output);
test_output.close();

if (gfa_graph.get_node_count() < 200) {
string command = "vg convert -g " + test_path_prefix + ".gfa -p | vg view -d - | dot -Tpng -o "
+ test_path_prefix + ".png";

cerr << "Running: " << command << '\n';

run_command(command);
}
}

log_progress("Harmonizing biclique edge orientations...");

for (size_t i=0; i<bicliques.size(); i++) {
cout << "Biclique " << i << '\n';
for (auto& edge: bicliques[i]) {
cout << "\t(" << gfa_graph.get_id(edge.first);
cout << (gfa_graph.get_is_reverse(edge.first) ? "-" : "+");
cout << ") -> (" << gfa_graph.get_id(edge.second);
cout << (gfa_graph.get_is_reverse(edge.second) ? "-" : "+") << ") ";
cout << gfa_graph.get_sequence(edge.first) << " " << gfa_graph.get_sequence(edge.second) << '\n';
}
}

harmonize_biclique_orientations();

log_progress("Aligning overlaps...");

subgraphs.resize(bicliques.size());

cerr << "\nPaths in graph: " << '\n';
gfa_graph.for_each_path_handle([&](const handlegraph::path_handle_t& p){
auto name = gfa_graph.get_path_name(p);
cerr << name << ":" << '\n';
gfa_graph.for_each_step_in_path(p, [&](const handlegraph::step_handle_t& s){
auto h = gfa_graph.get_handle_of_step(s);
cerr << '\t' << gfa_graph.get_id(h) << '\t' << gfa_graph.get_sequence(h) << '\n';
});
});

for (size_t i=0; i<bicliques.size(); i++){
align_biclique_overlaps(i);
}
Expand Down Expand Up @@ -688,21 +617,21 @@ void Bluntifier::bluntify(){
handle_graph_to_gfa(gfa_graph, cout);

// Output an image of the graph, can be uncommented for debugging
{
string test_path_prefix = "test_bluntify_final";
ofstream test_output(test_path_prefix + ".gfa");
handle_graph_to_gfa(gfa_graph, test_output);
test_output.close();

if (gfa_graph.get_node_count() < 200) {
string command = "vg convert -g " + test_path_prefix + ".gfa -p | vg view -d - | dot -Tpng -o "
+ test_path_prefix + ".png";

cerr << "Running: " << command << '\n';

run_command(command);
}
}
// {
// string test_path_prefix = "test_bluntify_final";
// ofstream test_output(test_path_prefix + ".gfa");
// handle_graph_to_gfa(gfa_graph, test_output);
// test_output.close();
//
// if (gfa_graph.get_node_count() < 200) {
// string command = "vg convert -g " + test_path_prefix + ".gfa -p | vg view -d - | dot -Tpng -o "
// + test_path_prefix + ".png";
//
// cerr << "Running: " << command << '\n';
//
// run_command(command);
// }
// }
}


Expand Down
5 changes: 0 additions & 5 deletions src/BluntifierAlign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ bool Bluntifier::biclique_overlaps_are_exact(size_t i){
auto query_start = gfa_graph.get_length(edge.first) - alignment.operations[0].length;
auto ref_start = 0;

// cerr << "explicitizing: " << gfa_graph.get_id(edge.first);
// cerr << "->" << gfa_graph.get_id(edge.second);
// cerr << " length=" << gfa_graph.get_length(edge.first) << ',';
// cerr << gfa_graph.get_length(edge.second) << '\n';

auto explicit_cigar_operations = alignment.explicitize_mismatches(gfa_graph, edge, ref_start, query_start);

sizes.emplace(explicit_cigar_operations[0].length);
Expand Down
2 changes: 0 additions & 2 deletions src/Cigar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ vector<Cigar> Alignment::explicitize_mismatches(
char query_base = graph.get_base(edge.second, iterator.query_index);
char ref_base = graph.get_base(edge.first, iterator.ref_index);

// std::cerr << iterator.query_index << " " << query_base << '-' << ref_base << " " << iterator.ref_index << '\n';

if (ref_base == query_base){
// If the last operation was already a Match (=), then extend its length
if (not explicit_operations.empty() and explicit_operations.back().type() == '='){
Expand Down
35 changes: 0 additions & 35 deletions src/OverlappingOverlapSplicer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ tuple<handle_t, size_t, size_t, bool> OverlappingOverlapSplicer::seek_to_path_ba
string& path_name,
size_t target_base_index){

cerr << "seeking path: " << path_name << '\n';

auto path_handle = gfa_graph.get_path_handle(path_name);
auto step = gfa_graph.path_begin(path_handle);

Expand All @@ -86,8 +84,6 @@ tuple<handle_t, size_t, size_t, bool> OverlappingOverlapSplicer::seek_to_path_ba
step_handle = gfa_graph.get_handle_of_step(step);
auto step_length = gfa_graph.get_length(step_handle);

cerr << target_base_index << " " << cumulative_index << " " << intra_handle_index << " " << gfa_graph.get_sequence(step_handle) << '\n';

if (cumulative_index + step_length > target_base_index){
intra_handle_index = target_base_index - cumulative_index;
fail = false;
Expand All @@ -102,8 +98,6 @@ tuple<handle_t, size_t, size_t, bool> OverlappingOverlapSplicer::seek_to_path_ba

remainder = target_base_index - cumulative_index;

cerr << (fail ? "FAIL with remainder " + to_string(remainder) : "PASS with remainder " + to_string(remainder)) << '\n';

return {step_handle, intra_handle_index, remainder, fail};
}

Expand All @@ -115,8 +109,6 @@ tuple<handle_t, size_t, size_t, bool> OverlappingOverlapSplicer::seek_to_reverse
string& path_name,
size_t target_base_index){

cerr << "seeking REVERSE path: " << path_name << '\n';

auto path_handle = gfa_graph.get_path_handle(path_name);
auto step = gfa_graph.path_back(path_handle);

Expand All @@ -130,8 +122,6 @@ tuple<handle_t, size_t, size_t, bool> OverlappingOverlapSplicer::seek_to_reverse
step_handle = gfa_graph.flip(gfa_graph.get_handle_of_step(step));
auto step_length = gfa_graph.get_length(step_handle);

cerr << target_base_index << " " << cumulative_index << " " << intra_handle_index << " " << gfa_graph.get_sequence(step_handle) << '\n';

if (cumulative_index + step_length > target_base_index){
intra_handle_index = target_base_index - cumulative_index;
fail = false;
Expand All @@ -146,8 +136,6 @@ tuple<handle_t, size_t, size_t, bool> OverlappingOverlapSplicer::seek_to_reverse

remainder = target_base_index - cumulative_index;

cerr << (fail ? "FAIL with remainder " + to_string(remainder) : "PASS with remainder " + to_string(remainder)) << '\n';

return {step_handle, intra_handle_index, remainder, fail};
}

Expand All @@ -160,8 +148,6 @@ void OverlappingOverlapSplicer::find_splice_pairs(

array <vector <overlapping_child_iter>, 2> other_children;

overlap_info.print(gfa_graph);

for (auto side: {0,1}) {
for (auto oo: overlap_info.overlapping_children[side]){

Expand Down Expand Up @@ -414,23 +400,6 @@ void OverlappingOverlapSplicer::find_splice_pairs(
void OverlappingOverlapSplicer::splice_overlapping_overlaps(MutablePathDeletableHandleGraph& gfa_graph) {

for (auto& oo_item: overlapping_overlap_nodes) {
// Output an image of the graph, can be uncommented for debugging
{
string test_path_prefix = "test_bluntify_splice_" + to_string(oo_item.first);
std::ofstream test_output(test_path_prefix + ".gfa");
handle_graph_to_gfa(gfa_graph, test_output);
test_output.close();

if (gfa_graph.get_node_count() < 200) {
string command = "vg convert -g " + test_path_prefix + ".gfa -p | vg view -d - | dot -Tpng -o "
+ test_path_prefix + ".png";

cerr << "Running: " << command << '\n';

run_command(command);
}
}

auto node_id = oo_item.first;
auto& overlap_info = oo_item.second;

Expand Down Expand Up @@ -479,17 +448,13 @@ void OverlappingOverlapSplicer::splice_overlapping_overlaps(MutablePathDeletable

if (left_index + 1 < gfa_graph.get_length(left_handle) and not left_fail) {
division_sites[left_handle].emplace(left_index + 1);
cerr << "Splice site for parent node " << node_id << " with children " << gfa_graph.get_id(left_handle) << " (" << gfa_graph.get_id(right_handle) << ") = " << left_index + 1 << '\n';
}

if (right_index < gfa_graph.get_length(right_handle) and right_index > 0 and not right_fail) {
division_sites[right_handle].emplace(right_index);
cerr << "Splice site for parent node " << node_id << " with children " << gfa_graph.get_id(right_handle) << " (" << gfa_graph.get_id(left_handle) << ") = " << right_index << '\n';
}
}

cerr << "Dividing nodes at oo splice sites... " << '\n';

// Do the divisions in bulk
for (auto& item: division_sites) {
vector<size_t> sites;
Expand Down

0 comments on commit f281c30

Please sign in to comment.