Esempio n. 1
0
// returns the largest component within the structure (you need to free this returned object later)
// doesn't free structure
int pickLargestSubstructure(int structure) {
    int componentIter, component, largestComponent; // Indigo objects that require freeing

    componentIter = indigoIterateComponents(structure);
    int maxAtoms = 0;
    if (componentIter != -1) {
        while (component = indigoNext(componentIter)) {
            // if only one component
            if (indigoIndex(component) == 0 && !indigoHasNext(componentIter))
            {
                indigoFree(componentIter);
                return indigoClone(structure);
            }
            
            int currentComponent = indigoClone(component);
            int numAtoms = indigoCountAtoms(currentComponent);
            //Rprintf("Number of atoms: %d\n\n", numAtoms);
            if (numAtoms>maxAtoms) {
                maxAtoms = numAtoms;
                largestComponent = indigoClone(currentComponent);  
            }
            indigoFree(currentComponent);
            indigoFree(component);
        }
    }
    indigoFree(componentIter);
    return largestComponent;
}
Esempio n. 2
0
File: main.c Progetto: Rillke/indigo
int _isMultipleCML (const char *filename, int *reaction)
{
   int iter = indigoIterateCMLFile(filename);

   *reaction = 0;
   
   if (indigoHasNext(iter))
   {
      int item = indigoNext(iter);
      if (strstr(indigoRawData(item), "<reaction") != NULL)
         *reaction = 1;
      
      if (indigoHasNext(iter))
      {
         indigoFree(item);
         indigoFree(iter);
         return 1;
      }
      indigoFree(item);
   }

   indigoFree(iter);
   return 0;
}