Hi Sébastien,

in principle you can disable the perception of connectivity, among other things, by using OBMol.BeginModify() (but somebody with more experience than me should confirm it). From the documentation[1]:

"Call when making many modifications -- clears conformer/rotomer data. The method "turns off" perception routines, improving performance. Changes in molecular structure will be re-considered after modifications."

Although, as far as I know, each BeginModify() should be followed by a EndModify(). If that's the case, after you're done parsing the file, you would trigger the perception again, so in the end you're just delaying the inevitable. Maybe before EndModify() you could call all methods to set properties you don't care about as perceived (see the docs)?

I have no experience on inorganic materials like yours, but by looking at your file, it seems you would have a dense network of connections: don't you want that?

If not, one thing you could do is to create "null" CONECT records in the PDB where each atom points at itself so there will be no need to perceive connections, but it's a very, very nasty hack that might backfire at any time. One might also argue that storing this kind of data in PDB files probably isn't the best choice...

Best,

S



[1] http://openbabel.org/dev-api/classOpenBabel_1_1OBMol.shtml#a1b5760b4c75b7631fffb54f84140b3e3

On 02/13/2018 05:09 AM, Sébastien Le Roux wrote:
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;
   }
}



--

 Stefano Forli, PhD

 Assistant Professor
 Dept. of Integrative Structural
 and Computational Biology, MB-112A
 The Scripps Research Institute
 10550  North Torrey Pines Road
 La Jolla,  CA 92037-1000,  USA.

    tel: +1 (858)784-2055
    fax: +1 (858)784-2860
    email: fo...@scripps.edu
    http://www.scripps.edu/~forli/


------------------------------------------------------------------------------
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