Esempio n. 1
0
        public void Create_symbol_defaultToUnknown()
        {
            IAtom a = AtomBuilder.Create("N/A")
                      .Build();

            Assert.AreEqual(a.Element, Element.Unknown);
        }
Esempio n. 2
0
        public void Create_symbol_null()
        {
            IAtom a = AtomBuilder.Create((string)null)
                      .Build();

            Assert.AreEqual(a.Element, Element.Unknown);
        }
Esempio n. 3
0
        public void Aliphatic_carbon_class1()
        {
            IAtom a = AtomBuilder.Aliphatic(Element.Carbon)
                      .AtomClass(1)
                      .Build();

            Assert.AreEqual(a.Element, Element.Carbon);
            Assert.AreEqual(a.AtomClass, 1);
        }
Esempio n. 4
0
        public void Aliphatic_charged_carbon_minus2()
        {
            IAtom a = AtomBuilder.Aliphatic(Element.Carbon)
                      .Charge(-2)
                      .Build();

            Assert.AreEqual(a.Element, Element.Carbon);
            Assert.AreEqual(a.Charge, -2);
        }
Esempio n. 5
0
        public void Aliphatic_carbon_3_hydrogens()
        {
            IAtom a = AtomBuilder.Aliphatic(Element.Carbon)
                      .NumOfHydrogens(3)
                      .Build();

            Assert.AreEqual(a.Element, Element.Carbon);
            Assert.AreEqual(a.NumOfHydrogens, 3);
        }
Esempio n. 6
0
        public void Aliphatic_carbon_14()
        {
            IAtom a = AtomBuilder.Aliphatic(Element.Carbon)
                      .Isotope(13)
                      .Build();

            Assert.AreEqual(a.Element, Element.Carbon);
            Assert.AreEqual(a.Isotope, 13);
        }
Esempio n. 7
0
        public void Aliphatic_charged_carbon_plus1()
        {
            IAtom a = AtomBuilder.Aliphatic(Element.Carbon)
                      .Cation
                      .Build();

            Assert.AreEqual(a.Element, Element.Carbon);
            Assert.AreEqual(a.Charge, +1);
        }
Esempio n. 8
0
 public void IsAromatic_element_cl()
 {
     try
     {
         IAtom a = AtomBuilder.Aromatic(Chlorine).Build();
         Assert.Fail();
     }
     catch (ArgumentException)
     { }
 }
Esempio n. 9
0
 public void Create_symbol_non_IsAromatic()
 {
     try
     {
         IAtom a = AtomBuilder.Create("cl").Build();
         Assert.Fail();
     }
     catch (ArgumentException)
     { }
 }
Esempio n. 10
0
 public void IsAromatic_symbol_null()
 {
     try
     {
         IAtom a = AtomBuilder.Aromatic((string)null).Build();
         Assert.Fail();
     }
     catch (ArgumentNullException)
     { }
 }
Esempio n. 11
0
        public void IsAromatic_element_c()
        {
            IAtom a = AtomBuilder.Aromatic(Carbon).Build();

            Assert.AreEqual(a.Element, Element.Carbon);
            Assert.AreEqual(a.Isotope, -1);
            Assert.AreEqual(a.Charge, 0);
            Assert.AreEqual(a.AtomClass, 0);
            Assert.AreEqual(a.IsAromatic(), true);
        }
Esempio n. 12
0
 public void IsAromatic_element_null()
 {
     try
     {
         IAtom a = AtomBuilder.Aromatic((Element)null).Build();
         Assert.Fail();
     }
     catch (ArgumentNullException)
     { }
 }
Esempio n. 13
0
        public void Aliphatic_symbol_c()
        {
            IAtom a = AtomBuilder.Aliphatic("C").Build();

            Assert.AreEqual(a.Element, Element.Carbon);
            Assert.AreEqual(a.Isotope, -1);
            Assert.AreEqual(a.Charge, 0);
            Assert.AreEqual(a.AtomClass, 0);
            Assert.AreEqual(a.IsAromatic(), false);
        }
Esempio n. 14
0
 public void IsAromatic_symbol_cl()
 {
     try
     {
         IAtom a = AtomBuilder.Aromatic("Cl").Build();
         Assert.Fail();
     }
     catch (ArgumentException)
     { }
 }
