Skip to content

Commit

Permalink
Updated the SMSD code for turbo mode substructure search Refactored t…
Browse files Browse the repository at this point in the history
…he SMSD class itself

Signed-off-by: Syed Asad Rahman <s9asad@gmail.com>
Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
  • Loading branch information
asad authored and rajarshi committed May 17, 2010
1 parent 9cbc242 commit f5ccf1b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 314 deletions.
271 changes: 0 additions & 271 deletions src/main/org/openscience/cdk/smsd/SMSD.java
Expand Up @@ -22,16 +22,7 @@
*/
package org.openscience.cdk.smsd;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.smsd.factory.SubStructureSearchAlgorithms;
import org.openscience.cdk.smsd.interfaces.AbstractMCS;
import org.openscience.cdk.smsd.interfaces.Algorithm;
Expand Down Expand Up @@ -142,10 +133,6 @@
@TestClass("org.openscience.cdk.smsd.SMSDTest")
public class SMSD extends SubStructureSearchAlgorithms {

private final static ILoggingTool logger =
LoggingToolFactory.createLoggingTool(SMSD.class);
private AbstractMCS comparison = null;

/**
* Algorithm {@link org.openscience.cdk.smsd.interfaces.Algorithm}
* choice for find MCS or performing substructure searches
Expand All @@ -168,263 +155,5 @@ public class SMSD extends SubStructureSearchAlgorithms {
*/
public SMSD(Algorithm algorithmType, boolean bondSensitiveFlag) {
super(algorithmType, bondSensitiveFlag);
comparison = new SubStructureSearchAlgorithms(algorithmType, bondSensitiveFlag);
}

/** {@inheritDoc}
*
* initialize query and target molecules
* @param Query query molecule
* @param Target target molecule
*/
@Override
@TestMethod("testInit_3args_1")
public synchronized void init(IMolecule Query, IMolecule Target, boolean removeHydrogen) {

if (Query.getAtomCount() > 0 && Target.getAtomCount() > 0) {
try {
getComparison().init(Query, Target, removeHydrogen);
} catch (CDKException ex) {
logger.error(Level.SEVERE, null, ex);
}
} else {
try {
throw new CDKException("Each molecule should have atleast one atom to compare");
} catch (CDKException ex) {
logger.error(Level.SEVERE, null, ex);
}
}
}

/** {@inheritDoc}
*
* initialize query and target molecules
* @param Query Atomcontainer
* @param Target Atomcontainer
*/
@Override
@TestMethod("testInit_3args_2")
public synchronized void init(IAtomContainer Query, IAtomContainer Target, boolean removeHydrogen) {

if (Query.getAtomCount() > 0 && Target.getAtomCount() > 0) {
try {
getComparison().init(Query, Target, removeHydrogen);
} catch (CDKException ex) {
logger.error(Level.SEVERE, null, ex);
}
} else {
try {
throw new CDKException("Each molecule should have atleast one atom to compare");
} catch (CDKException ex) {
logger.error(Level.SEVERE, null, ex);
}
}
}

/** {@inheritDoc}
*
* These are important set of paraments which will refine and rank the
* mcs solutions. The precedence of stereoFilter > fragmentFilter > energyFilter
* @param stereoFilter true if stereo match is considered else false
* @param fragmentFilter true if fragement filter is switched on else false
* @param energyFilter true if bond energy filter is switched on else false
*/
@Override
@TestMethod("testSetChemFilters")
public void setChemFilters(boolean stereoFilter, boolean fragmentFilter, boolean energyFilter) {
getComparison().setChemFilters(stereoFilter, fragmentFilter, energyFilter);
}

/** {@inheritDoc}
*
* Returns all plausible mappings between query and target molecules
* Each map in the list has atom-atom equivalence of the mappings
* between query and target molecule i.e. map.getKey() for the query
* and map.getValue() for the target molecule
* @return A List of all possible mapped MCS atoms.
*
*/
@Override
@TestMethod("testGetAllAtomMapping")
public List<Map<IAtom, IAtom>> getAllAtomMapping() {
return getComparison().getAllAtomMapping();
}

/** {@inheritDoc}
(*
* Returns all plausible mappings between query and target molecules
* Each map in the list has atom-atom equivalence index of the mappings
* between query and target molecule i.e. map.getKey() for the query
* and map.getValue() for the target molecule
* @return A List of all possible mapped MCS atom index.
*
*/
@Override
@TestMethod("testGetAllMapping")
public List<Map<Integer, Integer>> getAllMapping() {
return getComparison().getAllMapping();
}

/** {@inheritDoc}
*
* Returns one of the best matches with atoms mapped
* @return One of the best MCS solution(s) atoms
*
*/
@Override
@TestMethod("testGetFirstAtomMapping")
public Map<IAtom, IAtom> getFirstAtomMapping() {
return getComparison().getFirstAtomMapping();
}

/** {@inheritDoc}
*
* Returns one of the best matches with atom indexes mapped
* @return One of the best MCS solution(s) index
*/
@Override
@TestMethod("testGetFirstMapping")
public Map<Integer, Integer> getFirstMapping() {
return getComparison().getFirstMapping();
}

/** {@inheritDoc}
*
* Returns a number which denotes the quality of the mcs.
* A solution with highest stereo score is preferred over other
* scores
* @param Key position
* @return Stereo matching score for the mapped part
*
*/
@Override
@TestMethod("testGetStereoScore")
public Integer getStereoScore(int Key) {
return getComparison().getStereoScore(Key);
}

/** {@inheritDoc}
*
* Returns number of fragment generated in the solution space,
* if the MCS is removed from the target and query graph.
* Amongst the solutions, a solution with lowest fragment size
* is preferred
*
* @param Key position
* @return Fragment count(s) generated after removing the mapped parts
*
*/
@Override
@TestMethod("testGetFragmentSize")
public Integer getFragmentSize(int Key) {
return getComparison().getFragmentSize(Key);
}

/** {@inheritDoc}
*
* Returns summation energy score of the disorder if the MCS is removed
* from the target and query graph. Amongst the solutions, a solution
* with lowest energy score is preferred
*
* @param Key position
* @return Total bond breaking energy required to remove the mapped part
*
*/
@Override
@TestMethod("testGetEnergyScore")
public Double getEnergyScore(int Key) {
return getComparison().getEnergyScore(Key);
}

/** {@inheritDoc}
*
* Returns modified query molecule on which mapping was
* performed
* @return Query Molecule AtomContainer
*/
@Override
@TestMethod("testGetReactantMolecule")
public IAtomContainer getReactantMolecule() {
return getComparison().getReactantMolecule();
}

/** {@inheritDoc}
*
* Returns modified target molecule on which mapping was
* performed
* @return Target Molecule AtomContainer
*/
@Override
@TestMethod("testGetProductMolecule")
public IAtomContainer getProductMolecule() {
return getComparison().getProductMolecule();
}

/** {@inheritDoc}
*
* Returns Tanimoto similarity between query and target molecules
* (Score is between 0-min and 1-max)
* @return Tanimoto similarity between query and target molecules
* @throws java.io.IOException
*/
@Override
@TestMethod("testGetTanimotoSimilarity")
public double getTanimotoSimilarity() throws IOException {
return getComparison().getTanimotoSimilarity();
}

/** {@inheritDoc}
*
*
* @return true if no stereo mismatch occurs
* else false if stereo mismatch occurs
*/
@Override
@TestMethod("testIsStereoMisMatch")
public boolean isStereoMisMatch() {
return getComparison().isStereoMisMatch();
}

/** {@inheritDoc}
*
* Checks if query is a subgraph of the target
* @return true if query is a subgraph of the target
* else false
*/
@Override
@TestMethod("testIsSubgraph")
public boolean isSubgraph() {
return getComparison().isSubgraph();

}

/** {@inheritDoc}
*
* Returns Euclidean Distance between query and target molecule
* @return Euclidean Distance between query and target molecule
* @throws IOException
*/
@Override
@TestMethod("testGetEuclideanDistance")
public double getEuclideanDistance() throws IOException {
return getComparison().getEuclideanDistance();
}

/**
* Returns algorithm class instance in process
* @return the comparison
*/
@TestMethod("testGetComparison")
public AbstractMCS getComparison() {
return comparison;
}

/**
* Sets algorithm class initiated for search process
* @param comparison the comparison to set
*/
@TestMethod("testSetComparison")
public void setComparison(AbstractMCS comparison) {
this.comparison = comparison;
}
}

0 comments on commit f5ccf1b

Please sign in to comment.