public static bool MoleculeComparisonTest(string mol1, string mol2) { bool blStatus = false; try { string testMol1 = @" ACCLDraw01081514282D 22 23 0 0 0 0 0 0 0 0999 V2000 8.7283 -2.9723 0.0000 C 0 0 0 0 0 0 0 0 0 8 0 0 5.6037 -2.9121 0.0000 C 0 0 0 0 0 0 0 0 0 11 0 0 6.7270 -2.5471 0.0000 O 0 0 0 0 0 0 0 0 0 10 0 0 7.6048 -3.3374 0.0000 C 0 0 0 0 0 0 0 0 0 9 0 0 5.9904 -6.0131 0.0000 C 0 0 0 0 0 0 0 0 0 14 0 0 6.2360 -4.8578 0.0000 O 0 0 0 0 0 0 0 0 0 13 0 0 7.3593 -4.4927 0.0000 C 0 0 0 0 0 0 0 0 0 12 0 0 8.8692 -7.2288 0.0000 C 0 0 0 0 0 0 0 0 0 17 0 0 7.9915 -6.4384 0.0000 O 0 0 0 0 0 0 0 0 0 16 0 0 8.2371 -5.2831 0.0000 C 0 0 0 0 0 0 0 0 0 15 0 0 9.3604 -4.9180 0.0000 C 0 0 0 0 0 0 0 0 0 18 0 0 9.6059 -3.7626 0.0000 C 0 0 0 0 0 0 0 0 0 7 0 0 12.2755 -2.2744 0.0000 N 0 0 0 0 0 0 0 0 0 4 0 0 11.0943 -2.2744 0.0000 N 0 0 0 0 0 0 0 0 0 5 0 0 10.7293 -3.3978 0.0000 C 0 0 0 0 0 0 0 0 0 6 0 0 11.6848 -4.0921 0.0000 N 0 0 3 0 0 0 0 0 0 1 0 0 12.6405 -3.3978 0.0000 C 0 0 0 0 0 0 0 0 0 2 0 0 13.7638 -3.7626 0.0000 S 0 0 0 0 0 0 0 0 0 3 0 0 14.6416 -2.9723 0.0000 C 0 0 0 0 0 0 0 0 0 20 0 0 16.0106 -4.4927 0.0000 O 0 0 0 0 0 0 0 0 0 22 0 0 15.7649 -3.3374 0.0000 C 0 0 0 0 0 0 0 0 0 21 0 0 16.6427 -2.5471 0.0000 O 0 0 0 0 0 0 0 0 0 23 0 0 12 1 1 0 0 0 2 1 4 2 0 0 0 2 3 2 1 0 0 0 2 4 3 1 0 0 0 2 4 7 1 0 0 0 2 6 5 1 0 0 0 2 7 6 1 0 0 0 2 7 10 2 0 0 0 2 9 8 1 0 0 0 2 10 9 1 0 0 0 2 10 11 1 0 0 0 2 11 12 2 0 0 0 2 15 12 1 0 0 0 2 17 13 2 0 0 0 8 13 14 1 0 0 0 8 14 15 2 0 0 0 8 15 16 1 0 0 0 8 16 17 1 0 0 0 8 17 18 1 0 0 0 8 18 19 1 0 0 0 4 19 21 1 0 0 0 2 21 20 2 0 0 0 2 21 22 1 0 0 0 2 M END "; string testMol2 = @" ACCLDraw01081514312D 21 22 0 0 0 0 0 0 0 0999 V2000 9.0242 -4.6483 0.0000 N 0 0 0 0 0 0 0 0 0 9 0 0 10.2054 -4.6483 0.0000 N 0 0 3 0 0 0 0 0 0 8 0 0 14.5726 -4.9211 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 13.9404 -6.8668 0.0000 O 0 0 0 0 0 0 0 0 0 6 0 0 13.6947 -5.7114 0.0000 C 0 0 0 0 0 0 0 0 0 5 0 0 12.5714 -5.3464 0.0000 C 0 0 0 0 0 0 0 0 0 4 0 0 11.6936 -6.1367 0.0000 S 0 0 0 0 0 0 0 0 0 3 0 0 10.5703 -5.7718 0.0000 C 0 0 0 0 0 0 0 0 0 2 0 0 9.6148 -6.4660 0.0000 N 0 0 0 0 0 0 0 0 0 1 0 0 8.6592 -5.7718 0.0000 C 0 0 0 0 0 0 0 0 0 10 0 0 6.6580 -5.3464 0.0000 C 0 0 0 0 0 0 0 0 0 12 0 0 7.5359 -6.1367 0.0000 C 0 0 0 0 0 0 0 0 0 11 0 0 7.2902 -7.2921 0.0000 C 0 0 0 0 0 0 0 0 0 22 0 0 5.9214 -8.8123 0.0000 O 0 0 0 0 0 0 0 0 0 20 0 0 6.1669 -7.6571 0.0000 C 0 0 0 0 0 0 0 0 0 19 0 0 3.9203 -8.3871 0.0000 C 0 0 0 0 0 0 0 0 0 18 0 0 4.1658 -7.2317 0.0000 O 0 0 0 0 0 0 0 0 0 17 0 0 5.2891 -6.8666 0.0000 C 0 0 0 0 0 0 0 0 0 16 0 0 5.5347 -5.7114 0.0000 C 0 0 0 0 0 0 0 0 0 13 0 0 4.6570 -4.9211 0.0000 O 0 0 0 0 0 0 0 0 0 14 0 0 3.5336 -5.2860 0.0000 C 0 0 0 0 0 0 0 0 0 15 0 0 10 1 2 0 0 0 2 1 2 1 0 0 0 2 2 8 1 0 0 0 2 5 3 1 0 0 0 4 5 4 2 0 0 0 2 6 5 1 0 0 0 2 7 6 1 0 0 0 2 8 7 1 0 0 0 2 8 9 2 0 0 0 2 9 10 1 0 0 0 2 10 12 1 0 0 0 2 11 19 2 0 0 0 2 12 11 1 0 0 0 2 13 12 2 0 0 0 2 15 13 1 0 0 0 2 15 14 1 0 0 0 2 18 15 2 0 0 0 2 17 16 1 0 0 0 2 18 17 1 0 0 0 2 19 18 1 0 0 0 2 19 20 1 0 0 0 2 20 21 1 0 0 0 2 M END "; Molecule Molecule1 = MolImporter.importMol(testMol1); Molecule Molecule2 = MolImporter.importMol(testMol2); MolSearch s = new MolSearch(); s.setQuery(Molecule1); s.setTarget(Molecule2); if (s.isMatching()) { } } catch (Exception) { throw; } return(blStatus); }
private static bool CompareProductsAndReactantsInTables(DataTable productData, DataTable reactantData) { bool blStatus = true; try { int productsCnt = 0; int reactantsCnt = 0; RxnMolecule prodRxnMolecule = null; RxnMolecule rctRxnMolecule = null; Molecule molReactant = null; Molecule molProduct = null; MolSearch srchMol = new MolSearch(); MolSearchOptions so = new MolSearchOptions();//SearchConstants.DUPLICATE so.setQueryAbsoluteStereo(true); so.setChargeMatching(SearchConstants.__Fields.CHARGE_MATCHING_EXACT); so.setDoubleBondStereoMatchingMode(StereoConstants.__Fields.DBS_ALL); so.setImplicitHMatching(SearchConstants.__Fields.IMPLICIT_H_MATCHING_ENABLED); so.setExactBondMatching(true); so.setStereoSearchType(SearchConstants.__Fields.STEREO_EXACT); so.setTautomerSearch(true); so.setAttachedDataMatch(1); so.setOrderSensitiveSearch(true); so.setSearchType(5); srchMol.setSearchOptions(so); string rctInchi = ""; string prodInchi = ""; for (int prIndx = 0; prIndx < productData.Rows.Count; prIndx++) { if (!string.IsNullOrEmpty(productData.Rows[prIndx]["REACTION_SCHEME"].ToString())) { prodRxnMolecule = RxnMolecule.getReaction(MolImporter.importMol(productData.Rows[prIndx]["REACTION_SCHEME"].ToString())); productsCnt = prodRxnMolecule.getProductCount(); } for (int rctIndx = 0; rctIndx < reactantData.Rows.Count; rctIndx++) { if (!string.IsNullOrEmpty(reactantData.Rows[rctIndx]["REACTION_SCHEME"].ToString())) { rctRxnMolecule = RxnMolecule.getReaction(MolImporter.importMol(reactantData.Rows[rctIndx]["REACTION_SCHEME"].ToString())); reactantsCnt = rctRxnMolecule.getReactantCount(); } int rctLoopCnt = productsCnt < reactantsCnt ? productsCnt : reactantsCnt; for (int p = 0; p < productsCnt; p++) { molProduct = prodRxnMolecule.getProduct(p); for (int r = 0; r < rctLoopCnt; r++) { molReactant = rctRxnMolecule.getReactant(r); rctInchi = ChemistryOperations.GetStructureInchiKey(molReactant.toFormat("mol")); prodInchi = ChemistryOperations.GetStructureInchiKey(molProduct.toFormat("mol")); if (rctInchi == prodInchi) { srchMol.setQuery(molReactant); srchMol.setTarget(molProduct); if (!srchMol.isMatching()) { blStatus = false; return(blStatus); } } } } } } } catch (Exception) { throw; } return(blStatus); }