On 08/12/2020 23:01, José Emilio Sánchez Aparicio wrote:
Dear all,

 I need to find how many bonds of a certain type are in a molecule.
For example, for DOUBLE bonds, I would do:

 bond_number = 0
 for bond in mol.GetBonds():
     if bond.GetType() == Chem.BondType.DOUBLE:
         bond_number += 1

 However, searching for faster manners to do this, I found
"rdqueries". For example, to find how many atoms of Carbon there are
in a molecule, you could do:

 q = rdqueries.AtomNumEqualsQueryAtom(6)
 carbon_number = len(mol.GetAtomsMatchingQuery(q))

 I'm wondering if some of you know the equivalent in "rdqueries" to
find the number of bonds that match a type.

Such a function would probably do what your code is already doing.

It is not very useful to optimize such code fragment, unless
it is really taking most of your program runtime (which I doubt). ;)

 Many thanks in advance. Best,

 José-Emilio Sánchez
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to