Automatic Valency Restoration & Iterators

User d6c1b7eb8c

07-09-2009 14:09:54

I have noticed that when bonds are deleted via the mol.removeEdge(bond) method, and then the smiles are printed (mol.toFormat("smiles:+H")) that hydrogens are put in, restoring the valency of the molecule.

Why is this behaviour default, and can it be disabled?

Also, in doing this, I came across the 'IteratorFactory' class and was wondering if there are any distinct advantages of using it over a more conventional method like:


 for atom in mol.getAtomArray():
     n = atom.getBondCount()
  
     for i in range(0,n): 
    
           Bond = atom.getBond(i)



etc.



Thank you very much for your time,
Ben Lowe

ChemAxon a3d59b832c

07-09-2009 14:19:35

Hi Ben,


The topic was moved to the appropriate forum, my colleagues will answer you soon.


Best regards,


Szabolcs

ChemAxon e500b51457

08-09-2009 10:37:38

Hi Ben,

The +H option in SMILES export adds explicit Hydrogen atoms. (When we can see the explicit Hydrogens in the SMILES string, that doesn't mean that the original Molecule object contains the explicit hydrogens.) Could you send us a code example, please?

In this case there are no distinct advantages of using IteratorFactory. IteratorFactory is useful when including or exluding special atom or bond sets.


Best regards,
Erika.

User d6c1b7eb8c

09-09-2009 09:11:50

Thanks,

Previously I was not using the mol.addExplicitHydrogens(0) method, now I am using it but still have some questions.

Code:

I am using pattern matching as a method of fragmentation (Although I am aware of the Fragmentor Class) and inputting aromatic molecules and breaking off methyl groups until they are simply benzene rings.


(using Jython)


e.g. smiles = c1ccccc1CCC


smarts = '[a:1]-[C:2]'


**match**



for match in subSearch.findAll():


  aromaticAtomId = match[0]
  
  aromaticAtom = mol.getAtom(aromaticAtomId)


  ### Gets SMARTS Bond for this match
  n = aromaticAtom.getBondCount()
 
  smartsBond = None
 
  for i in range(0,n):
       bond = aromaticAtom.getBond(i)
 
       #Choose the bond which has the match
       if (mol.indexOf(bond.getAtom1()) == match[1] and mol.indexOf(bond.getAtom2()) == aromaticAtomId) or (mol.indexOf(bond.getAtom2()) == match[1] and mol.indexOf(bond.getAtom1()) == aromaticAtomId) :
    smartsBond = bond
 
  ###
 
  mol.removeEdge(smartsBond)
 
  print mol.toFormat("smiles")


  print mol.getExplicitHcount(), mol.getImplicitHcount()


 


OUTPUT:

[H]C([H])C([H])([H])C([H])([H])[H].[H]c1cc([H])c([H])c([H])c1[H]

12 2
_______


I've noticed that, although the output is now correct, it is still producing 2 implicit Hydrogens, i.e. it must have restored the valence where the bond was broken...?

Also is there a way of outputting to the format CC[CH2].c1c[c]ccc1 such that all non-valent correct hydrogens are indicated?

Thanks very much,
Ben

ChemAxon e500b51457

10-09-2009 07:58:03

Hi Ben,


Thanks for the code example, we understand the problem now. The valence check is called at bond removal and adds the extra hydrogen. You can restore the state this way:

MolAtom atom1 = bond.getAtom1();
MolAtom atom2 = bond.getAtom2();
mol.removeEdge(bond);
atom1.setRadical(MolAtom.RAD1);
atom2.setRadical(MolAtom.RAD1);
mol.valenceCheck();

Please use the ChemAxon Extended SMILES format to indicate the non-valent correct hydrogens, for example: mol.toFormat("cxsmiles:+H").

Best regards
Erika.

User d6c1b7eb8c

10-09-2009 10:10:47

Excellent Thanks!

I've noticed mol.toFormat("cxsmiles:+H") prints:


[H][C]([H])C([H])([H])C([H])([H])[H].[H]c1[c]c([H])c([H])c([H])c1[H] |^1:1,12|


In this example, therefore I take it that there is no easy way to output to the more readable form: CC[CH2].c1c[c]ccc1 ?

ChemAxon e500b51457

10-09-2009 20:34:47

Without the +H option, mol.toFormat("cxsmiles") will result in a similar form with an extension describing the radicals. Furthermore, exporting into SMILES with mol.toFormat("smiles") results the most simple form. Our SMILES import will add the radicals to the atoms where the H number is less than what the valence would require.


Best regards,


Erika

User d6c1b7eb8c

11-09-2009 08:29:35

Thanks very much!