Hi Ignacio,

  The xyz parser is in openbabel/src/formats/xyzformat.cpp .

The code you are looking for is called on lines 276 and 278, see 
https://github.com/openbabel/openbabel/blob/master/src/formats/xyzformat.cpp#L276

    if (!pConv->IsOption("b",OBConversion::INOPTIONS))
        mol.ConnectTheDots();
    if (!pConv->IsOption("s",OBConversion::INOPTIONS) && 
!pConv->IsOption("b",OBConversion::INOPTIONS))
        mol.PerceiveBondOrders();

ConnectTheDots() is in src/mol.cpp starting at line 2937. 
   https://github.com/openbabel/openbabel/blob/master/src/mol.cpp#L2937

     This method adds single bonds between all atoms
     closer than their combined atomic covalent radii,
     then "cleans up" making sure bonded atoms are not
     closer than 0.4A and the atom does not exceed its valence.
     It implements blue-obelisk:rebondFrom3DCoordinates.

PerceiveBondOrders() starts on line 3139 of the same file
   https://github.com/openbabel/openbabel/blob/master/src/mol.cpp#L3139

    This method uses bond angles and geometries from current
    connectivity to guess atom types and then filling empty valences
    with multiple bonds. It currently has a pass to detect some
    frequent functional groups. It still needs a pass to detect aromatic
    rings to "clean up."
    AssignSpinMultiplicity(true) is called at the end of the function. The true
    states that there are no implict hydrogens in the molecule.

Cheers,

                                Andrew
                                da...@dalkescientific.com


> On Oct 3, 2019, at 18:43, Ignacio Pickering <ign.picker...@gmail.com> wrote:
> 
> I found that OpenBabel can convert .xyz files to SMILES strings, which means 
> that it must be using some sort of heuristic to determine the connectivity of 
> a molecule based on distances and nuclear charges. 
> 
> I've been trying to find references to the specific algorithm implemented but 
> I couldn't find anything, and I haven't been able to find the code that does 
> this conversion in github (probably because I'm not too familiar with the 
> repo, It should be there somewhere right?).
> 
> I was wondering if someone could point me in the right direction regarding 
> this, since its a very useful feature I would like to use, and I would like 
> to be more familiar with its inner workings to check how reliable/robust it 
> is, and what approximations its making.
> 
> Best,
> 
> Ignacio
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss





_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to