/// <summary>Will add GSMs from db to the given Experiment</summary>
 /// <param name="experiment">Experiment to have its GSMs property updated</param>
 public static void AddExperimentGSMToExperimentFromDb(Experiment experiment, SQLiteDataReader reader)
 {
     ExperimentGSM gsm = new ExperimentGSM(reader["gsm_id"].ToString(), reader["gsm_value"].ToString());
     gsm.Id = Convert.ToInt32(reader["id"].ToString());
     gsm.ExperimentId = reader["experiment_id"].ToString();
     experiment.GSMs.Add(gsm);
 }
        /// <summary>Sets an Experiment property from given data</summary>
        /// <remarks>Method will figure out which property exactly to update</remarks>
        /// <param name="experiment">Experiment to be updated</param>
        /// <param name="lineFromCsvFile">Data from CSV containing the value to be set</param>
        public static void SetExperimentPropertyFromCsvLine(Experiment experiment, string lineFromCsvFile)
        {
            string[] data;

            if (lineFromCsvFile.Contains("="))
            {
                data = lineFromCsvFile.Split('=');
                data = Normalise(data);

                switch (data[0])
                {
                    case "^DATABASE":
                        experiment.Database = data[1];
                        break;
                    case "!Database_name":
                        experiment.DatabaseName = data[1];
                        break;
                    case "!Database_institute":
                        experiment.DatabaseInstitute = data[1];
                        break;
                    case "!Database_web_link":
                        experiment.DatabaseWebLink = data[1];
                        break;
                    case "!Database_email":
                        experiment.DatabaseEmail = data[1];
                        break;
                    case "!Database_ref":
                        experiment.DatabaseRef = data[1];
                        break;
                    case "^DATASET":
                        experiment.Dataset = RemoveCommas(data[1]);
                        break;
                    case "!dataset_title":
                        experiment.DatasetTitle = data[1];
                        break;
                    case "!dataset_description":
                        experiment.DatasetDescription = data[1];
                        break;
                    case "!dataset_type":
                        experiment.DatasetType = data[1];
                        break;
                    case "!dataset_pubmed_id":
                        experiment.DatasetPubmedId = data[1];
                        break;
                    case "!dataset_platform":
                        experiment.DatasetPlatform = data[1];
                        break;
                    case "!dataset_platform_organism":
                        experiment.DatasetPlatformOrganism = data[1];
                        break;
                    case "!dataset_platform_technology_type":
                        experiment.DatasetPlatformTechnologyType = data[1];
                        break;
                    case "!dataset_feature_count":
                        experiment.DatasetFeatureCount = data[1];
                        break;
                    case "!dataset_sample_organism":
                        experiment.DatasetSampleOrganism = data[1];
                        break;
                    case "!dataset_sample_type":
                        experiment.DatasetSampleType = data[1];
                        break;
                    case "!dataset_reference_series":
                        experiment.DatasetReferenceSeries = data[1];
                        break;
                    case "!dataset_update_date":
                        experiment.DatasetUpdateDate = data[1];
                        break;
                }

                if (data[0].StartsWith("#GSM"))
                {
                    ExperimentGSM gsm = new ExperimentGSM(data[0], data[1]);
                    experiment.GSMs.Add(gsm);
                }
            }
            else
            {
                lineFromCsvFile = FixInvalidDatasetTableIdentifiers(lineFromCsvFile);
                data = lineFromCsvFile.Split(',');

                if (data[0].EndsWith("_at"))
                {

                    StringBuilder datasetValue = new StringBuilder();
                    for (int i = 2; i < data.Length; i++)
                    {
                        try
                        {
                            datasetValue.Append(data[i]);
                            datasetValue.Append(";");
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            MessageBox.Show("Dataset table rows cannot contain double quotes and should be comma-separated. Row ID_REF: " + data[0], "Dataset table invalid row", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    datasetValue.Remove(datasetValue.Length - 1, 1); // remove last ';' separator

                    DatasetTableRow datasetRow = new DatasetTableRow(data[0], data[1], datasetValue.ToString());
                    experiment.DatasetTable.Add(datasetRow);
                }
            }
        }