private static List <object> GetMappedFragment(IAtomContainer molecule, IEnumerable <IAtom> atomsMCS) { IAtomContainer subgraphContainer = molecule.Builder.NewAtomContainer(molecule); var list = new List <IAtom>(); foreach (var atom in atomsMCS) { int post = molecule.Atoms.IndexOf(atom); list.Add(subgraphContainer.Atoms[post]); } List <IAtom> rlist = new List <IAtom>(); foreach (var atoms in subgraphContainer.Atoms) { if (!list.Contains(atoms)) { rlist.Add(atoms); } } foreach (var atoms in rlist) { subgraphContainer.RemoveAtomAndConnectedElectronContainers(atoms); } List <object> l = new List <object> { list, subgraphContainer }; return(l); }
/// <summary> /// </summary> /// <param name="mol"></param> /// <param name="mcss"></param> /// <param name="shouldMatchBonds"></param> /// <returns>IMolecule Set</returns> /// <exception cref="CDKException"></exception> private static IChemObjectSet <IAtomContainer> GetUncommon(IAtomContainer mol, IAtomContainer mcss, bool shouldMatchBonds) { List <int> atomSerialsToDelete = new List <int>(); var matches = CDKMCS.GetSubgraphAtomsMaps(mol, mcss, shouldMatchBonds); var mapList = matches[0]; foreach (var o in mapList) { CDKRMap rmap = (CDKRMap)o; atomSerialsToDelete.Add(rmap.Id1); } // at this point we have the serial numbers of the bonds to delete // we should get the actual bonds rather than delete by serial numbers List <IAtom> atomsToDelete = new List <IAtom>(); foreach (var serial in atomSerialsToDelete) { atomsToDelete.Add(mol.Atoms[serial]); } // now lets get rid of the bonds themselves foreach (var atom in atomsToDelete) { mol.RemoveAtomAndConnectedElectronContainers(atom); } // now we probably have a set of disconnected components // so lets get a set of individual atom containers for // corresponding to each component return(ConnectivityChecker.PartitionIntoMolecules(mol)); }
private int GetMappedMoleculeFragmentSize(IReadOnlyDictionary <IAtom, IAtom> mcsAtomSolution) { IAtomContainer educt = ChemObjectBuilder.Instance.NewAtomContainer(rMol); IAtomContainer product = ChemObjectBuilder.Instance.NewAtomContainer(pMol); if (mcsAtomSolution != null) { foreach (var map in mcsAtomSolution) { IAtom atomE = map.Key; IAtom atomP = map.Value; educt.RemoveAtomAndConnectedElectronContainers(atomE); product.RemoveAtomAndConnectedElectronContainers(atomP); } } return(GetFragmentCount(educt) + GetFragmentCount(product)); }