private void SearchVFMCSMappings() { IQuery query = null; IMapper mapper = null; if (queryMol == null) { countR = GetReactantMol().Atoms.Count + AtomContainerManipulator.GetSingleBondEquivalentSum(GetReactantMol()); countP = GetProductMol().Atoms.Count + AtomContainerManipulator.GetSingleBondEquivalentSum(GetProductMol()); } vfLibSolutions = new List <IReadOnlyDictionary <INode, IAtom> >(); if (queryMol != null) { query = new QueryCompiler(queryMol).Compile(); mapper = new VFMCSMapper(query); var maps = mapper.GetMaps(GetProductMol()); if (maps != null) { vfLibSolutions.AddRange(maps); } SetVFMappings(true, query); } else if (countR <= countP) { query = new QueryCompiler(mol1, IsBondMatchFlag).Compile(); mapper = new VFMCSMapper(query); var maps = mapper.GetMaps(GetProductMol()); if (maps != null) { vfLibSolutions.AddRange(maps); } SetVFMappings(true, query); } else { query = new QueryCompiler(GetProductMol(), IsBondMatchFlag).Compile(); mapper = new VFMCSMapper(query); var maps = mapper.GetMaps(GetReactantMol()); if (maps != null) { vfLibSolutions.AddRange(maps); } SetVFMappings(false, query); } SetVFMappings(false, query); }
/// <summary> /// <para>Compares two IAtomContainers for order with the following criteria /// with decreasing priority: /// <list type="number"> /// <item>Compare atom count</item> /// <item>Compare molecular weight (heavy atoms only)</item> /// <item>Compare bond count</item> /// <item>Compare sum of bond orders (heavy atoms only)</item> /// </list> /// </para> /// <para>If no difference can be /// found with the above criteria, the IAtomContainers are considered /// equal.</para> /// <para>Returns a negative integer, zero, or a positive integer as /// the first argument is less than, equal to, or greater than the /// second.</para> /// </summary> /// <para>This method is null safe.</para> /// <param name="o1">the first IAtomContainer</param> /// <param name="o2">the second IAtomContainer</param> /// <returns>a negative integer, zero, or a positive integer as the first /// argument is less than, equal to, or greater than the second.</returns> public int Compare(T o1, T o2) { // Check for nulls if (o1 == null && o2 == null) { return(0); } if (o1 == null) { return(1); } if (o2 == null) { return(-1); } T atomContainer1 = o1; T atomContainer2 = o2; // 1. Compare atom count if (atomContainer1.Atoms.Count > atomContainer2.Atoms.Count) { return(1); } else if (atomContainer1.Atoms.Count < atomContainer2.Atoms.Count) { return(-1); } else { // 2. Atom count equal, compare molecular weight (heavy atoms only) double mw1 = 0; double mw2 = 0; try { mw1 = GetMolecularWeight(atomContainer1); mw2 = GetMolecularWeight(atomContainer2); } catch (CDKException) { Trace.TraceWarning("Exception in molecular mass calculation."); return(0); } if (mw1 > mw2) { return(1); } else if (mw1 < mw2) { return(-1); } else { // 3. Molecular weight equal, compare bond count if (atomContainer1.Bonds.Count > atomContainer2.Bonds.Count) { return(1); } else if (atomContainer1.Bonds.Count < atomContainer2.Bonds.Count) { return(-1); } else { // 4. Bond count equal, compare sum of bond orders (heavy atoms only) double bondOrderSum1 = AtomContainerManipulator.GetSingleBondEquivalentSum(atomContainer1); double bondOrderSum2 = AtomContainerManipulator.GetSingleBondEquivalentSum(atomContainer2); if (bondOrderSum1 > bondOrderSum2) { return(1); } else if (bondOrderSum1 < bondOrderSum2) { return(-1); } } } } // AtomContainers are equal in terms of this comparator return(0); }