third_party/inchi/INCHI_BASE/src/ichicano.c
int GetCanonLengths( int num_at,
                     sp_ATOM* at,
                     ATOM_SIZES *s,
                     T_GROUP_INFO *t_group_info )
{
    /* include taut. groups as additional "atoms" to the connection table 07-22-2002 */

    int  i, nNumCT, nNumBonds, nNumTBonds = 0, nNumDblBondsStereo = 0, nNumAsymCarbStereo = 0, nNumIsotopic = 0;
    T_GROUP *t_group = ( s->nLenLinearCTTautomer && t_group_info ) ? t_group_info->t_group : NULL;

    for (nNumBonds = 0, i = 0; i < num_at; i++)
    {
        nNumBonds += at[i].valence;
        if (at[i].iso_sort_key)
        {
            nNumIsotopic++;  /* not including tautomeric endpoints that are isotopic only due to mobile atoms */
        }

        if (at[i].parity > 0)
        {
            /* ignore hydrogen isotope parities in at[i].parity2 */
            int j = 0, nStereoBondsToAtom = 0;  /* number of stereo double bonds at this atom */
            int k;
            for (; j < MAX_NUM_STEREO_BONDS && ( k = at[i].stereo_bond_neighbor[j] ); j++)
            {
                nStereoBondsToAtom += ( at[k - 1].parity > 0 );
            }
            nNumDblBondsStereo += nStereoBondsToAtom;
            nNumAsymCarbStereo += !j;
        }
    }

    nNumDblBondsStereo /= 2;
    nNumBonds /= 2;

    s->nLenBonds = inchi_max( s->nLenBonds, nNumBonds );
    nNumCT = nNumBonds; /* total number of neighbors in the CT */

#if ( CT_ATOMID != CT_ATOMID_DONTINCLUDE )
    nNumCT += num_at;
#endif

    s->nLenCTAtOnly = inchi_max( s->nLenCTAtOnly, nNumCT );

    if (t_group)
    {
        for (i = 0; i < t_group_info->num_t_groups; i++)
        {
            nNumTBonds += t_group[i].nNumEndpoints;
        }
        nNumCT += nNumTBonds;

#if ( CT_ATOMID != CT_ATOMID_DONTINCLUDE )
        nNumCT += t_group_info->num_t_groups;
#endif
    }

    nNumCT = inchi_max( 1, nNumCT ); /* keep GetBaseCanonRanking() happy */
    s->nLenCT = inchi_max( s->nLenCT, nNumCT );
    s->nLenIsotopic = inchi_max( s->nLenIsotopic, nNumIsotopic );
    s->nLenLinearCTStereoDble = inchi_max( s->nLenLinearCTStereoDble, nNumDblBondsStereo );
    s->nLenLinearCTStereoCarb = inchi_max( s->nLenLinearCTStereoCarb, nNumAsymCarbStereo );

    if (t_group_info)
    {
        s->nLenIsotopicEndpoints = inchi_max( s->nLenIsotopicEndpoints, t_group_info->nNumIsotopicEndpoints );
    }

    return 0;
}
/****************************************************************************
 length of canonic representation in sizeof(AT_NUMB) units
****************************************************************************/
length of canonic representation in sizeof(AT_NUMB) units
length of canonic representation in sizeof ( AT_NUMB ) units
int GetCanonLengths( int num_at,
                     sp_ATOM* at,
                     ATOM_SIZES *s,
                     T_GROUP_INFO *t_group_info )
{
    int  i, nNumCT, nNumBonds, nNumTBonds = 0, nNumDblBondsStereo = 0, nNumAsymCarbStereo = 0, nNumIsotopic = 0;
    T_GROUP *t_group = ( s->nLenLinearCTTautomer && t_group_info ) ? t_group_info->t_group : NULL;
    for (nNumBonds = 0, i = 0; i < num_at; i++)
    {
        nNumBonds += at[i].valence;
        if (at[i].iso_sort_key)
        {
            nNumIsotopic++;  
        }
        if (at[i].parity > 0)
        {
            int j = 0, nStereoBondsToAtom = 0;  
            int k;
            for (; j < MAX_NUM_STEREO_BONDS && ( k = at[i].stereo_bond_neighbor[j] ); j++)
            {
                nStereoBondsToAtom += ( at[k - 1].parity > 0 );
            }
            nNumDblBondsStereo += nStereoBondsToAtom;
            nNumAsymCarbStereo += !j;
        }
    }
    nNumDblBondsStereo /= 2;
    nNumBonds /= 2;
    s->nLenBonds = inchi_max( s->nLenBonds, nNumBonds );
    nNumCT = nNumBonds; 
#if ( CT_ATOMID != CT_ATOMID_DONTINCLUDE )
    nNumCT += num_at;
#endif
    s->nLenCTAtOnly = inchi_max( s->nLenCTAtOnly, nNumCT );
    if (t_group)
    {
        for (i = 0; i < t_group_info->num_t_groups; i++)
        {
            nNumTBonds += t_group[i].nNumEndpoints;
        }
        nNumCT += nNumTBonds;
#if ( CT_ATOMID != CT_ATOMID_DONTINCLUDE )
        nNumCT += t_group_info->num_t_groups;
#endif
    }
    nNumCT = inchi_max( 1, nNumCT ); 
    s->nLenCT = inchi_max( s->nLenCT, nNumCT );
    s->nLenIsotopic = inchi_max( s->nLenIsotopic, nNumIsotopic );
    s->nLenLinearCTStereoDble = inchi_max( s->nLenLinearCTStereoDble, nNumDblBondsStereo );
    s->nLenLinearCTStereoCarb = inchi_max( s->nLenLinearCTStereoCarb, nNumAsymCarbStereo );
    if (t_group_info)
    {
        s->nLenIsotopicEndpoints = inchi_max( s->nLenIsotopicEndpoints, t_group_info->nNumIsotopicEndpoints );
    }
    return 0;
}
int GetCanonLengths ( int num_at , sp_ATOM * at , ATOM_SIZES * s , T_GROUP_INFO * t_group_info ) { int i , nNumCT , nNumBonds , nNumTBonds = 0 , nNumDblBondsStereo = 0 , nNumAsymCarbStereo = 0 , nNumIsotopic = 0 ; T_GROUP * t_group = ( s -> nLenLinearCTTautomer && t_group_info ) ? t_group_info -> t_group : NULL ; for ( nNumBonds = 0 , i = 0 ; i < num_at ; i ++ ) { nNumBonds += at [ i ] . valence ; if ( at [ i ] . iso_sort_key ) { nNumIsotopic ++ ; } if ( at [ i ] . parity > 0 ) { int j = 0 , nStereoBondsToAtom = 0 ; int k ; for ( ; j < MAX_NUM_STEREO_BONDS && ( k = at [ i ] . stereo_bond_neighbor [ j ] ) ; j ++ ) { nStereoBondsToAtom += ( at [ k - 1 ] . parity > 0 ) ; } nNumDblBondsStereo += nStereoBondsToAtom ; nNumAsymCarbStereo += ! j ; } } nNumDblBondsStereo /= 2 ; nNumBonds /= 2 ; s -> nLenBonds = inchi_max ( s -> nLenBonds , nNumBonds ) ; nNumCT = nNumBonds ; #if ( CT_ATOMID != CT_ATOMID_DONTINCLUDE ) nNumCT += num_at ; #endif s -> nLenCTAtOnly = inchi_max ( s -> nLenCTAtOnly , nNumCT ) ; if ( t_group ) { for ( i = 0 ; i < t_group_info -> num_t_groups ; i ++ ) { nNumTBonds += t_group [ i ] . nNumEndpoints ; } nNumCT += nNumTBonds ; #if ( CT_ATOMID != CT_ATOMID_DONTINCLUDE ) nNumCT += t_group_info -> num_t_groups ; #endif } nNumCT = inchi_max ( 1 , nNumCT ) ; s -> nLenCT = inchi_max ( s -> nLenCT , nNumCT ) ; s -> nLenIsotopic = inchi_max ( s -> nLenIsotopic , nNumIsotopic ) ; s -> nLenLinearCTStereoDble = inchi_max ( s -> nLenLinearCTStereoDble , nNumDblBondsStereo ) ; s -> nLenLinearCTStereoCarb = inchi_max ( s -> nLenLinearCTStereoCarb , nNumAsymCarbStereo ) ; if ( t_group_info ) { s -> nLenIsotopicEndpoints = inchi_max ( s -> nLenIsotopicEndpoints , t_group_info -> nNumIsotopicEndpoints ) ; } return 0 ; }
length of canonic representation in sizeof(AT_NUMB) units
length of canonic representation in sizeof ( AT_NUMB ) units
/* include taut. groups as additional "atoms" to the connection table 07-22-2002 */ /* not including tautomeric endpoints that are isotopic only due to mobile atoms */ /* ignore hydrogen isotope parities in at[i].parity2 */ /* number of stereo double bonds at this atom */ /* total number of neighbors in the CT */ /* keep GetBaseCanonRanking() happy */