Merge molecules

User b22f714996

02-05-2005 08:29:36

Hi...





I have (once again) a very short and probably simple question.





I would like to combine to molecules. So I have a Molecule object mol_1 and a Molecule object mol_2 and I would put them together in a new Molecule object and join atoms of them with a bond. I have to mention that mol_1 and mol_2 are chiral.


My first shot was just by creating a new Molecule and adding the atoms and the bonds from mol_1 and afterwards the atoms and bonds from mol_2 to the new Molecule.


This works, but I am loosing the chirality by this procedure...


Any idea why and how I could fix this?





Thanks a lot in advance....





tobias

ChemAxon fb166edcbd

03-05-2005 01:26:12

A simple way to merge two molecules is to call





CGraph.fuse(CGraph graph)



You can either fuse the second molecule to the first one:


Code:



mol1.fuse(mol2);





or else you can fuse both to an empty molecule:


Code:



mol.fuse(mol1);


mol.fuse(mol2);








Unfortunately the chirality-preserving problem is not as simple as it seems if you connect chiral atoms, since their parities may change. To check this, you should call





MolAtom.isSameParityClass(int i1, int i2, int i3, int i4, int j1, int j2, int j3, int j4)
with the old and the corresponding new ligand indexes. If same parity class then you should set the original parity (to be on the safe side), otherwise you should set the opposite parity. The good news is that you do not have to bother with chiral atoms whose neighbours have not changed.





To get and set the parity of an atom, call





MoleculeGraph.getParity(int i)
and





MoleculeGraph.setParity(int i, int p)
, or if you connect more atoms and need to set more parities then it is more effective to set all parities in a single call to


)]


MoleculeGraph.setParity(int[] p)
.





I attach an example program that merges two molecules and connects them at two given atoms. Usage:


Code:



java MergeTest <mol1> <mol2> <atom1> <atom2>





where mol1 and mol2 are the two molecule files, atom1 and atom2 are the 1-based atom indexes to be connected (atom1 in mol1, atom2 in mol2). The 1-based atom indexes are more user-friendly since msketch/mview display 1-based indexes. The test program converts the indexes to 0-based.


The program writes the result molecule to System.out.





Examples:





connect non-chiral atoms:


Code:



java MergeTest m1.mol m2.mol 10 1








connect two chiral atoms:


Code:



java MergeTest m1.mol m2.mol 6 3








connect a chiral and a non-chiral atom:


Code:



java MergeTest m1.mol m2.mol 2 6