Esempio n. 15
0
        public void IsAromatic_symbol_n()
        {
            IAtom a = AtomBuilder.Aromatic("N")
                      .Build();

            Assert.AreEqual(a.Element, Element.Nitrogen);
            Assert.AreEqual(a.Isotope, -1);
            Assert.AreEqual(a.Charge, 0);
            Assert.AreEqual(a.AtomClass, 0);
            Assert.AreEqual(a.IsAromatic(), true);
        }
Esempio n. 16
0
        public void Create_symbol_IsAromatic_c()
        {
            IAtom a = AtomBuilder.Create("c")
                      .Build();

            Assert.AreEqual(a.Element, Element.Carbon);
            Assert.AreEqual(a.Isotope, -1);
            Assert.AreEqual(a.Charge, 0);
            Assert.AreEqual(a.AtomClass, 0);
            Assert.AreEqual(a.IsAromatic(), true);
        }
Esempio n. 17
0
        public void Aliphatic_element_n()
        {
            IAtom a = AtomBuilder.Aliphatic(Element.Nitrogen)
                      .Build();

            Assert.AreEqual(a.Element, Element.Nitrogen);
            Assert.AreEqual(a.Isotope, -1);
            Assert.AreEqual(a.Charge, 0);
            Assert.AreEqual(a.AtomClass, 0);
            Assert.AreEqual(a.IsAromatic(), false);
        }
Esempio n. 18
0
 public void Aliphatic_carbon_negative_hydrogens()
 {
     try
     {
         IAtom a = AtomBuilder.Aliphatic(Element.Carbon)
                   .NumOfHydrogens(-3)
                   .Build();
         Assert.Fail();
     }
     catch (ArgumentOutOfRangeException)
     { }
 }
Esempio n. 19
0
        public void Anticlockwise_parity()
        {
            GraphBuilder gb = GraphBuilder.Create(5);
            Graph        g  = gb.Add(AtomBuilder.Aliphatic("C").Build())
                              .Add(AtomImpl.AliphaticSubset.Nitrogen)
                              .Add(AtomImpl.AliphaticSubset.Oxygen)
                              .Add(AtomImpl.AliphaticSubset.Carbon)
                              .Add(AtomBuilder.ExplicitHydrogen())
                              .Add(0, 1)
                              .Add(0, 2)
                              .Add(0, 3)
                              .Add(0, 4)
                              .CreateTetrahedral(0).LookingFrom(1)
                              .Neighbors(2, 3, 4)
                              .Parity(-1)
                              .Build()
                              .Build();

            Assert.AreEqual(g.ToSmiles(), "[C@](N)(O)(C)[H]");
        }
Esempio n. 20
0
        private static void Traverse(State s, int idx)
        {
            s.visit[idx] = true;
            var mapIdx = s.g.GetAtom(idx).AtomClass;

            if (mapIdx != 0)
            {
                if (s.map[mapIdx] == 0)
                {
                    s.map[mapIdx] = ++s.nMaps;
                }
                mapIdx = s.map[mapIdx];
                s.g.SetAtom(idx, AtomBuilder.FromExisting(s.g.GetAtom(idx)).AtomClass(mapIdx).Build());
            }
            foreach (var e in s.g.GetEdges(idx))
            {
                int nbr = e.Other(idx);
                if (!s.visit[nbr])
                {
                    Traverse(s, nbr);
                }
            }
        }
Esempio n. 21
0
 public void Aliphatic_carbon_class_negative()
 {
     IAtom a = AtomBuilder.Aliphatic(Element.Carbon)
               .AtomClass(-10)
               .Build();
 }
Esempio n. 22
0
 public void IsAromatic_Unknown_from_element()
 {
     Assert.IsNotNull(AtomBuilder.Aromatic(Unknown).Build());
 }
Esempio n. 23
0
 /// <summary>
 /// Add an aliphatic element with the specified number of carbons.
 /// </summary>
 /// <param name="e">element</param>
 /// <param name="hCount">number of hydrogens</param>
 /// <returns>graph builder for adding more atoms/connections</returns>
 public GraphBuilder Add(Element e, int hCount)
 {
     return(Add(AtomBuilder.Aliphatic(e)
                .NumOfHydrogens(hCount)
                .Build()));
 }
Esempio n. 24
0
 public void IsAromatic_Unknown_from_symbol()
 {
     Assert.IsNotNull(AtomBuilder.Aromatic("*").Build());
     Assert.IsNotNull(AtomBuilder.Aromatic("R").Build());
 }