deps/kb_meme/meme-5.0.1/src/tomtom.c
/**************************************************************************
 * Compare 2 matches and put the best ones first.
 **************************************************************************/
Compare 2 matches and put the best ones first.
Compare 2 matches and put the best ones first .
static int tomtom_match_compare(const TOMTOM_MATCH_T **p1, const TOMTOM_MATCH_T **p2) {
  if ((*p1)->pvalue == (*p2)->pvalue) {
    if ((*p1)->overlap == (*p2)->overlap) {
      if ((*p1)->db->id == (*p2)->db->id) {
        return strcmp(get_motif_st_id((*p1)->target), get_motif_st_id((*p2)->target));
      } else if ((*p1)->db->id < (*p2)->db->id) {
        return -1;
      } else {
        return 1;
      }
    } else if ((*p1)->overlap > (*p2)->overlap) {
      return -1;
    } else {
      return 1;
    }
  } else if ((*p1)->pvalue < (*p2)->pvalue) {
    return -1;
  } else {
    return 1;
  }
}
static int tomtom_match_compare ( const TOMTOM_MATCH_T * * p1 , const TOMTOM_MATCH_T * * p2 ) { if ( ( * p1 ) -> pvalue == ( * p2 ) -> pvalue ) { if ( ( * p1 ) -> overlap == ( * p2 ) -> overlap ) { if ( ( * p1 ) -> db -> id == ( * p2 ) -> db -> id ) { return strcmp ( get_motif_st_id ( ( * p1 ) -> target ) , get_motif_st_id ( ( * p2 ) -> target ) ) ; } else if ( ( * p1 ) -> db -> id < ( * p2 ) -> db -> id ) { return -1 ; } else { return 1 ; } } else if ( ( * p1 ) -> overlap > ( * p2 ) -> overlap ) { return -1 ; } else { return 1 ; } } else if ( ( * p1 ) -> pvalue < ( * p2 ) -> pvalue ) { return -1 ; } else { return 1 ; } }
Compare 2 matches and put the best ones first.
Compare 2 matches and put the best ones first .
// 1st sort on pvalue (ascending) // 2nd sort on overlap (descending) // 3rd sort on target db (ascending) // Finally sort on target motif id with strand which should be unique (ascending)