void Node::check_valid_graph() const { vector<Site> *sites = sequence->get_sites(); for(unsigned int i=0;i<sites->size();i++) { Site *ssite = &sites->at(i); if( ssite->has_fwd_edge() ) { Edge *edge = ssite->get_first_fwd_edge(); Site *esite = &sites->at(edge->get_end_site_index()); if(!esite->contains_bwd_edge(edge,true)) { Log_output::write_out("Node: site "+Log_output::itos(i)+" has fwd edge from "+Log_output::itos(edge->get_start_site_index())+ " to "+Log_output::itos(edge->get_end_site_index())+" but no return\n",1); } while( ssite->has_next_fwd_edge() ) { edge = ssite->get_next_fwd_edge(); esite = &sites->at(edge->get_end_site_index()); if(!esite->contains_bwd_edge(edge,true)) { Log_output::write_out("Node: site "+Log_output::itos(i)+" has fwd edge from "+Log_output::itos(edge->get_start_site_index())+ " to "+Log_output::itos(edge->get_end_site_index())+" but no return\n",1); } } } if( ssite->has_bwd_edge() ) { Edge *edge = ssite->get_first_bwd_edge(); Site *esite = &sites->at(edge->get_start_site_index()); if(!esite->contains_fwd_edge(edge,true)) { Log_output::write_out("Node: site "+Log_output::itos(i)+" has bwd edge from "+Log_output::itos(edge->get_start_site_index())+ " to "+Log_output::itos(edge->get_end_site_index())+" but no return\n",1); } while( ssite->has_next_bwd_edge() ) { edge = ssite->get_next_bwd_edge(); esite = &sites->at(edge->get_start_site_index()); if(!esite->contains_fwd_edge(edge,true)) { Log_output::write_out("Node: site "+Log_output::itos(i)+" has bwd edge from "+Log_output::itos(edge->get_start_site_index())+ " to "+Log_output::itos(edge->get_end_site_index())+" but no return\n",1); } } } } }
void Basic_alignment::check_skipped_boundaries(Sequence *sequence) { vector<Site> *sites = sequence->get_sites(); // First, find 'Match/Skipped' and 'Skipped/Matched' boundaries and update the counts // for(unsigned int i=0;i<sites->size();i++) { Site *tsite = &sites->at(i); if( tsite->has_bwd_edge() ) { Edge *edge = tsite->get_first_bwd_edge(); while( tsite->has_next_bwd_edge() ) { Edge *another = tsite->get_next_bwd_edge(); if( another->get_start_site_index() > edge->get_start_site_index() ) edge = another; } Site *psite = &sites->at( edge->get_start_site_index() ); if( ( psite->get_path_state()==Site::matched || psite->get_path_state()==Site::start_site ) && ( tsite->get_path_state()==Site::xskipped || tsite->get_path_state()==Site::yskipped ) ) { edge->increase_branch_count_as_skipped_edge(); } } if( tsite->has_fwd_edge() ) { Edge *edge = tsite->get_first_fwd_edge(); while( tsite->has_next_fwd_edge() ) { Edge *another = tsite->get_next_fwd_edge(); if( another->get_start_site_index() < edge->get_start_site_index() ) edge = another; } Site *nsite = &sites->at( edge->get_end_site_index() ); if( ( tsite->get_path_state()==Site::xskipped || tsite->get_path_state()==Site::yskipped ) && ( nsite->get_path_state()==Site::matched || nsite->get_path_state()==Site::ends_site ) ) { edge->increase_branch_count_as_skipped_edge(); } } } // Then, see if any pair of boundaries (covering a skipped gap) is above the limit. Delete the range. // bool non_skipped = true; int skip_start = -1; for(unsigned int i=1;i<sites->size();i++) { Site *tsite = &sites->at(i); int tstate = tsite->get_path_state(); if( non_skipped && ( tstate == Site::xskipped || tstate == Site::yskipped ) ) { if( tsite->has_bwd_edge() ) { Edge *edge = tsite->get_first_bwd_edge(); while( tsite->has_next_bwd_edge() ) { Edge *another = tsite->get_next_bwd_edge(); if( another->get_start_site_index() > edge->get_start_site_index() ) edge = another; } if(edge->get_branch_count_as_skipped_edge()>max_allowed_match_skip_branches) { skip_start = i; } } non_skipped = false; } if(!non_skipped && skip_start>=0 && tstate == Site::matched) { int edge_ind = -1; if( tsite->has_bwd_edge() ) { Edge *edge = tsite->get_first_bwd_edge(); if(edge->get_branch_count_as_skipped_edge()>max_allowed_match_skip_branches) edge_ind = edge->get_index(); while( tsite->has_next_bwd_edge() ) { edge = tsite->get_next_bwd_edge(); if(edge->get_branch_count_as_skipped_edge()>max_allowed_match_skip_branches) edge_ind = edge->get_index(); } } if(edge_ind>=0) { Log_output::write_out("Basic_alignemnmt: delete range: "+Log_output::itos(edge_ind)+" "+Log_output::itos(skip_start)+" "+Log_output::itos(i)+"\n",4); this->delete_edge_range(sequence,edge_ind,skip_start); } non_skipped = true; skip_start = -1; } if(tstate == Site::xgapped || tstate == Site::ygapped || tstate == Site::matched) { non_skipped = true; skip_start = -1; } } }