Created
April 26, 2010 18:52
-
-
Save asad/379726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); | |
// Benzene | |
IAtomContainer A1 = sp.parseSmiles("C1=CC=CC=C1"); | |
// Napthalene | |
IAtomContainer A2 = sp.parseSmiles("C1=CC2=C(C=C1)C=CC=C2"); | |
//Turbo mode search | |
//Bond Sensitive is set true | |
SMSD comparison = new SMSD(Algorithm.SubStructure, true); | |
// set molecules and remove hydrogens | |
comparison.init(A1, A2, true); | |
// set chemical filter true | |
comparison.setChemFilters(false, false, false); | |
if (comparison.isSubgraph()) { | |
//Get similarity score | |
System.out.println("Tanimoto coefficient: " + comparison.getTanimotoSimilarity()); | |
System.out.println("A1 is a subgraph of A2: " + comparison.isSubgraph()); | |
//Get Modified AtomContainer | |
IAtomContainer Mol1 = comparison.getReactantMolecule(); | |
IAtomContainer Mol2 = comparison.getProductMolecule(); | |
// Print the mapping between molecules | |
System.out.println(" Mappings: "); | |
for (Map.Entry mapping : comparison.getFirstMapping().entrySet()) { | |
System.out.println((mapping.getKey() + 1) + " " + (mapping.getValue() + 1)); | |
IAtom eAtom = Mol1.getAtom(mapping.getKey()); | |
IAtom pAtom = Mol2.getAtom(mapping.getValue()); | |
System.out.println(eAtom.getSymbol() + " " + pAtom.getSymbol()); | |
} | |
System.out.println(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment