third_party/inchi/INCHI_BASE/src/runichi3.c
int  OAD_Polymer_FindRingSystems( OAD_Polymer *pd,
                                  inp_ATOM    *at,
                                  int         nat,
                                  int         *num_inp_bonds,
                                  int         *num_ring_sys,
                                  int         *size_ring_sys,
                                  int         start )
{
    int i, j, nrings = 0, bond_type, bond_stereo;

    if (NULL == num_ring_sys)
    {
        return 0;
    }

    /* Remove polymer SRU 'cyclizing' bonds if any */
    for (j = 0; j < pd->n; j++)
    {
        if (pd->units[j]->cyclized)
        {
            OrigAtData_RemoveBond( pd->units[j]->end_atom1 - 1,
                                   pd->units[j]->end_atom2 - 1,
                                   at, &bond_type, &bond_stereo,
                                   num_inp_bonds );
        }
    }

    MarkRingSystemsInp( at, nat, start ); /*0 );*/

    for (i = 0; i <= nat; i++)
    {
        num_ring_sys[i] = -1;
    }
    for (i = 0; i < nat; i++)
    {
        if (at[i].nNumAtInRingSystem > 2)
        {
            int atnum = at[i].orig_at_number;
            num_ring_sys[atnum] = at[i].nRingSystem;
            if (NULL != size_ring_sys)
            {
                size_ring_sys[atnum] = at[i].nNumAtInRingSystem;
            }
        }
    }

    UnMarkRingSystemsInp( at, nat );

    for (i = 0; i < nat; i++)
    {
        if (num_ring_sys[i] > -1)
        {
            nrings++;
        }
    }

    /* Restore polymer SRU 'cyclizing' bonds if applicable */
    for (j = 0; j < pd->n; j++)
    {
        if (pd->units[j]->cyclized)
        {
            OrigAtData_AddSingleStereolessBond( pd->units[j]->end_atom1 - 1,
                                                pd->units[j]->end_atom2 - 1,
                                                at,
                                                num_inp_bonds );
        }
    }

    return nrings;
}
/****************************************************************************
 Find ring systems (exclude possible cyclizing bonds) in all polymer SRU's
****************************************************************************/
Find ring systems (exclude possible cyclizing bonds) in all polymer SRU's
Find ring systems ( exclude possible cyclizing bonds ) in all polymer SRU ' s
int  OAD_Polymer_FindRingSystems( OAD_Polymer *pd,
                                  inp_ATOM    *at,
                                  int         nat,
                                  int         *num_inp_bonds,
                                  int         *num_ring_sys,
                                  int         *size_ring_sys,
                                  int         start )
{
    int i, j, nrings = 0, bond_type, bond_stereo;
    if (NULL == num_ring_sys)
    {
        return 0;
    }
    for (j = 0; j < pd->n; j++)
    {
        if (pd->units[j]->cyclized)
        {
            OrigAtData_RemoveBond( pd->units[j]->end_atom1 - 1,
                                   pd->units[j]->end_atom2 - 1,
                                   at, &bond_type, &bond_stereo,
                                   num_inp_bonds );
        }
    }
    MarkRingSystemsInp( at, nat, start ); 
    for (i = 0; i <= nat; i++)
    {
        num_ring_sys[i] = -1;
    }
    for (i = 0; i < nat; i++)
    {
        if (at[i].nNumAtInRingSystem > 2)
        {
            int atnum = at[i].orig_at_number;
            num_ring_sys[atnum] = at[i].nRingSystem;
            if (NULL != size_ring_sys)
            {
                size_ring_sys[atnum] = at[i].nNumAtInRingSystem;
            }
        }
    }
    UnMarkRingSystemsInp( at, nat );
    for (i = 0; i < nat; i++)
    {
        if (num_ring_sys[i] > -1)
        {
            nrings++;
        }
    }
    for (j = 0; j < pd->n; j++)
    {
        if (pd->units[j]->cyclized)
        {
            OrigAtData_AddSingleStereolessBond( pd->units[j]->end_atom1 - 1,
                                                pd->units[j]->end_atom2 - 1,
                                                at,
                                                num_inp_bonds );
        }
    }
    return nrings;
}
int OAD_Polymer_FindRingSystems ( OAD_Polymer * pd , inp_ATOM * at , int nat , int * num_inp_bonds , int * num_ring_sys , int * size_ring_sys , int start ) { int i , j , nrings = 0 , bond_type , bond_stereo ; if ( NULL == num_ring_sys ) { return 0 ; } for ( j = 0 ; j < pd -> n ; j ++ ) { if ( pd -> units [ j ] -> cyclized ) { OrigAtData_RemoveBond ( pd -> units [ j ] -> end_atom1 - 1 , pd -> units [ j ] -> end_atom2 - 1 , at , & bond_type , & bond_stereo , num_inp_bonds ) ; } } MarkRingSystemsInp ( at , nat , start ) ; for ( i = 0 ; i <= nat ; i ++ ) { num_ring_sys [ i ] = -1 ; } for ( i = 0 ; i < nat ; i ++ ) { if ( at [ i ] . nNumAtInRingSystem > 2 ) { int atnum = at [ i ] . orig_at_number ; num_ring_sys [ atnum ] = at [ i ] . nRingSystem ; if ( NULL != size_ring_sys ) { size_ring_sys [ atnum ] = at [ i ] . nNumAtInRingSystem ; } } } UnMarkRingSystemsInp ( at , nat ) ; for ( i = 0 ; i < nat ; i ++ ) { if ( num_ring_sys [ i ] > -1 ) { nrings ++ ; } } for ( j = 0 ; j < pd -> n ; j ++ ) { if ( pd -> units [ j ] -> cyclized ) { OrigAtData_AddSingleStereolessBond ( pd -> units [ j ] -> end_atom1 - 1 , pd -> units [ j ] -> end_atom2 - 1 , at , num_inp_bonds ) ; } } return nrings ; }
Find ring systems (exclude possible cyclizing bonds) in all polymer SRU's
Find ring systems ( exclude possible cyclizing bonds ) in all polymer SRU ' s
/* Remove polymer SRU 'cyclizing' bonds if any */ /*0 );*/ /* Restore polymer SRU 'cyclizing' bonds if applicable */