third_party_software/hmmer-3.0-linux-intel-x86_64/easel/miniapps/esl-alimanip.c
/* Function:  insert_x_pair_shared_length()
 * Synopsis:  Calculate the fraction of inserts shared between of two aligned digital seqs,
 *            weighted by the length of the inserts.
 * Incept:    EPN, Wed Jun 25 10:33:23 2008
 *
 * Purpose:   Returns the weighted fraction of the total
 *            number of inserts in both sequences that are shared.
 *            
 * Args:      msa          - MSA, digitized, with RF annotation
 *            i            - index of seq 1
 *            j            - indes of seq 2
 *            cfirst       - first consensus position to consider
 *            clast        - last consensus position to consider
 *            opt_pshared  - optRETURN: pairwise insert identity, 0<=x<=1
 *            opt_nshared  - optRETURN: weighted # inserts shared
 *            opt_nins     - optRETURN: nins, number of columns with an insert
 *
 * Returns:   <eslOK> on success. <opt_distance>, <opt_nid>, <opt_n>
 *            contain the answers, for any of these that were passed
 *            non-<NULL> pointers.
 *
 * Throws:    <eslEINVAL> if the strings are different lengths (not aligned).
 */
insert_x_pair_shared_length()
Synopsis:  Calculate the fraction of inserts shared between of two aligned digital seqs,
weighted by the length of the inserts.

Returns the weighted fraction of the total
number of inserts in both sequences that are shared.



 on success. , , 
contain the answers, for any of these that were passed
non- pointers.

 if the strings are different lengths (not aligned).
insert_x_pair_shared_length () Synopsis : Calculate the fraction of inserts shared between of two aligned digital seqs weighted by the length of the inserts . Returns the weighted fraction of the total number of inserts in both sequences that are shared . on success . contain the answers for any of these that were passed non - pointers . if the strings are different lengths ( not aligned ) .
int
insert_x_pair_shared_length(ESL_MSA *msa, int *i_am_rf, int i, int j, int cfirst, int clast, double *opt_pshared, double *opt_nshared, int *opt_nins)
{
  double  shared;               
  int     nins;                 
  int     apos;                 
  int     rfpos;
  int     leni, lenj;
  shared = nins = leni = lenj = 0;
  rfpos = 0;
  for(apos = 1; apos <= msa->alen; apos++)
    {
      if(i_am_rf[(apos-1)]) { 
	rfpos++;
	if(rfpos >= cfirst && rfpos <= clast) { 
	  if((leni + lenj) > 0) { 
	    nins++;
	    if(leni >= lenj) shared += (double) lenj / (double) leni;
	    else             shared += (double) leni / (double) lenj;
	  }
	  leni = lenj = 0;
	}
      }
      else { 
	if(! esl_abc_XIsGap(msa->abc, msa->ax[i][apos])) leni++;
	if(! esl_abc_XIsGap(msa->abc, msa->ax[j][apos])) lenj++;
      }
    }
  if (opt_pshared  != NULL)  *opt_pshared  = ( nins==0 ? 1. : (double) shared / (double) nins );
  if (opt_nshared  != NULL)  *opt_nshared  = shared;
  if (opt_nins     != NULL)  *opt_nins     = nins;
  return eslOK;
}
int insert_x_pair_shared_length ( ESL_MSA * msa , int * i_am_rf , int i , int j , int cfirst , int clast , double * opt_pshared , double * opt_nshared , int * opt_nins ) { double shared ; int nins ; int apos ; int rfpos ; int leni , lenj ; shared = nins = leni = lenj = 0 ; rfpos = 0 ; for ( apos = 1 ; apos <= msa -> alen ; apos ++ ) { if ( i_am_rf [ ( apos - 1 ) ] ) { rfpos ++ ; if ( rfpos >= cfirst && rfpos <= clast ) { if ( ( leni + lenj ) > 0 ) { nins ++ ; if ( leni >= lenj ) shared += ( double ) lenj / ( double ) leni ; else shared += ( double ) leni / ( double ) lenj ; } leni = lenj = 0 ; } } else { if ( ! esl_abc_XIsGap ( msa -> abc , msa -> ax [ i ] [ apos ] ) ) leni ++ ; if ( ! esl_abc_XIsGap ( msa -> abc , msa -> ax [ j ] [ apos ] ) ) lenj ++ ; } } if ( opt_pshared != NULL ) * opt_pshared = ( nins == 0 ? 1. : ( double ) shared / ( double ) nins ) ; if ( opt_nshared != NULL ) * opt_nshared = shared ; if ( opt_nins != NULL ) * opt_nins = nins ; return eslOK ; }
Function:  insert_x_pair_shared_length()
 Synopsis:  Calculate the fraction of inserts shared between of two aligned digital seqs,
            weighted by the length of the inserts.
Function : insert_x_pair_shared_length () Synopsis : Calculate the fraction of inserts shared between of two aligned digital seqs weighted by the length of the inserts .
/* weighted shared inserts */ /* number of inserts in either sequence */ /* position in aligned seqs   */ /* not a consensus column, an insert column */ /*if (opt_pshared  != NULL)  *opt_pshared  = ( nins==0 ? 0. : (double) shared / (double) nins );*/