Example #1
0
        /// <summary>
        /// Removes rings which do not have all sp2/planar3 aromatic atoms.
        /// and also gets rid of rings that have more than 8 atoms in them.
        /// </summary>
        /// <param name="m">The <see cref="IAtomContainer"/> from which we want to remove rings</param>
        /// <returns>The set of reduced rings</returns>
        private static IRingSet RemoveExtraRings(IAtomContainer m)
        {
            IRingSet rs = Cycles.FindSSSR(m).ToRingSet();

            //remove rings which don't have all aromatic atoms (according to hybridization set by lower case symbols in smiles):
            var rToRemove = new List <int>();

            for (int i = 0; i < rs.Count; i++)
            {
                if (rs[i].Atoms.Count > 8)
                {
                    rToRemove.Add(i);
                }
                else
                {
                    foreach (var a in rs[i].Atoms)
                    {
                        Hybridization h = a.Hybridization;
                        if (h.IsUnset() || !(h == Hybridization.SP2 || h == Hybridization.Planar3))
                        {
                            rToRemove.Add(i);
                            break;
                        }
                    }
                }
            }
            rToRemove.Reverse();
            foreach (var ri in rToRemove)
            {
                rs.RemoveAt(ri);
            }
            return(rs);
        }
Example #2
0
 /// <summary>
 /// Constructs a new <see cref="IDifference"/> object.
 /// </summary>
 /// <param name="name">a name reflecting the nature of the created <see cref="IDifference"/></param>
 /// <param name="first">the first object to compare</param>
 /// <param name="second">the second object to compare</param>
 /// <returns>an <see cref="IDifference"/> reflecting the differences between the first and second object</returns>
 public static IDifference Construct(string name, Hybridization first, Hybridization second)
 {
     if (first == second)
     {
         return(null);
     }
     return(new AtomTypeHybridizationDifference(name, first, second));
 }
Example #3
0
        public virtual void TestSetHybridization_IAtomType_Hybridization()
        {
            Hybridization hybridization = Hybridization.SP1;

            var atom = (IAtomType)NewChemObject();

            atom.Hybridization = hybridization;
            Assert.AreEqual(hybridization, atom.Hybridization);
        }
Example #4
0
 /// <summary>
 /// Constructs an isotope by copying the symbol, atomic number,
 /// flags, identifier, exact mass, natural abundance and mass
 /// number from the given IIsotope. It does not copy the
 /// listeners and properties. If the element is an instanceof
 /// IAtomType, then the maximum bond order, bond order sum,
 /// van der Waals and covalent radii, formal charge, hybridization,
 /// electron valency, formal neighbour count and atom type name
 /// are copied too.
 /// </summary>
 /// <param name="element">IIsotope to copy information from</param>
 public AtomType(IElement element)
     : base(element)
 {
     if (element is IAtomType aa)
     {
         maxBondOrder         = aa.MaxBondOrder;
         bondOrderSum         = aa.BondOrderSum;
         covalentRadius       = aa.CovalentRadius;
         formalCharge         = aa.FormalCharge;
         hybridization        = aa.Hybridization;
         valency              = aa.Valency;
         formalNeighbourCount = aa.FormalNeighbourCount;
         atomTypeName         = aa.AtomTypeName;
         SetIsHydrogenBondAcceptorWithoutNotify(aa.IsHydrogenBondAcceptor);
         SetIsHydrogenBondDonorWithoutNotify(aa.IsHydrogenBondDonor);
         SetIsAromaticWithoutNotify(aa.IsAromatic);
         SetIsInRingWithoutNotify(aa.IsInRing);
     }
 }
Example #5
0
        public void TestAtomHybridizationDescriptorTest()
        {
            var sp  = CDK.SmilesParser;
            var mol = sp.ParseSmiles("C#CC=CC");

            AddExplicitHydrogens(mol);
            var expectedStates = new Hybridization[]
            {
                Hybridization.SP1,
                Hybridization.SP1,
                Hybridization.SP2,
                Hybridization.SP2,
                Hybridization.SP3
            };
            var descriptor = new AtomHybridizationDescriptor(mol);

            for (int i = 0; i < expectedStates.Length; i++)
            {
                Assert.AreEqual(expectedStates[i], descriptor.Calculate(mol.Atoms[i]).Value);
            }
        }
Example #6
0
 internal ImmutableAtomType(IAtomType type)
 {
     this.element                = type.Element;
     this.symbol                 = type.Symbol;
     this.atomicNumber           = type.AtomicNumber;
     this.abundance              = type.Abundance;
     this.exactMass              = type.ExactMass;
     this.massNumber             = type.MassNumber;
     this.formalCharge           = type.FormalCharge;
     this.hybridization          = type.Hybridization;
     this.formalNeighbourCount   = type.FormalNeighbourCount;
     this.atomTypeName           = type.AtomTypeName;
     this.maxBondOrder           = type.MaxBondOrder;
     this.bondOrderSum           = type.BondOrderSum;
     this.covalentRadius         = type.CovalentRadius;
     this.isHydrogenBondAcceptor = type.IsHydrogenBondAcceptor;
     this.isHydrogenBondDonor    = type.IsHydrogenBondDonor;
     this.isAromatic             = type.IsAromatic;
     this.isAliphatic            = type.IsAliphatic;
     this.isInRing               = this.IsInRing;
     this.baseAtomType           = type;
     if (type.Valency != null)
     {
         this.valency = type.Valency;
     }
     else
     {
         var piBondCount = type.GetProperty <int?>(CDKPropertyName.PiBondCount);
         if (piBondCount != null && formalNeighbourCount != null)
         {
             this.valency = (int)piBondCount + (int)formalNeighbourCount;
         }
         else
         {
             this.valency = null;
         }
     }
 }
Example #7
0
 private AtomTypeHybridizationDifference(string name, Hybridization first, Hybridization second)
 {
     this.name   = name;
     this.first  = first;
     this.second = second;
 }
Example #8
0
 public Result(Hybridization value)
 {
     this.AtomHybridization = value;
 }
 public override string ToString()
 {
     return("HybridizationNumberAtom(" + Hybridization.ToString() + ")");
 }
Example #10
0
 public static bool IsUnset(this Hybridization value)
 {
     return(value == Unset);
 }