third_party/inchi/INCHI_BASE/src/runichi3.c
int  OAD_Polymer_CompareBackboneBondsSeniority( int* b1, int* b2, OAD_AtProps *aprops )
{
    int b1min, b1max, b2min, b2max, tmp, cmp = 0;

    /* Find min and max ext-ranked ends of the both bonds */
    b1max = b1[0]; b1min = b1[1];
    b2max = b2[0]; b2min = b2[1];
    if (OAD_Polymer_IsFirstAtomRankLower( b1min, b1max, aprops ) == -1)
    {
        tmp = b1max;
        b1max = b1min;
        b1min = tmp;
    }
    if (OAD_Polymer_IsFirstAtomRankLower( b2min, b2max, aprops ) == -1)
    {
        tmp = b2max;
        b2max = b2min;
        b2min = tmp;
    }

    /* Compare bonds' seniority */

    /* First, favor the bond which has greater ext-rank end
       NB: the result may be 0, that is, equal max ext. ranks */

    cmp = OAD_Polymer_CompareRanksOfTwoAtoms( b1max, b2max, aprops );
    if (cmp == 1)
    {
        return   1;        /* rank(b1max) < rank(b2max), so bond2 is senior */
    }
    else if (cmp == -1)
    {
        return  -1;        /* rank(b1max) > rank(b2max), so bond1 is senior */
    }

    /* Max ends are of the same rank, so favor the bond with lesser min-rank end
       NB: the result may NOT be 0, that is, the case is always resolved    */

    cmp = OAD_Polymer_CompareRanksOfTwoAtoms( b1min, b2min, aprops ); /*OAD_Polymer_IsFirstAtomRankLower( b1min, b2min, aprops );*/

    if (cmp == 1)
    {
        return  -1;         /* rank(b1min) < rank(b2min), so bond1 is senior */
    }
    else if (cmp == -1)
    {
        return   1;         /* rank(b1min) > rank(b2min), so bond2 is senior */
    }

    /* Min ends are of the same rank. Here is the time to compare directly
       which canonical number is larger of max-ends ... */

    if (b1max < b2max)
    {
        return  1;
    }
    if (b1max > b2max)
    {
        return -1;
    }

    /* ... they are the same, so compare which canonical number is larger for min-ends ... */

    if (b1min < b2min)
    {
        return -1;          /* b1min < b2min, so bond1 is senior */
    }
    if (b1min > b2min)
    {
        return  1;          /* b1min > b2min, so bond2 is senior */
    }

    return 0;    /* we should not reach there */
}
/****************************************************************************
 For sorting SRU cyclizing bonds (PS=='frame-shift') in descending order
 In general:  favor greater max-rank end
              if max ends are the same, favor lesser min-rank end
****************************************************************************/
For sorting SRU cyclizing bonds (PS=='frame-shift') in descending order
In general:  favor greater max-rank end
if max ends are the same, favor lesser min-rank end
For sorting SRU cyclizing bonds ( PS == ' frame - shift ' ) in descending order In general : favor greater max - rank end if max ends are the same favor lesser min - rank end
int  OAD_Polymer_CompareBackboneBondsSeniority( int* b1, int* b2, OAD_AtProps *aprops )
{
    int b1min, b1max, b2min, b2max, tmp, cmp = 0;
    b1max = b1[0]; b1min = b1[1];
    b2max = b2[0]; b2min = b2[1];
    if (OAD_Polymer_IsFirstAtomRankLower( b1min, b1max, aprops ) == -1)
    {
        tmp = b1max;
        b1max = b1min;
        b1min = tmp;
    }
    if (OAD_Polymer_IsFirstAtomRankLower( b2min, b2max, aprops ) == -1)
    {
        tmp = b2max;
        b2max = b2min;
        b2min = tmp;
    }
    cmp = OAD_Polymer_CompareRanksOfTwoAtoms( b1max, b2max, aprops );
    if (cmp == 1)
    {
        return   1;        
    }
    else if (cmp == -1)
    {
        return  -1;        
    }
    cmp = OAD_Polymer_CompareRanksOfTwoAtoms( b1min, b2min, aprops ); 
    if (cmp == 1)
    {
        return  -1;         
    }
    else if (cmp == -1)
    {
        return   1;         
    }
    if (b1max < b2max)
    {
        return  1;
    }
    if (b1max > b2max)
    {
        return -1;
    }
    if (b1min < b2min)
    {
        return -1;          
    }
    if (b1min > b2min)
    {
        return  1;          
    }
    return 0;    
}
int OAD_Polymer_CompareBackboneBondsSeniority ( int * b1 , int * b2 , OAD_AtProps * aprops ) { int b1min , b1max , b2min , b2max , tmp , cmp = 0 ; b1max = b1 [ 0 ] ; b1min = b1 [ 1 ] ; b2max = b2 [ 0 ] ; b2min = b2 [ 1 ] ; if ( OAD_Polymer_IsFirstAtomRankLower ( b1min , b1max , aprops ) == -1 ) { tmp = b1max ; b1max = b1min ; b1min = tmp ; } if ( OAD_Polymer_IsFirstAtomRankLower ( b2min , b2max , aprops ) == -1 ) { tmp = b2max ; b2max = b2min ; b2min = tmp ; } cmp = OAD_Polymer_CompareRanksOfTwoAtoms ( b1max , b2max , aprops ) ; if ( cmp == 1 ) { return 1 ; } else if ( cmp == -1 ) { return -1 ; } cmp = OAD_Polymer_CompareRanksOfTwoAtoms ( b1min , b2min , aprops ) ; if ( cmp == 1 ) { return -1 ; } else if ( cmp == -1 ) { return 1 ; } if ( b1max < b2max ) { return 1 ; } if ( b1max > b2max ) { return -1 ; } if ( b1min < b2min ) { return -1 ; } if ( b1min > b2min ) { return 1 ; } return 0 ; }
For sorting SRU cyclizing bonds (PS=='frame-shift') in descending order
In general:  favor greater max-rank end
if max ends are the same, favor lesser min-rank end
For sorting SRU cyclizing bonds ( PS == ' frame - shift ' ) in descending order In general : favor greater max - rank end if max ends are the same favor lesser min - rank end
/* Find min and max ext-ranked ends of the both bonds */ /* Compare bonds' seniority */ /* First, favor the bond which has greater ext-rank end
       NB: the result may be 0, that is, equal max ext. ranks */ /* rank(b1max) < rank(b2max), so bond2 is senior */ /* rank(b1max) > rank(b2max), so bond1 is senior */ /* Max ends are of the same rank, so favor the bond with lesser min-rank end
       NB: the result may NOT be 0, that is, the case is always resolved    */ /*OAD_Polymer_IsFirstAtomRankLower( b1min, b2min, aprops );*/ /* rank(b1min) < rank(b2min), so bond1 is senior */ /* rank(b1min) > rank(b2min), so bond2 is senior */ /* Min ends are of the same rank. Here is the time to compare directly
       which canonical number is larger of max-ends ... */ /* ... they are the same, so compare which canonical number is larger for min-ends ... */ /* b1min < b2min, so bond1 is senior */ /* b1min > b2min, so bond2 is senior */ /* we should not reach there */