long int tyay = byay + cyay;  if ((float)byay/(float)tyay*100.0 >= OPT_Majority)
float tyay = byay + cyay; if ( tyay == 0 ) tyay = -1;  if ((float)byay / tyay * 100.0 >= OPT_Majority)
void RefineConflicts (Mapping_t & mapping){  ReadMap_t temprm;  temprm . place = new ReadAlignChain_t( );  temprm . place -> head = new ReadAlign_t( );  long int cpos, beg, end, tot;  Reference_t * rp;  ReadAlign_t * rap;  list<Conflict_t *>::iterator cpi, locpi, hicpi, bcpi, ecpi;  map<string, Reference_t>::iterator rmi;  vector<ReadMap_t *>::iterator rmpi, rmpie, ri, rj;  set<ReadMap_t *>::iterator si;  pair<    vector<ReadMap_t *>::iterator,    vector<ReadMap_t *>::iterator    > rmpip;  vector<ReadMap_t *> heap;  vector<Conflict_t *> breaks;  vector<Conflict_t *>::iterator bi;  set<ReadMap_t *> readsetA;  set<ReadMap_t *> readsetB;  //-- For each reference and its conflicts  for ( rmi  = mapping . references . begin( );	rmi != mapping . references . end( ); ++ rmi )    {      rp = &(rmi -> second);      bcpi = rp -> conflicts . begin( );      ecpi = rp -> conflicts . end( );      //-- Find the read mapping range      temprm . place -> head -> ref = rp;      rmpip = equal_range (mapping . reads . begin( ), mapping . reads . end( ),			   &temprm, ReadReferenceCmp_t( ));      rmpi = rmpip . first;      rmpie = rmpip . second;      //-- For each *BREAK*, collect nay counts      for ( cpi = bcpi; cpi != ecpi; ++ cpi )	{	  if ( (*cpi) -> type == Conflict_t::INDEL )	    continue;	  cpos = (*cpi) -> pos;	  //-- Update the heap to current conflict pos	  while ( !heap . empty( )  &&  heap . front( ) -> place -> end < cpos )	    PopHeap (heap);	  //-- Load up the heap with reads that overlap the conflict	  for ( ; rmpi != rmpie  &&  (*rmpi) -> place -> beg <= cpos; ++ rmpi )	    if ( (*rmpi) -> place -> end >= cpos )	      PushHeap (heap, *rmpi);	  //-- Collect the nay counts, i.e. reads that do not agree on break	  for ( ri = heap . begin( ); ri != heap . end( ); ++ ri )	    for ( rap = (*ri)->place->head; rap != NULL; rap = rap->from )	      if ( rap -> loR < cpos - FUZZY  &&  rap -> hiR > cpos + FUZZY )		{		  (*cpi) -> discount . insert (*ri);		  break;		}	  //-- Can't discount break if supporting it	  set_difference	    ((*cpi) -> discount . begin( ), (*cpi) -> discount . end( ),	     (*cpi) -> support  . begin( ), (*cpi) -> support  . end( ),	     insert_iterator<set<ReadMap_t *> >	     (readsetA, readsetA . begin( )));	  (*cpi) -> discount . swap (readsetA);	  readsetA . clear( );	  //-- Call the break SUPPORTED, UNSUPPORTED, AMBIGUOUS	  CallConflict (*cpi);	  //-- We don't want to accept breaks, so call them ambiguous	  if ( (*cpi) -> status == Conflict_t::SUPPORTED )	    (*cpi) -> status = Conflict_t::AMBIGUOUS;	}      heap . clear( );      //-- For each *INDEL*, sum yay/nay counts from its break counts      for ( cpi = bcpi; cpi != ecpi; ++ cpi )	{	  if ( (*cpi)->type != Conflict_t::INDEL )	    continue;	  //-- The reference breaks for the gap	  beg = (*cpi) -> pos;	  end = (*cpi) -> pos + (*cpi) -> gapR + 1;	  //-- Find conflicts corresponding to the reference HIBREAK	  for ( hicpi = bcpi; hicpi != ecpi; ++ hicpi )	    if ( hicpi != cpi  &&		 labs ((*hicpi)->pos - beg) <= FUZZY )	      {		breaks . push_back (*hicpi);		if ( (*hicpi) -> type == Conflict_t::HIBREAK )		  {		    //-- Add to INDEL support if hang isn't too large		    for ( si  = (*hicpi) -> support . begin( );			  si != (*hicpi) -> support . end( ); ++ si )		      if ( (*si) -> place -> end - beg <			   (*cpi) -> gapQ + OPT_MaxTrimLen )			(*cpi) -> support . insert (*si);		    //-- Add to hibreak discount		    for ( si  = (*hicpi) -> discount . begin( );			  si != (*hicpi) -> discount . end( ); ++ si )		      readsetA . insert (*si);		  }	      }	  //-- Find conflicts corresponding to the reference LOBREAK	  for ( locpi = bcpi; locpi != ecpi; ++ locpi )	    if ( locpi != cpi  &&		 labs ((*locpi)->pos + (*locpi)->gapR + 1 - end) <= FUZZY )	      {		breaks . push_back (*locpi);		if ( (*locpi) -> type == Conflict_t::LOBREAK )		  {		    //-- Add to INDEL support if hang isn't too large		    for ( si  = (*locpi) -> support . begin( );			  si != (*locpi) -> support . end( ); ++ si )		      if ( end - (*si) -> place -> beg <			   (*cpi) -> gapQ + OPT_MaxTrimLen )			(*cpi) -> support . insert (*si);		    //-- Add to lobreak discount		    for ( si  = (*locpi) -> discount . begin( );			  si != (*locpi) -> discount . end( ); ++ si )		      readsetB . insert (*si);		  }	      }	  //-- One break discounted good enough for regular gap	  if ( (*cpi) -> gapR > 0 )	    set_union	      (readsetA . begin( ), readsetA . end( ),	       readsetB . begin( ), readsetB . end( ),	       insert_iterator<set<ReadMap_t *> >	       ((*cpi) -> discount, (*cpi) -> discount . begin( )));	  //-- Tandems with reference overlap need both breaks discounted	  else	    set_intersection	      (readsetA . begin( ), readsetA . end( ),	       readsetB . begin( ), readsetB . end( ),	       insert_iterator<set<ReadMap_t *> >	       ((*cpi) -> discount, (*cpi) -> discount . begin( )));	  readsetA . clear( );	  readsetB . clear( );	  //-- Can't support indel if discounting it	  set_difference	    ((*cpi) -> support  . begin( ), (*cpi) -> support  . end( ),	     (*cpi) -> discount . begin( ), (*cpi) -> discount . end( ),	     insert_iterator<set<ReadMap_t *> >	     (readsetA, readsetA . begin( )));	  (*cpi) -> support . swap (readsetA);	  readsetA . clear( );	  //-- Call the indel SUPPORTED, UNSUPPORTED, AMBIGUOUS	  CallConflict (*cpi);	  //-- Flag indel breaks as artifacts	  if ( (*cpi) -> status != Conflict_t::UNSUPPORTED )	    for ( bi = breaks . begin( ); bi != breaks . end( ); ++ bi )	      {		if ( (*bi) -> type != Conflict_t::INDEL )		  (*bi) -> status = Conflict_t::ARTIFACT;		else if ( (*bi)  -> status != Conflict_t::UNSUPPORTED  &&			  (*cpi) -> status != Conflict_t::ARTIFACT )		  {		    long int byay = (*bi) -> support . size( );		    long int cyay = (*cpi) -> support . size( );		    long int tyay = byay + cyay;		    		    if ((float)byay/(float)tyay*100.0 >= OPT_Majority)		      (*cpi) -> status = Conflict_t::ARTIFACT;		    else if ((float)cyay/(float)tyay*100.0 >= OPT_Majority)		      (*bi) -> status = Conflict_t::ARTIFACT;		    else		      {			long int bnay = (*bi) -> discount . size( );			long int cnay = (*cpi) -> discount . size( );			long int tnay = bnay + cnay;						if ((float)bnay/(float)tnay*100.0 >= OPT_Majority)			  (*bi) -> status = Conflict_t::ARTIFACT;			else if ((float)cnay/(float)tnay*100.0 >= OPT_Majority)			  (*cpi) -> status = Conflict_t::ARTIFACT;			else			  {			    (*bi)  -> status = Conflict_t::AMBIGUOUS;			    (*cpi) -> status = Conflict_t::AMBIGUOUS;			  }		      }		  }	      }	  breaks . clear( );	}      //-- INCLUDE/EXCLUDE reads based on consistency      for ( cpi = bcpi; cpi != ecpi; ++ cpi )	if ( (*cpi) -> status == Conflict_t::ARTIFACT )	  {	    //-- Exclude supporting reads (will be revived later if good)	    for ( si  = (*cpi) -> support . begin( );		  si != (*cpi) -> support . end( ); ++ si )	      (*si) -> exclude = true;	  }	        for ( cpi = bcpi; cpi != ecpi; ++ cpi )	if ( (*cpi) -> status == Conflict_t::SUPPORTED )	  {	    //-- Include supporting reads (revives supporting artifacts)	    for ( si  = (*cpi) -> discount . begin( );		  si != (*cpi) -> discount . end( ); ++ si )	      (*si) -> exclude = true;	    //-- Exclude discounting reads	    for ( si  = (*cpi) -> support . begin( );		  si != (*cpi) -> support . end( ); ++ si )	      (*si) -> exclude = false;	  }      for ( cpi = bcpi; cpi != ecpi; ++ cpi )	if ( (*cpi) -> status == Conflict_t::UNSUPPORTED )	  {	    //-- Exclude supporting reads	    for ( si  = (*cpi) -> support . begin( );		  si != (*cpi) -> support . end( ); ++ si )	      (*si) -> exclude = true;	  }	else if ( (*cpi) -> status == Conflict_t::AMBIGUOUS )	  {	    //-- Exclude everything ambiguous	    for ( si  = (*cpi) -> discount . begin( );		  si != (*cpi) -> discount . end( ); ++ si )	      (*si) -> exclude = true;	    for ( si  = (*cpi) -> support . begin( );		  si != (*cpi) -> support . end( ); ++ si )	      (*si) -> exclude = true;	  }    }  delete temprm . place -> head;  delete temprm . place;}