Пример #1
0
        public IUPACCompound(string iupacName)
        {
            string mainChainDescription = FindMainChainPart(iupacName);

            Enums.ChainTypes chaintype;

            if (mainChainDescription.StartsWith("cyclo"))
            {
                chaintype            = Enums.ChainTypes.Cyclo;
                mainChainDescription = UtilStrings.RemoveAtStart(mainChainDescription, "cyclo");
            }
            else
            {
                chaintype = Enums.ChainTypes.Straight;
            }

            int mainChainLength = CarbonMainChain.FindMainChainLength(mainChainDescription);

            string remaining;

            if (iupacName.Contains(Constants.EndBracket))
            {
                remaining = UtilStrings.RemoveEverythingAfter(iupacName, Constants.EndBracket);
            }
            else
            {
                remaining = UtilStrings.RemoveEverythingAfter(iupacName, Constants.SubChainEnd);
            }

            List <int> doubleBondLocations, tripleBondLocations;

            GetDoubleAndTripleBondLocations(iupacName, out doubleBondLocations, out tripleBondLocations);
            Formula = new Formula(chaintype, 0, mainChainLength, doubleBondLocations, tripleBondLocations, remaining);
        }
        public static List <CarbonMainChain> GetAllMainChains()
        {
            List <CarbonMainChain> mainChains = new List <CarbonMainChain>();

            for (int counter = 1; counter <= Constants.MaxChainlength; counter++)
            {
                CarbonMainChain mainChain = new CarbonMainChain(counter);
                mainChains.Add(mainChain);
            }
            return(mainChains.OrderByDescending(c => c.Name.Length).ToList());
        }