コード例 #1
0
	//--
	// [rad] used to make look like descriptors are part of the molecule
	bool ClassCondition::ProcessDescriptor(OpenBabel::OBMol* pMolecule)
	{
		std::vector<OpenBabel::OBGenericData*>::iterator iter_data;
		std::string sQualityName, sQualityValue;
		OpenBabel::OBPairData* pAuxData;

		std::istringstream ssConv;
		int iValue;
		double dValue;		
		

		for(iter_data = pMolecule->BeginData(); iter_data != pMolecule->EndData(); iter_data++)
		{
			// [rad] Take care of PairData only for now
			if(1 == (*iter_data)->GetDataType())
			{
				pAuxData = (OpenBabel::OBPairData*)(*iter_data);
				sQualityName = pAuxData->GetAttribute();
				sQualityValue = pAuxData->GetValue();

				if(!sQualityName.compare("PUBCHEM_COMPOUND_CID") && !m_sOn.compare("MOLECULE_PUBCHEM_COMPOUND_CID")) 
				{
					ssConv.str(sQualityValue);
					ssConv >> iValue;

					return(ProcessInt(iValue));
				}
				else if(!sQualityName.compare("PUBCHEM_CACTVS_HBOND_ACCEPTOR") && !m_sOn.compare("MOLECULE_PUBCHEM_CACTVS_HBOND_ACCEPTOR"))
コード例 #2
0
ファイル: dcgram.c プロジェクト: fengttt/TPC-DS
/*
 * Routine: ProcessSet
 * Purpose: Read distribution settings
 * Algorithm:
 * Data Structures:
 *
 * Params:
 * Returns:
 * Called By:
 * Calls:
 * Assumptions:
 * Side Effects:
 * TODO: None
 *
 * NOTE: if QERR_SYNTAX can be a valid return value, we have a problem.
 */
int
ProcessSet (char *stmt, token_t * tokens)
{
    int nRetCode = 0,
        i;
    char *cp = NULL;

    cp = SafeStrtok (NULL, " \t=");
    switch (i = FindToken (cp))
    {
    case TKN_WEIGHTS:
        cp = SafeStrtok (NULL, " \t");	/* discard = */
        pCurrentIndexEntry->w_width = ProcessInt (stmt, tokens);
        if (pCurrentIndexEntry->w_width == QERR_SYNTAX)
            nRetCode = QERR_RANGE_ERROR;
        else
        {
            if (pCurrentIndexEntry->w_width > nMaxWeightWidth)
            {
                arWeights = (int *) REALLOC (arWeights,
                                             pCurrentIndexEntry->w_width *
                                             sizeof (int));
                if (arWeights == NULL)
                    nRetCode = QERR_NO_MEMORY;
            }
            else
                nMaxWeightWidth = pCurrentIndexEntry->w_width;
        }
        pCurrentIndexEntry->dist->weight_sets =
            (int **) MALLOC (pCurrentIndexEntry->w_width * sizeof (int *));
        if (pCurrentIndexEntry->dist->weight_sets == NULL)
            nRetCode = QERR_NO_MEMORY;
        memset(pCurrentIndexEntry->dist->weight_sets, 0, pCurrentIndexEntry->w_width * sizeof(int *));
        break;
    case TKN_TYPES:
        pCurrentIndexEntry->v_width = ProcessTypes (stmt, tokens);
        if (pCurrentIndexEntry->v_width == QERR_SYNTAX)
            nRetCode = QERR_RANGE_ERROR;
        else
        {
            if (pCurrentIndexEntry->v_width > nMaxValueWidth)
            {
                arValues =
                    (char **) REALLOC (arValues,
                                       pCurrentIndexEntry->v_width *
                                       sizeof (char *));
                arValueLengths =
                    (int *) REALLOC (arValueLengths,
                                     pCurrentIndexEntry->v_width *
                                     sizeof (int));
            }
            if (arValues == NULL || arValueLengths == NULL)
                nRetCode = QERR_NO_MEMORY;
            else
            {
                for (i=nMaxValueWidth; i < pCurrentIndexEntry->v_width; i++)
                {
                    arValueLengths[i] = 0;
                    arValues[i] = NULL;
                }
                nMaxValueWidth = pCurrentIndexEntry->v_width;
            }
        }
        pCurrentIndexEntry->dist->value_sets =
            (int **) MALLOC (pCurrentIndexEntry->v_width * sizeof (int *));
        if (pCurrentIndexEntry->dist->value_sets == NULL)
            nRetCode = QERR_NO_MEMORY;
        memset(pCurrentIndexEntry->dist->value_sets, 0, pCurrentIndexEntry->v_width * sizeof(int *));
        break;
    case TKN_NAMES:
        if ((pCurrentIndexEntry->v_width <= 0) || (pCurrentIndexEntry->w_width <= 0))
            return(QERR_NAMES_EARLY);
        pCurrentIndexEntry->name_space = ProcessNames(stmt, tokens);
        break;
    default:
        nRetCode = QERR_SYNTAX;
    }

    return (nRetCode);
}