private string FindSubChainPart(string line) { List <string> subGroupNames = CarbonSubChain.GetAllNames(); string subGroupName = UtilStrings.FindPattern(line, subGroupNames, UtilStrings.SearchDirection.Backward); return(subGroupName); }
public Group(string locationsline, string nameline) { if ((nameline.StartsWith(Constants.StartBracket, StringComparison.OrdinalIgnoreCase)) && (nameline.EndsWith(Constants.EndBracket, StringComparison.OrdinalIgnoreCase))) { nameline = nameline.TrimStart("(".ToCharArray()); nameline = nameline.TrimEnd(")".ToCharArray()); int locationOnParent = Convert.ToInt16(locationsline); IUPACCompound compound = new IUPACCompound(locationOnParent, nameline); Formulas = new List <Formula>(); Formulas.Add(compound.Formula); } else { List <string> locations = locationsline.Split(",".ToCharArray()).ToList(); string chainName = MultiplyingAffix.RemoveMultiplyingAffixName(nameline); int chainLength = CarbonSubChain.FindSubChainLength(chainName); Formulas = new List <Formula>(); foreach (string location in locations) { Formula formula = new Formula(Convert.ToInt16(location), chainName); Formulas.Add(formula); } } }
public IUPACCompound(int locationOnParent, string name) { string chainDescription = FindSubChainPart(name); int chainLength = CarbonSubChain.FindSubChainLength(chainDescription); string remaining = UtilStrings.RemoveAtEnd(name, chainDescription); List <int> doubleBondLocations, tripleBondLocations; GetDoubleAndTripleBondLocations(name, out doubleBondLocations, out tripleBondLocations); Formula = new Formula(Enums.ChainTypes.Straight, locationOnParent, chainLength, doubleBondLocations, tripleBondLocations, remaining); }
public static List <CarbonSubChain> GetAllSubChains() { List <CarbonSubChain> subChains = new List <CarbonSubChain>(); for (int counter = 1; counter <= Constants.MaxChainlength; counter++) { CarbonSubChain subChain = new CarbonSubChain(counter); subChains.Add(subChain); } return(subChains.OrderByDescending(c => c.Name.Length).ToList()); }
public Formula(int location, string subchainname) { ChainType = Enums.ChainTypes.Straight; LocationOnParent = location; Length = CarbonSubChain.FindSubChainLength(subchainname); //no double and triplebondlocations in subchains DoubleBondLocations = new List <int>(); TripleBondLocations = new List <int>(); SubFormulas = new List <Formula>(); }