/// <summary> /// Parse a file line into a molecule type data object, with a list of binding sites /// </summary> /// <param name="line"> The file line to parse for data</param> /// <returns> The data constructed by parsing the file line</returns> private MoleculeFileData ParseMolecule(string line) { if (!line.Contains("(") || !line.Contains(")")) { Debug.LogError(String.Format("{0} a molecule is missing parentheses or binding site information.\n{1}", fileErrorMsg, line)); return(new MoleculeFileData()); } MoleculeFileData m = new MoleculeFileData(); int lp = line.IndexOf("("); int rp = line.IndexOf(")"); m.name = line.Substring(0, lp).Trim(); // remove the name & the "(" and ")" characters line = line.Substring(lp + 1, rp - lp - 1); // split the binding site info by the "," character string[] binding_site_strings = line.Split( new[] { "," }, StringSplitOptions.RemoveEmptyEntries); // parse the info for each binding site for (int i = 0; i < binding_site_strings.Length; ++i) { m.bindingSites.Add(ParseBindingSite(binding_site_strings[i])); } return(m); }
/// <summary> /// Parses a list of file-lines, line by line, for molecule type data /// Generally, expected to be called second in file parsing /// Molecule types describe the allowed states of molecule binding-sites in the simulation /// </summary> /// <param name="info"> The strings (file lines) to parse for data</param> /// <param name="fdata"> The BNGL File data object that holds parsed data</param> /// <returns>0(int) for successfull completion</returns> private int ParseMoleculeTypes(List <string> info, BNGLFileData fdata) { // parse each molecule line-by-line foreach (string s in info) { for (int i = 0; i < info.Count; ++i) { string line = info[i]; MoleculeFileData md = ParseMolecule(line); fdata.molecules.Add(md); } } return(0); }