Dear all,
first thanks for reading this, I am new to OpenBabel and to this mailing list,
be sure I will appreciate your advise.
I developed a software to visualize/analyse/edit atomistic models, very recently I decided to use the OpenBabel library to read/output coordinates files in various format, bellow you will find the code I wrote to read coordinates files via babel. While playing with my software and the newly inserted OpenBabel read/write functions, I noticed something rather odd when reading rather larger coordinates files,
and I would like to get a better idea of what is going on.
When the connectivity of the system is rather large, well that it my guess after few trial and error sessions, it can takes a very long time to open the coordinate file, and I am just talking about some time spend around the '.ReadFile()' instruction, as an example you use this file (silica glass SiO2 with 3000 atoms in PDB format, written using Babel):


https://ipcms-cloud.u-strasbg.fr/owncloud/index.php/s/70C7b9Z04adVauD

I also noticed that other PDB file where the bonds are described can be opened very quickly. My guess is, that Babel is analysing the connectivity, ie. looking for bonds, am I correct ? Is this the reason why it is so slow for this kind of coordinates is because Babel looking for bonds ?
If yes is there a way to turn off this analyses before it begins ?
If yes I am wrong what can I do to speed up the opening process ?

Thanks in advance for your lights on the matter.

Best regards.

Sébastien Le Roux

--------------------------------------------------------------------------------------------------------------------------------------------------

int read_this_file_using_babel (char * this_format, char * this_file)
{
  OBConversion conv;
  if(conv.SetInFormat(this_format))
  {
    OBMol mol;
    if(conv.ReadFile(& mol, this_file))
    {
      // It does read the file !
      if (mol.HasData(OBGenericDataType::UnitCell))
      {
         OBUnitCell * uc = (OBUnitCell *)mol.GetData(OBGenericDataType::UnitCell);         // My code is mostly in C, so I have to send back the data I need to the C part.          save_babel_unit_cell_details (uc->GetA(), uc->GetB(), uc->GetC(), uc->GetAlpha() , uc->GetBeta(), uc->GetGamma());
         if (strcmp(this_format, "cif")  == 0) uc -> FillUnitCell (& mol);
      }
      int atoms = mol.NumAtoms ();
      int * lot;
      lot = (int *)calloc(atoms, sizeof(int));
      double ** coords;
      coords = (double **)calloc(atoms, sizeof(double *));
      int i = 0;
      FOR_ATOMS_OF_MOL (atom, mol)
      {
        lot[i] = atom -> GetAtomicNum();
        coords[i] = (double *)calloc(3, sizeof(double));
        coords[i][0] = atom -> GetX();
        coords[i][1] = atom -> GetY();
        coords[i][2] = atom -> GetZ();
        i ++;
      }
      // My code is mostly in C, so I have to send back the data I need to the C part.
      save_babel_molecule_details (atoms, lot, coords);
      free (lot);
      free (coords);
      mol.Clear();
      return 0;
    }
    else
    {
      // Error reading file
      return 1;
    }
  }
  else
  {
    // Error with this format
    return 2;
  }
}


--
===========================================================
Dr. Sébastien Le Roux
Ingénieur de Recherche CNRS
Institut de Physique et Chimie des Matériaux de Strasbourg
Département des Matériaux Organiques
23, rue du Loess
BP 43
F-67034 Strasbourg Cedex 2, France
E-mail: sebastien.ler...@ipcms.unistra.fr
Webpage: http://www.ipcms.unistra.fr/?page_id=14965&lang=en
RINGS project: http://rings-code.sourceforge.net/
ISAACS project: http://isaacs.sourceforge.net/
Fax:   +33 3 88 10 72 46
Phone: +33 3 88 10 71 58
===========================================================


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to