示例#1
0
        // All of the Private Data Type Parsing functions assume previous validation for null, empty, or comment lines

        private ComplexFileData ParseComplex(string line)
        {
            ComplexFileData cd = new ComplexFileData();

            // split the complex by the '.' character
            string[] complex_strings = line.Split(
                new[] { "." },
                StringSplitOptions.RemoveEmptyEntries);

            // parse the info for each molecule in the complex
            for (int i = 0; i < complex_strings.Length; ++i)
            {
                cd.molecules.Add(ParseMolecule(complex_strings[i]));
            }

            return(cd);
        }
示例#2
0
        /// <summary>
        /// Parses a list of file-lines, line by line, for seed species data
        /// Generally, expected to be called third in file parsing
        /// Seed species are species present at the beginning of 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 ParseSeedSpecies(List <string> info, BNGLFileData fdata)
        {
            foreach (string s in info)
            {
                int rp = s.IndexOf(")"); // assuming the following layout:
                                         // [molecule]"(" [binding-sites] ")" [numerical value]

                ComplexFileData cd        = ParseComplex(s.Substring(0, rp + 1));
                string          iv_string = s.Substring(rp + 1).Trim();

                // Check that a value was specified for the seed species
                if (String.IsNullOrEmpty(iv_string))
                {
                    Debug.LogError(String.Format("{0} Seed Species is missing a value.\n{1}", fileErrorMsg, s));
                    return(-1);
                }

                SeedSpeciesFileData ssd = new SeedSpeciesFileData();
                ssd.complex = cd;

                float n     = 0;
                bool  isNum = float.TryParse(iv_string, out n);

                if (isNum) // A number was specified as the initial value for this seed species
                {
                    ssd.initialValue = n;
                }
                else // A parameter was specified as the initial value for this seed species
                {
                    // Check that the specified parameter was specified and parsed
                    if (!fdata.parameters.ContainsKey(iv_string))
                    {
                        Debug.LogError(String.Format("{0} A Seed Species referenced an undefined parameter.\n{1}", fileErrorMsg, s));
                        return(-1);
                    }

                    ssd.initialValue = fdata.parameters[iv_string];
                }

                fdata.seedSpecies.Add(ssd);
            }

            return(0);
        }