6
$\begingroup$

I have been using OpenBabel as a handy-tool for converting small files without any issues.

Now, I am working with graphene-like systems with hundreds or even thousands of atoms, and the conversion of a 1360-line XYZ file to MOL2 format is taking more than 48 hours! My notebook is running Ubuntu 22.04 (64-bit), with an Intel i7 12-core processor and 24GB RAM.

There seems to be a problem with trying to do this using OpenBabel, whether directly or via third-party programs that use it as a plugin (like MAESTRO, Avogadro, etc.).

Is there any other tool for file conversion than does not use OpenBabel (or any library from it) that can be used for large files?

$\endgroup$
8
  • $\begingroup$ Interesting! Perhaps you can show us the XYZ file that you're trying to convert to MOL2 format, so that we can try to do some tests? SE posts can have up to 30,000 characters so 1360 lines might be okay. If it doesn't fit, perhaps you can put it in a folder called "9627" here. $\endgroup$ Sep 6, 2022 at 19:11
  • 5
    $\begingroup$ My strong guess (knowing your research) is that you'r running into problems with guessing the bond orders on a nanotube or graphene flake, for example. Determining bond orders in a ~25k atom PDB file is easy .. figuring out the Kekule bond orders in fused ring systems is a hard problem. $\endgroup$ Sep 6, 2022 at 19:33
  • $\begingroup$ Why do you need the file in mol2 format? $\endgroup$ Sep 6, 2022 at 19:33
  • $\begingroup$ I am using DESMOND to run molecular dynamics and its input files are prepare using MAESTRO, that convert the files using OPENBABEL. MAESTRO is getting stuck reading large files in XYZ format but if the file is in MOL2, it read it without any problem. I thought that converting first, and load it after will solve my issue. $\endgroup$
    – Camps
    Sep 6, 2022 at 19:42
  • 3
    $\begingroup$ I'd like to propose an edit. The problem isn't in converting large files. Its with converting large graphene-like systems. I can convert 25k atom PDB files in seconds, but yes 1300 atoms of graphene can take a lot of time. $\endgroup$ Sep 7, 2022 at 20:05

1 Answer 1

7
$\begingroup$

Large files aren't a problem per se. Open Babel easily handles 25k atom proteins. You're hitting slow conversion because you have files with many fused aromatic rings, e.g., graphene flakes, nanotubes, etc.

The problem you're describing is based on the need to perceive bond orders. (The mol2 format requires bond orders and aromaticity to define types, etc.)

The current algorithm in Open Babel uses backtracking when finding the correct Kekulé assignment. This can require a lot of time on fused ring systems because there are a lot of potential paths to check.

It's possible to turn off bond order assignment when reading XYZ files, using the -as flag (i.e., read single bonds only)

obabel file.xyz -O file.mol2 -as

Here's benzene:

@<TRIPOS>MOLECULE
benzene example
 12 12 0 0 0
SMALL
GASTEIGER

@<TRIPOS>ATOM
      1 C           0.0000    1.4027    0.0000 C.3     1  UNL1       -0.0309
      2 H           0.0000    2.4903    0.0000 H       1  UNL1        0.0309
      3 C          -1.2148    0.7014    0.0000 C.3     1  UNL1       -0.0309
      4 H          -2.1567    1.2451    0.0000 H       1  UNL1        0.0309
      5 C          -1.2148   -0.7014    0.0000 C.3     1  UNL1       -0.0309
      6 H          -2.1567   -1.2451    0.0000 H       1  UNL1        0.0309
      7 C           0.0000   -1.4027    0.0000 C.3     1  UNL1       -0.0309
      8 H           0.0000   -2.4903    0.0000 H       1  UNL1        0.0309
      9 C           1.2148   -0.7014    0.0000 C.3     1  UNL1       -0.0309
     10 H           2.1567   -1.2451    0.0000 H       1  UNL1        0.0309
     11 C           1.2148    0.7014    0.0000 C.3     1  UNL1       -0.0309
     12 H           2.1567    1.2451    0.0000 H       1  UNL1        0.0309
@<TRIPOS>BOND
     1     1     2    1
     2     1     3    1
     3     1    11    1
     4     3     4    1
     5     3     5    1
     6     5     6    1
     7     5     7    1
     8     7     8    1
     9     7     9    1
    10     9    10    1
    11     9    11    1
    12    11    12    1

Now that seems useless, since all the carbon atoms are C.3 instead of C.ar .. but it's trivial using Python or another script to find-and-replace the atom typings.

The other thing is to fix the C-C bonds:

@<TRIPOS>BOND
     1     1     2    1
     2     1     3   ar
     3     1    11   ar
     4     3     4    1
     5     3     5   ar
     6     5     6    1
     7     5     7   ar
     8     7     8    1
     9     7     9   ar
    10     9    10    1
    11     9    11   ar
    12    11    12    1

Besides Open Babel, it's possible to use RDKit with the xyz2mol package and save to SDF format, converting the resulting .mol or .sdf file to .mol2.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .