예제 #1
0
        /// <summary>  Returns the most abundant (major) isotope whose symbol equals element.
        ///
        /// </summary>
        /// <param name="symbol"> Description of the Parameter
        /// </param>
        /// <returns>         The Major Isotope value
        /// </returns>
        public virtual IIsotope getMajorIsotope(System.String symbol)
        {
            IIsotope major = null;

            if (majorIsotopes.ContainsValue(symbol))
            {
                major = (IIsotope)majorIsotopes[symbol];
            }
            else
            {
                for (int f = 0; f < isotopes.Count; f++)
                {
                    IIsotope current = (IIsotope)isotopes[f];
                    if (current.Symbol.Equals(symbol))
                    {
                        try
                        {
                            if (major == null)
                            {
                                major = (IIsotope)current.Clone();
                            }
                            else
                            {
                                if (current.NaturalAbundance > major.NaturalAbundance)
                                {
                                    major = (IIsotope)current.Clone();
                                }
                            }
                        }
                        //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
                        catch (System.Exception e)
                        {
                            //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                            //logger.error("Could not clone IIsotope: ", e.Message);
                            //logger.debug(e);
                        }
                    }
                }
                if (major == null)
                {
                    //logger.error("Could not find major isotope for: ", symbol);
                }
                else
                {
                    majorIsotopes[symbol] = major;
                }
            }
            return(major);
        }
예제 #2
0
 private static IIsotope Clone(IIsotope isotope)
 {
     if (isotope == null)
     {
         return(null);
     }
     return((IIsotope)isotope.Clone());
 }
예제 #3
0
        public virtual void TestClone_ExactMass()
        {
            IIsotope iso = (IIsotope)NewChemObject();

            iso.ExactMass = 1.0;
            IIsotope clone = (IIsotope)iso.Clone();

            // test cloning of exact mass
            iso.ExactMass = 2.0;
            Assert.AreEqual(1.0, clone.ExactMass.Value, 0.001);
        }
예제 #4
0
        public virtual void TestClone_MassNumber()
        {
            IIsotope iso = (IIsotope)NewChemObject();

            iso.MassNumber = 12;
            IIsotope clone = (IIsotope)iso.Clone();

            // test cloning of exact mass
            iso.MassNumber = 13;
            Assert.AreEqual(12, clone.MassNumber.Value);
        }
예제 #5
0
        public virtual void TestClone_NaturalAbundance()
        {
            IIsotope iso = (IIsotope)NewChemObject();

            iso.Abundance = 1.0;
            IIsotope clone = (IIsotope)iso.Clone();

            // test cloning of exact mass
            iso.Abundance = 2.0;
            Assert.AreEqual(1.0, clone.Abundance.Value, 0.001);
        }
예제 #6
0
        public override void TestClone()
        {
            IIsotope iso   = (IIsotope)NewChemObject();
            object   clone = iso.Clone();

            Assert.IsTrue(clone is IIsotope);

            // test that everything has been cloned properly
            string diff = IsotopeDiff.Diff(iso, (IIsotope)clone);

            Assert.IsNotNull(diff);
            Assert.AreEqual(0, diff.Length);
        }