3
$\begingroup$

I have a small set (a hundred of items) of chemical compounds in XYZ formats in my DB. How to quickly identify that a given chemical is or isn't in this DB?

I don't want to just scan through them, or do something else of an ad-hoc nature.

Is there an algorithm that allows to do this?

$\endgroup$
  • 2
    $\begingroup$ Are you using database software, or are you programming in a general purpose programming language? $\endgroup$ – Karsten Theis Apr 18 at 17:07
  • $\begingroup$ In general, you can't because a chemical formula is not an unambiguous way to identify a compound. $\endgroup$ – Zhe Apr 18 at 17:25
  • $\begingroup$ @KarstenTheis I use a general purpose programming language. $\endgroup$ – Jennifer M. Apr 18 at 17:33
  • 1
    $\begingroup$ You might be able to convert your structures to smiles or something similar, i.e. InChI and then match that, or is hash. Obviously there are drawbacks, and you might lose information along the way, but this should be fairly quick, and the are libraries you might be able to use. $\endgroup$ – Martin - マーチン Apr 18 at 17:53
  • 1
    $\begingroup$ Cartesian coordinates capture a snapshot of a molecule in time. Molecules do adapt different conformations. Some equivalent connections are invalid because they cannot be accessed (atropisomers) and others have equivalent connections but the exact nature of the 3D connectivity matters (stereochemistry). This is a non-trivial problem. @Martin-マーチン 's suggestion can get you a good way there, but I don't think there is a general solution. $\endgroup$ – Zhe Apr 18 at 18:25
4
$\begingroup$

Either way, you need to define what it means for a chemical to be 'in' your database. Do you care about the 3D coordinates (given that you have XYZ) or just the atom types and connectivity?

Short answer. use a cheminformatics library that provides structure matching or can encode your molecules (query and targets) as canonical SMILES, InChI, etc.

See Is there a way to use free software to convert SMILES strings to structures?

Long answer. Use a series of filters (or questions):

  1. Are there any molecues in my database with the same number of atoms?
  2. Do any of these have the same atom types?
  3. Finally, are these atoms connected to the same neighbours?

The third one is a little trickier, but is still a quick way to determine isomorphism. If you need true structure matching, see the short answer! If you need 3D matching, then again it's going to be much quicker to use a library method.

$\endgroup$
  • $\begingroup$ A series of filters, from cheap to more expensive, makes a lot of sense. For 1. and 2., you could write the sum formula in a string and use a dictionary (hash) to retrieve matches (built into many programming languages). For 3., you could use algorithms relating to distance geometry or, once you have a connectivity graph, use graph matching algorithms. $\endgroup$ – Karsten Theis Apr 18 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.