third_party/inchi/INCHI_BASE/src/ichicans.c
int FillOutStereoParities( sp_ATOM       *at,
                           int           num_atoms,
                           const AT_RANK *nCanonRank,
                           const AT_RANK *nAtomNumberCanon,
                           const AT_RANK *nRank,
                           const AT_RANK *nAtomNumber,
                           CANON_STAT    *pCS,
                           CANON_GLOBALS *pCG,
                           int           bIsotopic )
{
    int ret;
    /*  unmark atoms with 2 or more constitutionally equivalent neighbors */
    /*  such that there is no path through them to an atom with parity */
    ret = UnmarkNonStereo( pCG, at, num_atoms, nRank, nAtomNumber, bIsotopic );
    if (ret < 0)
        return ret;  /*  program error? */ /*   <BRKPT> */
    ret = FillAllStereoDescriptors( pCG, at, num_atoms, nCanonRank, nAtomNumberCanon, pCS ); /*  ret<0: error */
    if (!ret)
    {
        ret = pCS->nLenLinearCTStereoCarb + pCS->nLenLinearCTStereoDble;
    }
    if (ret < 0)
    {
        return ret; /*  program error? */ /*   <BRKPT> */
    }

    if (ret >= 0)
    {
        int ret2;
        ret2 = SetKnownStereoCenterParities( pCG, at, num_atoms, nCanonRank, nRank, nAtomNumber );
        if (ret2 >= 0)
        {
            ret2 = MarkKnownEqualStereoCenterParities( at, num_atoms, nRank, nAtomNumber );
        }
        if (ret2 >= 0)
        {
            ret2 = SetKnownStereoBondParities( pCG, at, num_atoms, nCanonRank, nRank, nAtomNumber );
            if (ret2 >= 0)
            {
                ret2 = MarkKnownEqualStereoBondParities( at, num_atoms, nRank, nAtomNumber );
            }
        }
#if ( REMOVE_KNOWN_NONSTEREO == 1 ) /* { */
        if (ret2 >= 0)
        {
            int ret3;
            do
            {
                ret2 = RemoveKnownNonStereoCenterParities( pCG, at, num_atoms, nCanonRank, nRank, pCS );
                if (ret2 >= 0)
                {
                    ret3 = RemoveKnownNonStereoBondParities( at, num_atoms, nCanonRank, nRank, pCS );
                    ret2 = ret3 >= 0 ? ret2 + ret3 : ret3;
                }
            }
            while (ret2 > 0);
        }
        if (RETURNED_ERROR( ret2 ))
        {
            ret = ret2;
        }
#endif /* } REMOVE_KNOWN_NONSTEREO */
    }

    return ret; /*  non-zero means error */
}
/********************************************************************************/
/*  Make sure atoms stereo descriptors fit molecular symmetry and remove        */
/*  parity from obviously non-stereo atoms and bonds                            */
/********************************************************************************/
Make sure atoms stereo descriptors fit molecular symmetry and remove
parity from obviously non-stereo atoms and bonds
Make sure atoms stereo descriptors fit molecular symmetry and remove parity from obviously non - stereo atoms and bonds
int FillOutStereoParities( sp_ATOM       *at,
                           int           num_atoms,
                           const AT_RANK *nCanonRank,
                           const AT_RANK *nAtomNumberCanon,
                           const AT_RANK *nRank,
                           const AT_RANK *nAtomNumber,
                           CANON_STAT    *pCS,
                           CANON_GLOBALS *pCG,
                           int           bIsotopic )
{
    int ret;
    ret = UnmarkNonStereo( pCG, at, num_atoms, nRank, nAtomNumber, bIsotopic );
    if (ret < 0)
        return ret;   
    ret = FillAllStereoDescriptors( pCG, at, num_atoms, nCanonRank, nAtomNumberCanon, pCS ); 
    if (!ret)
    {
        ret = pCS->nLenLinearCTStereoCarb + pCS->nLenLinearCTStereoDble;
    }
    if (ret < 0)
    {
        return ret;  
    }
    if (ret >= 0)
    {
        int ret2;
        ret2 = SetKnownStereoCenterParities( pCG, at, num_atoms, nCanonRank, nRank, nAtomNumber );
        if (ret2 >= 0)
        {
            ret2 = MarkKnownEqualStereoCenterParities( at, num_atoms, nRank, nAtomNumber );
        }
        if (ret2 >= 0)
        {
            ret2 = SetKnownStereoBondParities( pCG, at, num_atoms, nCanonRank, nRank, nAtomNumber );
            if (ret2 >= 0)
            {
                ret2 = MarkKnownEqualStereoBondParities( at, num_atoms, nRank, nAtomNumber );
            }
        }
#if ( REMOVE_KNOWN_NONSTEREO == 1 ) 
        if (ret2 >= 0)
        {
            int ret3;
            do
            {
                ret2 = RemoveKnownNonStereoCenterParities( pCG, at, num_atoms, nCanonRank, nRank, pCS );
                if (ret2 >= 0)
                {
                    ret3 = RemoveKnownNonStereoBondParities( at, num_atoms, nCanonRank, nRank, pCS );
                    ret2 = ret3 >= 0 ? ret2 + ret3 : ret3;
                }
            }
            while (ret2 > 0);
        }
        if (RETURNED_ERROR( ret2 ))
        {
            ret = ret2;
        }
#endif 
    }
    return ret; 
}
int FillOutStereoParities ( sp_ATOM * at , int num_atoms , const AT_RANK * nCanonRank , const AT_RANK * nAtomNumberCanon , const AT_RANK * nRank , const AT_RANK * nAtomNumber , CANON_STAT * pCS , CANON_GLOBALS * pCG , int bIsotopic ) { int ret ; ret = UnmarkNonStereo ( pCG , at , num_atoms , nRank , nAtomNumber , bIsotopic ) ; if ( ret < 0 ) return ret ; ret = FillAllStereoDescriptors ( pCG , at , num_atoms , nCanonRank , nAtomNumberCanon , pCS ) ; if ( ! ret ) { ret = pCS -> nLenLinearCTStereoCarb + pCS -> nLenLinearCTStereoDble ; } if ( ret < 0 ) { return ret ; } if ( ret >= 0 ) { int ret2 ; ret2 = SetKnownStereoCenterParities ( pCG , at , num_atoms , nCanonRank , nRank , nAtomNumber ) ; if ( ret2 >= 0 ) { ret2 = MarkKnownEqualStereoCenterParities ( at , num_atoms , nRank , nAtomNumber ) ; } if ( ret2 >= 0 ) { ret2 = SetKnownStereoBondParities ( pCG , at , num_atoms , nCanonRank , nRank , nAtomNumber ) ; if ( ret2 >= 0 ) { ret2 = MarkKnownEqualStereoBondParities ( at , num_atoms , nRank , nAtomNumber ) ; } } #if ( REMOVE_KNOWN_NONSTEREO == 1 ) if ( ret2 >= 0 ) { int ret3 ; do { ret2 = RemoveKnownNonStereoCenterParities ( pCG , at , num_atoms , nCanonRank , nRank , pCS ) ; if ( ret2 >= 0 ) { ret3 = RemoveKnownNonStereoBondParities ( at , num_atoms , nCanonRank , nRank , pCS ) ; ret2 = ret3 >= 0 ? ret2 + ret3 : ret3 ; } } while ( ret2 > 0 ) ; } if ( RETURNED_ERROR ( ret2 ) ) { ret = ret2 ; } #endif } return ret ; }
Make sure atoms stereo descriptors fit molecular symmetry and remove
parity from obviously non-stereo atoms and bonds
Make sure atoms stereo descriptors fit molecular symmetry and remove parity from obviously non - stereo atoms and bonds
/*  unmark atoms with 2 or more constitutionally equivalent neighbors */ /*  such that there is no path through them to an atom with parity */ /*  program error? */ /*   <BRKPT> */ /*  ret<0: error */ /*  program error? */ /*   <BRKPT> */ /* { */ /* } REMOVE_KNOWN_NONSTEREO */ /*  non-zero means error */