Commit
Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ | |
import org.openscience.cdk.smsd.filters.ChemicalFilters; | ||
import org.openscience.cdk.smsd.global.BondType; | ||
import org.openscience.cdk.smsd.global.TimeOut; | ||
import org.openscience.cdk.smsd.helper.MolHandler; | ||
import org.openscience.cdk.smsd.tools.MolHandler; | ||
import org.openscience.cdk.smsd.interfaces.Algorithm; | ||
import org.openscience.cdk.smsd.interfaces.AbstractMCS; | ||
import org.openscience.cdk.tools.ILoggingTool; | ||
|
@@ -186,8 +186,6 @@ private synchronized void cdkMCSAlgorithm() { | |
firstAtomMCS.putAll(mcs.getFirstAtomMapping()); | ||
allAtomMCS.addAll(mcs.getAllAtomMapping()); | ||
|
||
|
||
|
||
} | ||
|
||
private synchronized void mcsPlusAlgorithm() { | ||
|
@@ -289,11 +287,7 @@ private boolean isBondMatch(IAtomContainer Reactant, IAtomContainer Product) { | |
} | ||
|
||
private void defaultAlgorithm() { | ||
if (BondType.getInstance().isBondSensitive()) { | ||
cdkMCSAlgorithm(); | ||
} else { | ||
mcsPlusAlgorithm(); | ||
} | ||
cdkMCSAlgorithm(); | ||
This comment has been minimized.
Sorry, something went wrong.
egonw
Member
|
||
if (isTimeOut() || getFirstAtomMapping() == null) { | ||
vfLibMCS(); | ||
} | ||
|
@@ -514,20 +508,21 @@ public double getTanimotoSimilarity() throws IOException { | |
int decimalPlaces = 4; | ||
int rAtomCount = 0; | ||
int pAtomCount = 0; | ||
double tanimoto = 0.0; | ||
if (!removeHydrogen) { | ||
rAtomCount = rMol.getMolecule().getAtomCount(); | ||
pAtomCount = pMol.getMolecule().getAtomCount(); | ||
} else { | ||
rAtomCount = rMol.getMolecule().getAtomCount() - getHCount(rMol.getMolecule()); | ||
pAtomCount = pMol.getMolecule().getAtomCount() - getHCount(pMol.getMolecule()); | ||
} | ||
double matchCount = getFirstMapping().size(); | ||
double tanimoto = (matchCount) / (rAtomCount + pAtomCount - matchCount); | ||
|
||
BigDecimal tan = new BigDecimal(tanimoto); | ||
|
||
tan = tan.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); | ||
tanimoto = tan.doubleValue(); | ||
if (getFirstMapping() != null || !getFirstMapping().isEmpty()) { | ||
double matchCount = getFirstMapping().size(); | ||
tanimoto = (matchCount) / (rAtomCount + pAtomCount - matchCount); | ||
BigDecimal tan = new BigDecimal(tanimoto); | ||
tan = tan.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); | ||
tanimoto = tan.doubleValue(); | ||
} | ||
return tanimoto; | ||
} | ||
|
||
|
@@ -610,26 +605,30 @@ public double getEuclideanDistance() throws IOException { | |
int decimalPlaces = 4; | ||
double source = 0; | ||
double target = 0; | ||
double euclidean = -1; | ||
if (!removeHydrogen) { | ||
source = rMol.getMolecule().getAtomCount(); | ||
target = pMol.getMolecule().getAtomCount(); | ||
} else { | ||
source = rMol.getMolecule().getAtomCount() - getHCount(rMol.getMolecule()); | ||
target = pMol.getMolecule().getAtomCount() - getHCount(pMol.getMolecule()); | ||
} | ||
double common = getFirstMapping().size(); | ||
double euclidean = Math.sqrt(source + target - 2 * common); | ||
|
||
BigDecimal dist = new BigDecimal(euclidean); | ||
dist = dist.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); | ||
euclidean = dist.doubleValue(); | ||
if (getFirstMapping() != null || !getFirstMapping().isEmpty()) { | ||
double common = getFirstMapping().size(); | ||
euclidean = Math.sqrt(source + target - 2 * common); | ||
BigDecimal dist = new BigDecimal(euclidean); | ||
dist = dist.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); | ||
euclidean = dist.doubleValue(); | ||
} | ||
return euclidean; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @return the bondSensitiveTimeOut | ||
*/ | ||
@Override | ||
public double getBondSensitiveTimeOut() { | ||
return bondSensitiveTimeOut; | ||
} | ||
|
@@ -638,6 +637,7 @@ public double getBondSensitiveTimeOut() { | |
* {@inheritDoc} | ||
* @param bondSensitiveTimeOut the bond Sensitive Timeout in mins (default 0.15 min) | ||
*/ | ||
@Override | ||
public void setBondSensitiveTimeOut(double bondSensitiveTimeOut) { | ||
this.bondSensitiveTimeOut = bondSensitiveTimeOut; | ||
} | ||
|
@@ -646,6 +646,7 @@ public void setBondSensitiveTimeOut(double bondSensitiveTimeOut) { | |
* {@inheritDoc} | ||
* @return the bondInSensitiveTimeOut | ||
*/ | ||
@Override | ||
public double getBondInSensitiveTimeOut() { | ||
return bondInSensitiveTimeOut; | ||
} | ||
|
@@ -654,6 +655,7 @@ public double getBondInSensitiveTimeOut() { | |
* {@inheritDoc} | ||
* @param bondInSensitiveTimeOut the bond insensitive Timeout in mins (default 0.15 min) | ||
*/ | ||
@Override | ||
public void setBondInSensitiveTimeOut(double bondInSensitiveTimeOut) { | ||
this.bondInSensitiveTimeOut = bondInSensitiveTimeOut; | ||
} | ||
|
4 comments
on commit 370a926
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asad, it is of utmost importance that you file bug report, that you cannot fix the same day. Or, if it has such an impact as the index bug seems to have, file it always. People need to know that they need to upgrade to the next version, if they use your SMSD code (and I know some are).
For these bugs, you must also add unit tests that shows at least one situation when the bug happens. And please annotate that unit test with "@cdk.bug XXXXX" then. It is really important to disclose these things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your point is valid but I was waiting for the commits. I will file the bug report right away!
Thanks for -> ... "@cdk.bug XXXXX"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just filed the bug report. cdk.bug 3021679
Could you please add this to the MCSPlus module and then I will pull the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I do not have time for that now.
The @cdk.bug annotation goes on the test... check the existing source code; there is plenty of use of it.
Consider using the ILoggingTool functionality:
logger.debug"(VEC SIZE ", vec_size);