Tags

, , , , , , , ,

Lately, an interesting question was posed to me.

How can I join two molecules?

Well for many of us this might be a regular exercise on a chemical editor but this is a little trickier to program. So mathematically, we are aiming for a union between two molecules. The union between two molecules can be defined as (A ∪ B) = n(A) + n(B) – (A ∩ B), where A is a query molecule and B is the target molecule. The intersection (A ∩ B) can be obtained by finding isomorphism between two molecules. The joining part is a little challenging as not all combination(s) might be chemically valid. So we need to find combination(s) which are unique and unsaturated!

Here is a little snippet to perform this task in Java using the SMSD and CDK.

You can download the java source UnionMolecule and java executable Union.jar.

Union between query and target molecule

Union between query and target molecules

Usage example:

java -jar Union.jar "OOC1=CC=CC=C1" "c1ccc(cc1)c2ccccc2"

Results:

------------- Combination 1--------------------
Query SMILES OOC1=CC=CC=C1, count 8
Target SMILES c1ccc(cc1)c2ccccc2, count 12
Union SMILES OOc1ccccc1c2ccccc2, count 14

------------- Combination 2--------------------
Query SMILES OOC1=CC=CC=C1, count 8
Target SMILES c1ccc(cc1)c2ccccc2, count 12
Union SMILES OOc1cccc(c1)c2ccccc2, count 14

------------- Combination 3--------------------
Query SMILES OOC1=CC=CC=C1, count 8
Target SMILES c1ccc(cc1)c2ccccc2, count 12
Union SMILES OOc1ccc(cc1)c2ccccc2, count 14