User 870ab5b546
17-09-2010 17:22:04
The code:
private MolSearch setupSearchObject(int ignoreFlags) {
final String SELF = "MechSubstructSearch.setupSearchObject: ";
final MolSearchOptions searchOpts = new MolSearchOptions();
searchOpts.setSearchType(SUBSTRUCTURE);
searchOpts.setOrderSensitiveSearch(true);
debugPrint(SELF + "search type == SUBSTRUCTURE, ordersensitive = true");
if ((ignoreFlags & CHARGE_MASK) == 0) {
debugPrint(SELF + "exact charge matching set for search.");
searchOpts.setChargeMatching(CHARGE_MATCHING_EXACT);
}
if ((ignoreFlags & ISOTOPES_MASK) == 0) {
debugPrint(SELF + "exact isotope matching set for search.");
searchOpts.setIsotopeMatching(ISOTOPE_MATCHING_EXACT);
}
if ((ignoreFlags & RADSTATE_MASK) == 0) {
debugPrint(SELF + "exact radical matching set for search.");
searchOpts.setRadicalMatching(RADICAL_MATCHING_EXACT);
}
final MolSearch searchObj = new MolSearch();
searchObj.setSearchOptions(searchOpts);
searchObj.setQuery(authMolecule);
searchObj.setTarget(stageMolecule);
try {
debugPrint(SELF + "query = ", authMolecule, ", target = ",
stageMolecule, ", searchObj.isMatching() = ",
searchObj.isMatching());
} catch (SearchException e) { ; }
return searchObj;
} // setupSearchObject(int)
The target:
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14"
elementType="O C C C C C C H H H H H H H"
formalCharge="0 0 0 0 0 1 0 0 0 0 0 0 0 0"
x2="-7.074375152587891 -8.40804449363615 -8.40804449363615 -7.074375152587891 -5.740705811539632 -5.740705811539632 -9.74172850577338 -9.74172850577338 -7.074375152587891 -4.4070217994024015 -4.4070217994024015 -10.511720035447272 -11.075412517910612 -8.971736976099491"
y2="1.4919088823101738 0.7218919417511334 -0.8181419393669476 -1.588158879925988 -0.8181419393669476 0.7218919417511334 -1.5881334690408386 1.4918834714250244 -3.128158879925988 -1.5881334690408386 1.4918834714250244 -0.25444945690360754 -2.3581249987147292 -2.9218174811780697"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a1 a6" order="1" />
<bond atomRefs2="a2 a3" order="2" />
<bond atomRefs2="a3 a4" order="1" />
<bond atomRefs2="a3 a7" order="1" />
<bond atomRefs2="a4 a5" order="2" />
<bond atomRefs2="a5 a6" order="1" />
<bond atomRefs2="a2 a8" order="1" />
<bond atomRefs2="a4 a9" order="1" />
<bond atomRefs2="a5 a10" order="1" />
<bond atomRefs2="a6 a11" order="1" />
<bond atomRefs2="a7 a12" order="1" />
<bond atomRefs2="a7 a13" order="1" />
<bond atomRefs2="a7 a14" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MEFlow id="o2" arcAngle="-254.995522631729" headSkip="0.15"
headLength="0.5" headWidth="0.4" tailSkip="0.25">
<MEFlowBasePoint atomRef="m1.a1" />
<MAtomSetPoint atomRefs="m1.a1 m1.a2" />
</MEFlow>
<MEFlow id="o3" arcAngle="189.9" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a2 m1.a3" />
<MAtomSetPoint atomRefs="m1.a3 m1.a4" />
</MEFlow>
<MEFlow id="o4" arcAngle="189.9" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a4 m1.a5" />
<MAtomSetPoint atomRefs="m1.a5 m1.a6" />
</MEFlow>
</MDocument>
</cml>
With the following query, I correctly get a substructure match:
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6"
elementType="O C C C C C"
formalCharge="0 0 0 0 0 1"
x2="-7.074375152587891 -8.40804449363615 -8.40804449363615 -7.074375152587891 -5.740705811539632 -5.740705811539632"
y2="1.4919088823101738 0.7218919417511334 -0.8181419393669476 -1.588158879925988 -0.8181419393669476 0.7218919417511334"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="2" />
<bond atomRefs2="a3 a4" order="1" />
<bond atomRefs2="a4 a5" order="2" />
<bond atomRefs2="a5 a6" order="1" />
<bond atomRefs2="a1 a6" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MEFlow id="o2" arcAngle="-254.995522631729" headSkip="0.15"
headLength="0.5" headWidth="0.4" tailSkip="0.25">
<MEFlowBasePoint atomRef="m1.a1" />
<MAtomSetPoint atomRefs="m1.a1 m1.a2" />
</MEFlow>
<MEFlow id="o3" arcAngle="189.9" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a2 m1.a3" />
<MAtomSetPoint atomRefs="m1.a3 m1.a4" />
</MEFlow>
<MEFlow id="o4" arcAngle="189.9" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a4 m1.a5" />
<MAtomSetPoint atomRefs="m1.a5 m1.a6" />
</MEFlow>
</MDocument>
</cml>
MechSubstructSearch.setupSearchObject: search type == SUBSTRUCTURE, ordersensitive = true
MechSubstructSearch.setupSearchObject: exact charge matching set for search.
MechSubstructSearch.setupSearchObject: query = [CH+]1OC=CC=C1, target = [H][C+]1OC([H])=C(C([H])=C1[H])C([H])([H])[H], searchObj.isMatching() = true
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7"
elementType="O C C C C C C"
formalCharge="0 0 0 0 0 1 0"
x2="-7.074375152587891 -8.40804449363615 -8.40804449363615 -7.074375152587891 -5.740705811539632 -5.740705811539632 -9.74172850577338"
y2="1.4919088823101738 0.7218919417511334 -0.8181419393669476 -1.588158879925988 -0.8181419393669476 0.7218919417511334 -1.5881334690408386"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="2" />
<bond atomRefs2="a3 a4" order="1" />
<bond atomRefs2="a4 a5" order="2" />
<bond atomRefs2="a5 a6" order="1" />
<bond atomRefs2="a1 a6" order="1" />
<bond atomRefs2="a3 a7" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MEFlow id="o2" arcAngle="-254.995522631729" headSkip="0.15"
headLength="0.5" headWidth="0.4" tailSkip="0.25">
<MEFlowBasePoint atomRef="m1.a1" />
<MAtomSetPoint atomRefs="m1.a1 m1.a2" />
</MEFlow>
<MEFlow id="o3" arcAngle="189.9" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a2 m1.a3" />
<MAtomSetPoint atomRefs="m1.a3 m1.a4" />
</MEFlow>
<MEFlow id="o4" arcAngle="189.9" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a4 m1.a5" />
<MAtomSetPoint atomRefs="m1.a5 m1.a6" />
</MEFlow>
</MDocument>
</cml>MechSubstructSearch.setupSearchObject: search type == SUBSTRUCTURE, ordersensitive = true
MechSubstructSearch.setupSearchObject: exact charge matching set for search.
MechSubstructSearch.setupSearchObject: query = CC1=CO[CH+]C=C1, target = [H][C+]1OC([H])=C(C([H])=C1[H])C([H])([H])[H], searchObj.isMatching() = false
I cannot for the life of me figure out why the second search fails and the first does not. Furthermore, if I paste these two structures in my JChem comparator here, the match succeeds.
Any ideas what is going on? The unpredictability is quite disturbing.
I get this behavior whether I use findFirst() or isMatching(). I get the same behavior in JChem5.3.3 and JChem 5.3.8pre.