public void Create_symbol_defaultToUnknown() { IAtom a = AtomBuilder.Create("N/A") .Build(); Assert.AreEqual(a.Element, Element.Unknown); }
public void Create_symbol_null() { IAtom a = AtomBuilder.Create((string)null) .Build(); Assert.AreEqual(a.Element, Element.Unknown); }
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); }
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); }
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); }
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); }
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); }
public void IsAromatic_element_cl() { try { IAtom a = AtomBuilder.Aromatic(Chlorine).Build(); Assert.Fail(); } catch (ArgumentException) { } }
public void Create_symbol_non_IsAromatic() { try { IAtom a = AtomBuilder.Create("cl").Build(); Assert.Fail(); } catch (ArgumentException) { } }
public void IsAromatic_symbol_null() { try { IAtom a = AtomBuilder.Aromatic((string)null).Build(); Assert.Fail(); } catch (ArgumentNullException) { } }
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); }
public void IsAromatic_element_null() { try { IAtom a = AtomBuilder.Aromatic((Element)null).Build(); Assert.Fail(); } catch (ArgumentNullException) { } }
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); }
public void IsAromatic_symbol_cl() { try { IAtom a = AtomBuilder.Aromatic("Cl").Build(); Assert.Fail(); } catch (ArgumentException) { } }
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); }
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); }
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); }
public void Aliphatic_carbon_negative_hydrogens() { try { IAtom a = AtomBuilder.Aliphatic(Element.Carbon) .NumOfHydrogens(-3) .Build(); Assert.Fail(); } catch (ArgumentOutOfRangeException) { } }
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]"); }
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); } } }
public void Aliphatic_carbon_class_negative() { IAtom a = AtomBuilder.Aliphatic(Element.Carbon) .AtomClass(-10) .Build(); }
public void IsAromatic_Unknown_from_element() { Assert.IsNotNull(AtomBuilder.Aromatic(Unknown).Build()); }
/// <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())); }
public void IsAromatic_Unknown_from_symbol() { Assert.IsNotNull(AtomBuilder.Aromatic("*").Build()); Assert.IsNotNull(AtomBuilder.Aromatic("R").Build()); }