コード例 #1
0
        /// <summary>
        /// Filter the mappings for those which cover a unique set of atoms in the
        /// target. The unique atom mappings are a subset of the unique bond
        /// matches.
        /// </summary>
        /// <returns>fluent-api instance</returns>
        /// <seealso cref="GetUniqueBonds"/>
        public Mappings GetUniqueAtoms()
        {
            // we need the unique predicate to be reset for each new iterator -
            // otherwise multiple iterations are always filtered (seen before)
            var m = new UniqueAtomMatches();

            return(new Mappings(query, target, iterable.Where(n => m.Apply(n))));
        }
コード例 #2
0
ファイル: MappingPredicatesTest.cs プロジェクト: qize/NCDK
        public void UniqueAtoms()
        {
            UniqueAtomMatches uam = new UniqueAtomMatches();

            Assert.IsTrue(uam.Apply(new int[] { 1, 2, 3, 4 }));
            Assert.IsTrue(uam.Apply(new int[] { 1, 2, 3, 5 }));
            Assert.IsFalse(uam.Apply(new int[] { 4, 3, 2, 1 }));
            Assert.IsFalse(uam.Apply(new int[] { 1, 5, 2, 3 }));
        }
コード例 #3
0
ファイル: MappingPredicatesTest.cs プロジェクト: qize/NCDK
        public void UniqueBonds()
        {
            IAtomContainer query  = Smi("C1CCC1");
            IAtomContainer target = Smi("C12C3C1C23");

            var mappings = VentoFoggia.CreateSubstructureFinder(query).MatchAll(target);

            // using unique atoms we may think we only found 1 mapping
            {
                var p = new UniqueAtomMatches();
                Assert.AreEqual(1, mappings.Count(p.Apply));
            }

            // when in fact we found 4 different mappings
            {
                var p = new UniqueBondMatches(GraphUtil.ToAdjList(query));
                Assert.AreEqual(3, mappings.Count(p.Apply));
            }
        }