third_party/inchi/INCHI_BASE/src/runichi3.c
void OAD_Polymer_FindBackbones( ORIG_ATOM_DATA *at_data,
                                COMP_ATOM_DATA *composite_norm_data,
                                int            *err,
                                char           *pStrErr )
{
    int i;

    *err = 0;
    for (i = 0; i < at_data->polymer->n; i++)
    {
        if (!at_data->polymer->units[i]->cyclizable)
        {
            continue;
        }

        OAD_CollectBackboneBonds( at_data, 
                                  at_data->polymer->units[i]->na,
                                  at_data->polymer->units[i]->alist,
                                  at_data->polymer->units[i]->end_atom1,
                                  at_data->polymer->units[i]->end_atom2,
                                  &(at_data->polymer->units[i]->nbkbonds),
                                  at_data->polymer->units[i]->bkbonds,
                                  err, pStrErr );
        if (*err)
        {
            at_data->polymer->units[i]->cyclizable = CLOSING_SRU_NOT_APPLICABLE;
            continue;
        }
        if (at_data->polymer->units[i]->nbkbonds < 1)
        {
            continue;
        }
        if (at_data->polymer->units[i]->nbkbonds == 1)
        {
            /*  Special case: we got only one bond between end_atom1 and   */
            /*  end_atom2 (this may be the result of metal disconnection)  */
            continue;
        }

        OAD_PolymerUnit_DelistIntraRingBackboneBonds( at_data->polymer->units[i], at_data, err, pStrErr );
        if (*err)
        {
            continue;
        }

        OAD_PolymerUnit_DelistHighOrderBackboneBonds( at_data->polymer->units[i],
                                                      at_data, composite_norm_data,
                                                      err, pStrErr );
        if (*err)
        {
            continue;
        }
        if (at_data->polymer->units[i]->nbkbonds == 0)
        {
            /* We already cyclized frame-shiftable unit and preprocessed it (in 'prep_inp_data').                       */
            /* Despite that, now we discovered that there are no bonds eligible for frame shift                         */
            /* (as all potentially eligible in-unit bonds are either in-ring or alternate ones).                        */
            /* We can not simply restore original connections as the structure may have been already heavily touched.   */
            /* The most viable action is to hold a single frame-shift bond (between original caps of CRU ends).   */
            /* It is for sure will be converted to original bonds to star atoms on possible inchi2struct.               */
            at_data->polymer->units[i]->cyclizable = 1;
            at_data->polymer->units[i]->nbkbonds = 1;
            at_data->polymer->units[i]->bkbonds[0][0] = at_data->polymer->units[i]->end_atom1;
            at_data->polymer->units[i]->bkbonds[0][1] = at_data->polymer->units[i]->end_atom2;
        }
    }

    return;
}
/****************************************************************************
 For all CRUs detect the bonds potentially involved in frame shift
****************************************************************************/
For all CRUs detect the bonds potentially involved in frame shift
For all CRUs detect the bonds potentially involved in frame shift
void OAD_Polymer_FindBackbones( ORIG_ATOM_DATA *at_data,
                                COMP_ATOM_DATA *composite_norm_data,
                                int            *err,
                                char           *pStrErr )
{
    int i;
    *err = 0;
    for (i = 0; i < at_data->polymer->n; i++)
    {
        if (!at_data->polymer->units[i]->cyclizable)
        {
            continue;
        }
        OAD_CollectBackboneBonds( at_data, 
                                  at_data->polymer->units[i]->na,
                                  at_data->polymer->units[i]->alist,
                                  at_data->polymer->units[i]->end_atom1,
                                  at_data->polymer->units[i]->end_atom2,
                                  &(at_data->polymer->units[i]->nbkbonds),
                                  at_data->polymer->units[i]->bkbonds,
                                  err, pStrErr );
        if (*err)
        {
            at_data->polymer->units[i]->cyclizable = CLOSING_SRU_NOT_APPLICABLE;
            continue;
        }
        if (at_data->polymer->units[i]->nbkbonds < 1)
        {
            continue;
        }
        if (at_data->polymer->units[i]->nbkbonds == 1)
        {
            continue;
        }
        OAD_PolymerUnit_DelistIntraRingBackboneBonds( at_data->polymer->units[i], at_data, err, pStrErr );
        if (*err)
        {
            continue;
        }
        OAD_PolymerUnit_DelistHighOrderBackboneBonds( at_data->polymer->units[i],
                                                      at_data, composite_norm_data,
                                                      err, pStrErr );
        if (*err)
        {
            continue;
        }
        if (at_data->polymer->units[i]->nbkbonds == 0)
        {
            at_data->polymer->units[i]->cyclizable = 1;
            at_data->polymer->units[i]->nbkbonds = 1;
            at_data->polymer->units[i]->bkbonds[0][0] = at_data->polymer->units[i]->end_atom1;
            at_data->polymer->units[i]->bkbonds[0][1] = at_data->polymer->units[i]->end_atom2;
        }
    }
    return;
}
void OAD_Polymer_FindBackbones ( ORIG_ATOM_DATA * at_data , COMP_ATOM_DATA * composite_norm_data , int * err , char * pStrErr ) { int i ; * err = 0 ; for ( i = 0 ; i < at_data -> polymer -> n ; i ++ ) { if ( ! at_data -> polymer -> units [ i ] -> cyclizable ) { continue ; } OAD_CollectBackboneBonds ( at_data , at_data -> polymer -> units [ i ] -> na , at_data -> polymer -> units [ i ] -> alist , at_data -> polymer -> units [ i ] -> end_atom1 , at_data -> polymer -> units [ i ] -> end_atom2 , & ( at_data -> polymer -> units [ i ] -> nbkbonds ) , at_data -> polymer -> units [ i ] -> bkbonds , err , pStrErr ) ; if ( * err ) { at_data -> polymer -> units [ i ] -> cyclizable = CLOSING_SRU_NOT_APPLICABLE ; continue ; } if ( at_data -> polymer -> units [ i ] -> nbkbonds < 1 ) { continue ; } if ( at_data -> polymer -> units [ i ] -> nbkbonds == 1 ) { continue ; } OAD_PolymerUnit_DelistIntraRingBackboneBonds ( at_data -> polymer -> units [ i ] , at_data , err , pStrErr ) ; if ( * err ) { continue ; } OAD_PolymerUnit_DelistHighOrderBackboneBonds ( at_data -> polymer -> units [ i ] , at_data , composite_norm_data , err , pStrErr ) ; if ( * err ) { continue ; } if ( at_data -> polymer -> units [ i ] -> nbkbonds == 0 ) { at_data -> polymer -> units [ i ] -> cyclizable = 1 ; at_data -> polymer -> units [ i ] -> nbkbonds = 1 ; at_data -> polymer -> units [ i ] -> bkbonds [ 0 ] [ 0 ] = at_data -> polymer -> units [ i ] -> end_atom1 ; at_data -> polymer -> units [ i ] -> bkbonds [ 0 ] [ 1 ] = at_data -> polymer -> units [ i ] -> end_atom2 ; } } return ; }
For all CRUs detect the bonds potentially involved in frame shift
For all CRUs detect the bonds potentially involved in frame shift
/*  Special case: we got only one bond between end_atom1 and   */ /*  end_atom2 (this may be the result of metal disconnection)  */ /* We already cyclized frame-shiftable unit and preprocessed it (in 'prep_inp_data').                       */ /* Despite that, now we discovered that there are no bonds eligible for frame shift                         */ /* (as all potentially eligible in-unit bonds are either in-ring or alternate ones).                        */ /* We can not simply restore original connections as the structure may have been already heavily touched.   */ /* The most viable action is to hold a single frame-shift bond (between original caps of CRU ends).   */ /* It is for sure will be converted to original bonds to star atoms on possible inchi2struct.               */