breaking mutiple ring bonds

User 55ffa2f197

08-08-2013 03:19:22

Hi, i am trying to break mutiple ring bonds in a molecule, for each selected ring, two specific ring bonds will be broken, and i need to track the cutout acyclic subgraph. Since there are mutiple paired breaking, i need to track which paired break produce what. Attached file illustrate the cuts, i am making two cuts on each ring.


What i did is following,


1. identify the bond with its bond index, and put them into a list bondToBreak


2. use removeBond(int) method to break the bond in cloned molecule m2, keep original molecule intact


Molecule m2 = molecule.cloneMolecule();


for (int bond: bondToBreak){


m2.removeBond(bond);


}


for (Molecule frag:m2.convertToFrags()){


system.out.println(frag.toFormat("smiles");


}


but i am getting wrong result.


If i put molbond to bondToBreak, and do following on original molecule:


for (MolBond bond: bondToBreak){


molecule.removeBond(bond);


}


I do get the right result, however I cannot correctly track which break generates what, convertToFrags method sending out the frag not exactly fowlloing the order the frag is generated


Is there an alternative way to do this


Thanks


Dong


 

ChemAxon 712bc8fcf4

08-08-2013 10:44:31

Hi Dong,


In the first case if you delete a bond the bond indices of the other bonds are changing. So the indices that you stored before are not valid after you delete a bond.


If you only want to know the number of the frags after a delete, use the getFragCount method, or if you want to know the new frags, use the getFragIds method.


Best regards,
Mate 

User 55ffa2f197

08-08-2013 12:31:27

would you consider this 'changing' of the bond idx as an imperfect implementation of the removeBond method? Or it might have been by desgin.


removeBond(molbond) would work, and it generates the frags i know, but in order to track down which frag comes from which 'cut', i need to inpect each frag to find the hard atom invovled the 'cut', would each frament still have the original atom index before the cut ?  I will try to see if it is so, also would these fragments are molecules, i know convertToFrags() can change all frags into molecules, but i would assume the molecules in Molecule[] would have a new set of atom index, so i cannot use them to trace their origine ....


It gets messy here, i still doubt i have the best /simple approach, essentially i know all atom indexes i like to extract from molecule, is there other way to crop these atoms, and form a new molecule .... instead of cuting approach ... i am not familar with other methofs in cxn API, i would assume there should be other methofs in some classes ...


I will continue on with my experiment, meanwhile really appreciate fresh new idea.


Thanks


Dong

ChemAxon 712bc8fcf4

08-08-2013 13:13:18

Maybe this code helps to you


 for (MolBond bond : bonds) {
MolAtom a1 = bond.getAtom1();
MolAtom a2 = bond.getAtom2();
mol.removeBond(bond);
int[] ids = mol.getFragIds(MoleculeGraph.FRAG_BASIC);
if (ids[mol.indexOf(a1)] != ids[mol.indexOf(a2)]) {
SelectionMolecule frag1 = new SelectionMolecule();
SelectionMolecule frag2 = new SelectionMolecule();
mol.findFragById(ids[mol.indexOf(a1)], MoleculeGraph.FRAG_BASIC, frag1);
mol.findFragById(ids[mol.indexOf(a2)], MoleculeGraph.FRAG_BASIC, frag2);
}
}


frag1 and frag2 will contains the new fragments, by using SelectionMolecule the fragmentation does not delete the atoms from the original molecule.


Mate

User 55ffa2f197

08-08-2013 13:21:52

i tried following;  breaking bonds by bond ref, and convert the frags to molecules, i am right each frag as new molecule with new identity, so there is no way to use them trace the cut. I checked on the getFrag related methos could not find any method that reutrn the frag as molecule ,,,, i am not surpried since the convertToFrags is what to be used, looks like l do need other alternative, any idea how ....


 


for (MolBond b: bond2Break){
molecule.removeBond(b);
}
for (Molecule m: molecule.convertToFrags()){
List<MolAtom> alist = m.getAtomReferenceList();
for (MolAtom atom: alist){
System.out.println(m.indexOf(atom));
}
}


 


 

ChemAxon 712bc8fcf4

08-08-2013 13:36:01

You are right, in the fragments the atoms have different indices. Why can't you trace by reference instead of the index?

User 55ffa2f197

08-08-2013 13:55:48

would the atom reference from orig mol be carried into frags gnereated through converToFrags?


Your suggestion using SelectionMolecule might work, did not quite understand the nature of the frag ids[] before, thanks

ChemAxon 712bc8fcf4

08-08-2013 14:09:11

yes the references will be the same if you use the convertToFrags method. After you can use the Molecule.contains(MolAtom) method to trace the atoms.

User 55ffa2f197

08-08-2013 17:08:55

Following works great, thanks, should also try the SelectionMolecule ... well another time


for (MolBond b: bond2Break){
molecule.removeBond(b);
}
Molecule[] mfrags = molecule.convertToFrags();
for (MolAtom oAtom: origineTrace.keySet()){
 for ( Molecule fmol: mfrags ){
  if (fmol.contains(origineTrace.get(oAtom))){
   System.out.println(fmol.toFormat("smiles"));


break;
  }
 }
}