third_party/inchi/INCHI_BASE/src/runichi3.c
void OAD_PolymerUnit_SetEndsAndCaps( OAD_PolymerUnit *unit,
                                     ORIG_ATOM_DATA  *orig_at_data,
                                     int             *err,
                                     char            *pStrErr )
{
    int k;

    unit->cyclizable = CLOSING_SRU_NOT_APPLICABLE;
    unit->end_atom1 = unit->end_atom2 = unit->cap1 = unit->cap2 = -1;
    unit->cap1_is_undef = unit->cap2_is_undef = 0;

    OAD_PolymerUnit_FindEndsAndCaps( unit, orig_at_data,
                                     &unit->end_atom1, &unit->cap1, &unit->cap1_is_undef,
                                     &unit->end_atom2, &unit->cap2, &unit->cap2_is_undef,
                                     err, pStrErr);

    if (*err)
    {
        goto exit_function;
    }

#if ( defined(DEBUG_POLYMERS) && ( DEBUG_POLYMERS != 0 ) )
    ITRACE_( "Cap-end_atom pairs (numbers are from 1) are: %-d-%-d and %-d-%-d\n",
        unit->cap1, unit->end_atom1, unit->cap2, unit->end_atom2 );
#endif

    if (!unit->cap1_is_undef && !unit->cap2_is_undef)
    {
        goto exit_function;
    }

    /* The rest is applicable only to *---SRU---* case */

    /* Stars are separated by one atom - that's not error but do nothing */
    if (unit->end_atom1 == unit->end_atom2)
    {
#ifdef ALLOW_CLOSING_SRU_VIA_DIRADICAL
        unit->cyclizable = CLOSING_SRU_DIRADICAL;
#else
        unit->cyclizable = CLOSING_SRU_NOT_APPLICABLE;
#endif
        goto exit_function;
    }

    /* Stars are separated by two atoms - that's not error but do nothing */
    for (k = 0; k < orig_at_data->at[unit->end_atom1 - 1].valence; k++)
    {
        if (orig_at_data->at[unit->end_atom1 - 1].neighbor[k] == unit->end_atom2 - 1)
        {
#ifdef ALLOW_CLOSING_SRU_VIA_HIGHER_ORDER_BOND
            unit->cyclizable = CLOSING_SRU_HIGHER_ORDER_BOND;
#else
            unit->cyclizable = CLOSING_SRU_NOT_APPLICABLE;
#endif
            goto exit_function;
        }
    }

    unit->cyclizable = CLOSING_SRU_RING;

exit_function:

    return;
}
/****************************************************************************
 Reveal and store CRU caps and ends ('stars and partners')
****************************************************************************/
Reveal and store CRU caps and ends ('stars and partners')
Reveal and store CRU caps and ends ( ' stars and partners ' )
void OAD_PolymerUnit_SetEndsAndCaps( OAD_PolymerUnit *unit,
                                     ORIG_ATOM_DATA  *orig_at_data,
                                     int             *err,
                                     char            *pStrErr )
{
    int k;
    unit->cyclizable = CLOSING_SRU_NOT_APPLICABLE;
    unit->end_atom1 = unit->end_atom2 = unit->cap1 = unit->cap2 = -1;
    unit->cap1_is_undef = unit->cap2_is_undef = 0;
    OAD_PolymerUnit_FindEndsAndCaps( unit, orig_at_data,
                                     &unit->end_atom1, &unit->cap1, &unit->cap1_is_undef,
                                     &unit->end_atom2, &unit->cap2, &unit->cap2_is_undef,
                                     err, pStrErr);
    if (*err)
    {
        goto exit_function;
    }
#if ( defined(DEBUG_POLYMERS) && ( DEBUG_POLYMERS != 0 ) )
    ITRACE_( "Cap-end_atom pairs (numbers are from 1) are: %-d-%-d and %-d-%-d\n",
        unit->cap1, unit->end_atom1, unit->cap2, unit->end_atom2 );
#endif
    if (!unit->cap1_is_undef && !unit->cap2_is_undef)
    {
        goto exit_function;
    }
    if (unit->end_atom1 == unit->end_atom2)
    {
#ifdef ALLOW_CLOSING_SRU_VIA_DIRADICAL
        unit->cyclizable = CLOSING_SRU_DIRADICAL;
#else
        unit->cyclizable = CLOSING_SRU_NOT_APPLICABLE;
#endif
        goto exit_function;
    }
    for (k = 0; k < orig_at_data->at[unit->end_atom1 - 1].valence; k++)
    {
        if (orig_at_data->at[unit->end_atom1 - 1].neighbor[k] == unit->end_atom2 - 1)
        {
#ifdef ALLOW_CLOSING_SRU_VIA_HIGHER_ORDER_BOND
            unit->cyclizable = CLOSING_SRU_HIGHER_ORDER_BOND;
#else
            unit->cyclizable = CLOSING_SRU_NOT_APPLICABLE;
#endif
            goto exit_function;
        }
    }
    unit->cyclizable = CLOSING_SRU_RING;
exit_function:
    return;
}
void OAD_PolymerUnit_SetEndsAndCaps ( OAD_PolymerUnit * unit , ORIG_ATOM_DATA * orig_at_data , int * err , char * pStrErr ) { int k ; unit -> cyclizable = CLOSING_SRU_NOT_APPLICABLE ; unit -> end_atom1 = unit -> end_atom2 = unit -> cap1 = unit -> cap2 = -1 ; unit -> cap1_is_undef = unit -> cap2_is_undef = 0 ; OAD_PolymerUnit_FindEndsAndCaps ( unit , orig_at_data , & unit -> end_atom1 , & unit -> cap1 , & unit -> cap1_is_undef , & unit -> end_atom2 , & unit -> cap2 , & unit -> cap2_is_undef , err , pStrErr ) ; if ( * err ) { goto exit_function ; } #if ( defined ( DEBUG_POLYMERS ) && ( DEBUG_POLYMERS != 0 ) ) ITRACE_ ( " \n " , unit -> cap1 , unit -> end_atom1 , unit -> cap2 , unit -> end_atom2 ) ; #endif if ( ! unit -> cap1_is_undef && ! unit -> cap2_is_undef ) { goto exit_function ; } if ( unit -> end_atom1 == unit -> end_atom2 ) { #ifdef ALLOW_CLOSING_SRU_VIA_DIRADICAL unit -> cyclizable = CLOSING_SRU_DIRADICAL ; #else unit -> cyclizable = CLOSING_SRU_NOT_APPLICABLE ; #endif goto exit_function ; } for ( k = 0 ; k < orig_at_data -> at [ unit -> end_atom1 - 1 ] . valence ; k ++ ) { if ( orig_at_data -> at [ unit -> end_atom1 - 1 ] . neighbor [ k ] == unit -> end_atom2 - 1 ) { #ifdef ALLOW_CLOSING_SRU_VIA_HIGHER_ORDER_BOND unit -> cyclizable = CLOSING_SRU_HIGHER_ORDER_BOND ; #else unit -> cyclizable = CLOSING_SRU_NOT_APPLICABLE ; #endif goto exit_function ; } } unit -> cyclizable = CLOSING_SRU_RING ; exit_function : return ; }
Reveal and store CRU caps and ends ('stars and partners')
Reveal and store CRU caps and ends ( ' stars and partners ' )
/* The rest is applicable only to *---SRU---* case */ /* Stars are separated by one atom - that's not error but do nothing */ /* Stars are separated by two atoms - that's not error but do nothing */