Closed tobigithub closed 4 years ago
Thanks for reporting. There is indeed a bug in the released version, which should be fixed by https://github.com/grimme-lab/xtb/pull/4.
I would very much appreciate having your recommendations as separate issues, since I cannot come up if a single pull request addressing all of them. Maybe a few thoughts here
xtb
side.xtb
doesn't use any bond topology information (it actually drops them while reading the SDF, which is part of the problem you reported). In principle we are producing bond order information in xtb
and could amend those from the SDF.xtb
. I know that GFN-xTB is suited for this kind of high-throughput calculations, but the xtb
program is not designed to work this way. Don't get me wrong here, I like the idea, but I don't think it is possible to get this running in xtb
in the near future.Let's sum this up:
xtb
.IMHO, if a 2D case or an SDF is supplied without explicit hydrogens, I'd suggest calling obabel
to convert. (Granted, I'm biased.)
@awvwgk thank you for the additional comments, I will open individual requests with the new version. As you mentioned, not everything will be doable, but I have a test pipeline of a couple thousand of structures I want to send through. I will see what problems remain open after the patch. In the mean time I will just use the coord (tmol) input.
I've run through ~100k compounds using XYZ from Open Babel, but I have a validation set I've been using for holdout that I can run ~70k optimization + Hessian.
@ghutchis will you be able to share the results and your methods?
I am using either bash shell scripts or some single liner constructs that may add some penalty to the overall computational time. For example using the C60 fullerene data from Comprehensive theoretical study of all 1812 C60 isomers [XYZ] one can calculate single point energies with a wonderful speedup factor of 80 in 0.7 seconds for each molecule on a node with 44 CPUs/88 threads. The final time boils down to 22 min for 1812 molecules, based on the really awesome scaling of xtb.
$ for d in ./*/ ; do (cd "$d" && echo -n "active dir: $d" && xtb geom.xyz
| grep --line-buffered "TOTAL ENERGY"); done
active dir: ./1/ | TOTAL ENERGY -128.453291352107 Eh |
normal termination of xtb
active dir: ./10/ | TOTAL ENERGY -128.331358624594 Eh |
normal termination of xtb
active dir: ./100/ | TOTAL ENERGY -128.265600476068 Eh |
normal termination of xtb
active dir: ./1000/ | TOTAL ENERGY -128.166664861876 Eh |
normal termination of xtb
active dir: ./1001/ | TOTAL ENERGY -128.168084576528 Eh |
normal termination of xtb
active dir: ./1002/ | TOTAL ENERGY -128.169887114880 Eh |
normal termination of xtb
active dir: ./1003/ | TOTAL ENERGY -128.168197428449 Eh |
Of course once we calculate opt-freq we need to store the data, but I guess even 100k molecules should be doable in a couple of hours on multiple nodes. I wonder if one could pipe the SDF conversions from Open Babel directly to xtb and then extract the energies or other values one the fly. Its probably best done with the python API? I have not looked into that yet.
@tobigithub - this seems outside the discussion on this issue. Feel free to contact me. At the moment, the data isn't public, but we should be making several GFN-related manuscripts and data sets available soon. We generally use Python, but your shell script is similar and won't add much overhead.
I guess we are almost there, see #30. So there are a few open questions here, I need a reliable way to determine:
If it is not easily possible, I will go with garbage in / garbage out here.
A SDF is supposed to note whether it's a 2D depiction or a 3D coordinates (that might be flat): https://gist.github.com/ghutchis/270df9db7c4f2f4a30519aabbaa3f73d
Note that in the 2nd line, a 2D depiction ends in '2D' and a 3D depiction ends in '3D'
As far as hydrogen atoms, I'd probably go with 'we're going to run what you sent us' - maybe with a warning if the charge/spin seem weird.
One request though would be to add up the formal charges in a SDF file from the M CHG lines: https://gist.github.com/ghutchis/29130f768fd85444333b2a0ec643a441
M CHG 1 3 -1 (one charge on atom 3, -1) M CHG 2 3 -1 5 -1 (two charges, atom 3 is -1 and atom 5 is -1)
I'd have to check on the radical options (M RAD), but there are a lot more cases with formal charges (e.g., amino acids, side chains, etc.)
M ISO might be useful for some purposes too.
I guess we are almost there, see #30. So there are a few open questions here, I need a reliable way to determine:
- that a structure is 2D (e.g. benzen is 2D in reality, so it should not catch this one)
- if explicit hydrogen atoms are missing (e.g. S8 doesn't need hydrogen atoms)
If it is not easily possible, I will go with garbage in / garbage out here.
@awvwgk I think that is something to check with tests, while it is impossible to cover all MDL MOL definitions, it will still leave room for errors. But covering 90% of the correct cases should be fine.
Meaning if molecules pass openbabel or molconvert they are fine, If xtb accepts molecules that do not pass a openbabel conversion something is wrong. Plus xtb should be able to calculate energies for a random selection of good molecules such as those below.
Data sources of good molecules can be PubChem, EBI, HMDB, NCI ftp://ftp.ncbi.nlm.nih.gov/pubchem/Compound_3D/01_conf_per_cmpd/SDF/ ftp://ftp.ncbi.nlm.nih.gov/pubchem/Compound/CURRENT-Full/SDF/ https://www.ebi.ac.uk/chebi/downloadsForward.do
@awvwgk
need a reliable way to determine: that a structure is 2D (e.g. benzen is 2D in reality, so it should not catch this one)
A way to determine if a structure is 2D in MOL or SDF is that a single column's coordinates sum equals zero. In the case below, the z-axis is zero. It could also be x or y but most packages just zero out the z-axis. While there could be other cases (rotation along a specific bond) this is 99% never the case. I am sure there are matrix operations to test for all cases, but the sum of z-axis coordinates equals zero is a good test for having 2D molecules. Its what most of the software tools do.
Another observation is that xtb actually handles 2D molecules quite well. So it might not be a big issue, but additional tests are required. I am running the CHEBI molecules (https://www.ebi.ac.uk/chebi/downloadsForward.do) with a single energy point calculation to see if something is wrong.
Marvin 05071312412D
12 13 0 0 0 0 999 V2000
16.4064 -5.7650 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
16.4064 -6.6172 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
17.0908 -7.0082 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
17.8173 -6.6172 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
17.8173 -5.7650 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
17.0908 -5.3740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
18.5856 -5.5415 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
19.0745 -6.1981 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
18.5856 -6.8407 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
17.0908 -4.5637 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
19.8987 -6.1981 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
15.7079 -7.0223 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
5 4 2 0 0 0 0
9 4 1 0 0 0 0
3 4 1 0 0 0 0
7 5 1 0 0 0 0
6 5 1 0 0 0 0
8 7 1 0 0 0 0
8 9 1 0 0 0 0
11 8 2 0 0 0 0
2 3 2 0 0 0 0
2 1 1 0 0 0 0
6 1 1 0 0 0 0
12 2 1 0 0 0 0
10 6 2 0 0 0 0
M END
> <ChEBI ID>
CHEBI:52617
> <ChEBI Name>
7,8-dihydro-8-oxoguanine
> <Star>
3
@awvwgk
if explicit hydrogen atoms are missing (e.g. S8 doesn't need hydrogen atoms)
The test would be for organic compounds, most commonly carbon bound to hydrogen, nitrogen, oxygen, sulfur. So I would not be concerned with exotic cases, including metals or single elements. Elements CHNSOP are enough. Elements such as SNP will have multiple valencies, but here one could use the most common valence states for each element. The cheapest way would be to test if there is any carbon at all, short of fullerenes and pure carbon compounds.
A way to test would be via Lewis and Senior rules and check that against the charge. See ANALOGOUS ODD-EVEN PARITIESIN MATHEMATICS AND CHEMISTRY http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.665.1134&rep=rep1&type=pdf
Intro I highly appreciate the MOL and SDF file reader and import, because it narrows the gap between cheminformatics with millions of molecules from PubChem and ChemSpider and the quantum chemistry world. So instead of going via information devoid xyz or coord files, the SDF and mol files can be enriched directly with meta information (energies, fukui indices, EA, HOMO-LUMO gaps etc). While we have tools to convert files (OpenBabel, ChemAxon molconvert) the direct calculation on MOL and SDF files is a really important feature, because it will allow for easier workflows and finally also broader use within the community. I am writing this somewhat lengthy intro because it is easy to just get rid of problematic features by excluding them, but that is not my intention.
Describe the bug The mol/sdf file reader is reading only very specifically formatted molecules, but throws errors on correctly formatted standard MOL (MDL V2000) formatted files. This applies to simple molecules, not exotic SDF options. When it does that it actually leads to many different errors, from falsely breaking bonds to throwing errors regarding atom numbers and optimization failures. I am also adding additional recommendations, or if needed can file them as individual issues?
To Reproduce Steps to reproduce the behavior:
XTB version: Version 6.2 RC2 (SAW190805) I checked and converted most molecules with OpenBabel and ChemAxon mview and molconvert. These tools have been used to convert millions/billions of connection tables. They are pretty robust. Case 2-6 shows the errors.
Case 1 (Expected computational behavior): Warning, this is a faulty SDF/mol molecule recreated from the xtb documentation, it can not be imported by OpenBabel or by MarvinView. There are not enough spaces after the atom coordinates (x y z O), therefore the molecules is corrupt. The xtb file reader probably just reads coordinates.
Case 2 (C6H6-m213-2D.sdf) benzene standard and error free 2D formatted mod/sdf file:
Case 3 (C6H6-m213-aroma.sdf) (benzene aromatized bonds):
Case 4 (water-chemaxon.sdf) (correctly formatted SDF) atom number mismatch:
Case 5 (xtb water-openbabel-2D.sdf) (correctly formatted 2D SDF):
Case 6 (xtb water-openbabel-3D.sdf) (correctly formatted 3D SDF): This case is interesting, because a different energy is presented, even with --opt extreme options. When compared to the working h2o.sdf example from the handbook, the energy is different and somewhat interesting the optimization failed, even when repeated.
Please provide all input and output file such that we confirm your report. See attached. XTB-sdf-issues.zip contains the examples shown here.
Additional recommendations
Additional context
original MDL V2000 format definitions (CTF file formats) http://c4.cabrillo.edu/404/ctfile.pdf
ChemAxon structure checker, a software that detects errors in SDF/MOL files https://docs.chemaxon.com/display/docs/Checker+List
OpenBabel Doc https://buildmedia.readthedocs.org/media/pdf/open-babel/latest/open-babel.pdf
OpenBabel installation http://openbabel.org/wiki/Category:Installation
ChemAxon molconvert https://chemaxon.com/marvin-archive/latest/help/applications/molconvert.html
SDF error checker http://www.nonlinear.com/progenesis/sdf-studio/v0.9/faq/sdf-file-format-guidance.aspx
command line parameters to convert or split a single multi-molecule SDF to multiple mol/sdf/tmol