Re: [Open Babel] Reading large coordinate files in C++ using Babel
> as an example you use this file (silica glass SiO2 with 3000 atoms in PDB > format, written using Babel): ... > Is this the reason why it is so slow for this kind of coordinates is because > Babel looking for bonds ? My guess, based on your example, is ring / aromaticity perception. In PDB, while bonds (CONECT) records can be stored, bond orders are not. So by default, Open Babel performs bond order perception (OBMol::PerceiveBondOrders()). At the moment, this includes a process to detect aromaticity and perform Kekule assignment. This gets slowed by perception over multiple fused rings (nanotubes, graphene, .. silica glass). On most molecules, it’s not a huge issue, but for materials and nanostructures, its. very. . slooww. . . I’m not sure how you’re using your code, but I’d make sure that PerceiveBondOrders() is not called. Finding bonds with ConnectTheDots() is usually reasonably fast, but this can also be an impact that you’re describing. -Geoff -- 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
Re: [Open Babel] Reading large coordinate files in C++ using Babel
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 htt
Re: [Open Babel] Problems importing pybel on Mac
> I'm on a mac running 10.13.1 and I installed openbabel using homebrew. I’d ask the Homebrew folks, but my guess is that you’re either not using the right python: % which python Or, Homebrew is installing the Open Babel python packages into a directory that you’ll need to add to your Python path. It’s also not obvious to me from the Homebrew formula whether pybel is installed by default: https://github.com/Homebrew/homebrew-core/blob/master/Formula/open-babel.rb Note that I see: option "with-python", "Compile Python language bindings” I’m not 100% sure how Homebrew works, but you may need to supply that option when installing the formula. Hope that helps, -Geoff -- 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
[Open Babel] Problems importing pybel on Mac
Hello, I'm an inexperienced user here and having some problems with importing pybel. When importing pybel I get the following error: Traceback (most recent call last): File "", line 1, in ImportError: No module named pybel I'm on a mac running 10.13.1 and I installed openbabel using homebrew. I've gathered from the wiki and earlier posts that eigen is important and I currently have version 3.3.4 installed. I'm currently using Python 2.7.14 as well. Any help on how to get pybel working would be appreciated! Thanks, Finn -- 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
[Open Babel] Reading large coordinate files in C++ using Babel
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