third_party/inchi/INCHI_BASE/src/runichi3.c
void OAD_PolymerUnit_DelistHighOrderBackboneBonds( OAD_PolymerUnit *unit,
                                                   ORIG_ATOM_DATA  *orig_at_data,
                                                   COMP_ATOM_DATA  *composite_norm_data,
                                                   int             *err,
                                                   char            *pStrErr )
{
    int at1, at2, border, j = 0, k, check_taut = 0, remove;

    int *orig_num = NULL, *curr_num = NULL;

    if (unit->na < 2)
    {
        return;
    }
    if (unit->nb < 2)
    {
        return;
    }
    if (unit->nbkbonds < 1)
    {
        return;
    }

    /* Care on tautomeric bonds */
    if (composite_norm_data)
    {
        check_taut = 1;
        orig_num = (int *) inchi_calloc( orig_at_data->num_inp_atoms + 2, sizeof( int ) );
        curr_num = (int *) inchi_calloc( orig_at_data->num_inp_atoms + 2, sizeof( int ) );
        if (orig_num && curr_num)
        {
            check_taut = 1;
            CompAtomData_GetNumMapping( composite_norm_data, orig_num, curr_num );
        }
    }
repeatj:
    remove = 0;
    at1 = unit->bkbonds[j][0];
    at2 = unit->bkbonds[j][1];
    border = 0;
    for (k = 0; k < orig_at_data->at[at1 - 1].valence; k++)
    {
        if (orig_at_data->at[at1 - 1].neighbor[k] != at2 - 1)
            continue;
        border = orig_at_data->at[at1 - 1].bond_type[k];
    }
    /*if ( border > 1 ) */
    {
        int bond_is_untouchable = 0, btype;
        if (check_taut && composite_norm_data && composite_norm_data->at)
        {
            for (k = 0; k < composite_norm_data->at[curr_num[at1]].valence; k++)
            {
                if (composite_norm_data->at[curr_num[at1]].neighbor[k] != curr_num[at2])
                {
                    continue;
                }
                btype = composite_norm_data->at[curr_num[at1]].bond_type[k];
                bond_is_untouchable = ( btype == BOND_TAUTOM ); /*|| btype == BOND_ALTERN );*/
                break;
            }
        }
        if (bond_is_untouchable)
        {
            remove = 1;
        }
    }

    if (remove)
    {
        OAD_PolymerUnit_RemoveLinkFromCRUChain( at1, at2, &unit->nbkbonds, unit->bkbonds );
    }
    else
    {
        ++j;
    }

    if (j < unit->nbkbonds)
    {
        goto repeatj;
    }

    if (orig_num)
    {
        inchi_free( orig_num );
    }
    if (curr_num)
    {
        inchi_free( curr_num );
    }

    return;
}
/****************************************************************************
  Exclude higher order bonds from list of bkbonds
****************************************************************************/
Exclude higher order bonds from list of bkbonds
Exclude higher order bonds from list of bkbonds
void OAD_PolymerUnit_DelistHighOrderBackboneBonds( OAD_PolymerUnit *unit,
                                                   ORIG_ATOM_DATA  *orig_at_data,
                                                   COMP_ATOM_DATA  *composite_norm_data,
                                                   int             *err,
                                                   char            *pStrErr )
{
    int at1, at2, border, j = 0, k, check_taut = 0, remove;
    int *orig_num = NULL, *curr_num = NULL;
    if (unit->na < 2)
    {
        return;
    }
    if (unit->nb < 2)
    {
        return;
    }
    if (unit->nbkbonds < 1)
    {
        return;
    }
    if (composite_norm_data)
    {
        check_taut = 1;
        orig_num = (int *) inchi_calloc( orig_at_data->num_inp_atoms + 2, sizeof( int ) );
        curr_num = (int *) inchi_calloc( orig_at_data->num_inp_atoms + 2, sizeof( int ) );
        if (orig_num && curr_num)
        {
            check_taut = 1;
            CompAtomData_GetNumMapping( composite_norm_data, orig_num, curr_num );
        }
    }
repeatj:
    remove = 0;
    at1 = unit->bkbonds[j][0];
    at2 = unit->bkbonds[j][1];
    border = 0;
    for (k = 0; k < orig_at_data->at[at1 - 1].valence; k++)
    {
        if (orig_at_data->at[at1 - 1].neighbor[k] != at2 - 1)
            continue;
        border = orig_at_data->at[at1 - 1].bond_type[k];
    }
    {
        int bond_is_untouchable = 0, btype;
        if (check_taut && composite_norm_data && composite_norm_data->at)
        {
            for (k = 0; k < composite_norm_data->at[curr_num[at1]].valence; k++)
            {
                if (composite_norm_data->at[curr_num[at1]].neighbor[k] != curr_num[at2])
                {
                    continue;
                }
                btype = composite_norm_data->at[curr_num[at1]].bond_type[k];
                bond_is_untouchable = ( btype == BOND_TAUTOM ); 
                break;
            }
        }
        if (bond_is_untouchable)
        {
            remove = 1;
        }
    }
    if (remove)
    {
        OAD_PolymerUnit_RemoveLinkFromCRUChain( at1, at2, &unit->nbkbonds, unit->bkbonds );
    }
    else
    {
        ++j;
    }
    if (j < unit->nbkbonds)
    {
        goto repeatj;
    }
    if (orig_num)
    {
        inchi_free( orig_num );
    }
    if (curr_num)
    {
        inchi_free( curr_num );
    }
    return;
}
void OAD_PolymerUnit_DelistHighOrderBackboneBonds ( OAD_PolymerUnit * unit , ORIG_ATOM_DATA * orig_at_data , COMP_ATOM_DATA * composite_norm_data , int * err , char * pStrErr ) { int at1 , at2 , border , j = 0 , k , check_taut = 0 , remove ; int * orig_num = NULL , * curr_num = NULL ; if ( unit -> na < 2 ) { return ; } if ( unit -> nb < 2 ) { return ; } if ( unit -> nbkbonds < 1 ) { return ; } if ( composite_norm_data ) { check_taut = 1 ; orig_num = ( int * ) inchi_calloc ( orig_at_data -> num_inp_atoms + 2 , sizeof ( int ) ) ; curr_num = ( int * ) inchi_calloc ( orig_at_data -> num_inp_atoms + 2 , sizeof ( int ) ) ; if ( orig_num && curr_num ) { check_taut = 1 ; CompAtomData_GetNumMapping ( composite_norm_data , orig_num , curr_num ) ; } } repeatj : remove = 0 ; at1 = unit -> bkbonds [ j ] [ 0 ] ; at2 = unit -> bkbonds [ j ] [ 1 ] ; border = 0 ; for ( k = 0 ; k < orig_at_data -> at [ at1 - 1 ] . valence ; k ++ ) { if ( orig_at_data -> at [ at1 - 1 ] . neighbor [ k ] != at2 - 1 ) continue ; border = orig_at_data -> at [ at1 - 1 ] . bond_type [ k ] ; } { int bond_is_untouchable = 0 , btype ; if ( check_taut && composite_norm_data && composite_norm_data -> at ) { for ( k = 0 ; k < composite_norm_data -> at [ curr_num [ at1 ] ] . valence ; k ++ ) { if ( composite_norm_data -> at [ curr_num [ at1 ] ] . neighbor [ k ] != curr_num [ at2 ] ) { continue ; } btype = composite_norm_data -> at [ curr_num [ at1 ] ] . bond_type [ k ] ; bond_is_untouchable = ( btype == BOND_TAUTOM ) ; break ; } } if ( bond_is_untouchable ) { remove = 1 ; } } if ( remove ) { OAD_PolymerUnit_RemoveLinkFromCRUChain ( at1 , at2 , & unit -> nbkbonds , unit -> bkbonds ) ; } else { ++ j ; } if ( j < unit -> nbkbonds ) { goto repeatj ; } if ( orig_num ) { inchi_free ( orig_num ) ; } if ( curr_num ) { inchi_free ( curr_num ) ; } return ; }
Exclude higher order bonds from list of bkbonds
Exclude higher order bonds from list of bkbonds
/* Care on tautomeric bonds */ /*if ( border > 1 ) */ /*|| btype == BOND_ALTERN );*/