private void btnSaveProcessDefinition_Click(object sender, RoutedEventArgs e) { ProcessDefinition = ProcessDefinition.ToProcessDefinition(ColumnProcessDefinitions); NumericTable numericTable = ProcessDefinition.ToNumericTableUpdateProcessDefinition(RawText, ",", DependantColumnIndex); if (ProcessDefinition != null) { FileIOProcessDefinition.SaveAs(ref ProcessDefinition); } }
/// <summary> /// The add result to scores table. /// </summary> /// <param name="dataset"> /// The dataset. /// </param> /// <param name="chemicalResult"> /// The chemical result. /// </param> /// <param name="target"> /// The target. /// </param> /// <param name="table"> /// The table. /// </param> /// <param name="colDef"> /// The col def. /// </param> /// <returns> /// The <see cref="int"/>. /// </returns> public static int AddResultToScoresTable(string dataset, CrossSectionWorkflowResult chemicalResult, IImsTarget target, NumericTable table, IList<string> colDef) { TableRow dict = new TableRow(dataset + target); dict.Name += "(" + chemicalResult.AnalysisStatus + ")"; dict.Add(colDef[1], chemicalResult.AverageObservedPeakStatistics.IntensityScore); dict.Add(colDef[2], chemicalResult.AverageObservedPeakStatistics.IsotopicScore); dict.Add(colDef[3], chemicalResult.AverageObservedPeakStatistics.PeakShapeScore); dict.Add(colDef[0], chemicalResult.AverageVoltageGroupStability); dict.Add(colDef[4], chemicalResult.AssociationHypothesisInfo.ProbabilityOfHypothesisGivenData); table.Add(dict); return 1; }
private void mnuImport_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { string rawText = File.ReadAllText(openFileDialog.FileName); string[,] rawTable = ProcessData.ParseCSV(rawText, ","); StringTable stringTable = ProcessData.RawTableToStringTable(rawTable, rawTable.GetUpperBound(1)); NumericTable = ProcessData.ToNumericTable(stringTable); } MessageBox.Show("Done."); }
private void btnForecast_Click(object sender, RoutedEventArgs e) { InputBox inputBox = new InputBox(); inputBox.Label1.Text = "Enter the header name you want to use as the id column."; inputBox.ShowDialog(); string selectedHeaderName = inputBox.TextBox1.Text; //tabName = Interaction.InputBox("Enter a name for the new tab.", "Enter Name", "Tab " + Convert.ToString(tabControl.Items.Count + 1)); if (selectedHeaderName == "" | selectedHeaderName == null) { return; } NumericTable numericTable = ProcessDefinition.ToNumericTableUseProcessDefinition(RawData, ",", -1); StringTable stringTable = ProcessData.RawTableToStringTable(ProcessData.ParseCSV(RawData, ","), -1); int idHeaderIndex = numericTable.IndependentHeaders.ToList().IndexOf(selectedHeaderName); if (idHeaderIndex == -1) { MessageBox.Show("Id header not found, aborted."); return; } int totalRows = numericTable.Independents.GetUpperBound(0) + 1; int totalColumns = numericTable.Independents.GetUpperBound(1) + 1; List <string> rows = new List <string>(); rows.Add(selectedHeaderName + "," + "Forecast"); List <Operator> operators = Operator.BuildOperators(); Node modelExpression = Node.Parse(txtModelExpression.Text, operators); List <Node> branches = modelExpression.DescendantsAndSelf(); List <Pointer> pointers = Node.BuildPointers("Independent", branches); for (int rowIndex = 0; rowIndex < totalRows; rowIndex++) { string id = stringTable.Independents[rowIndex, idHeaderIndex]; List <double> numbers = new List <double>(); for (int columnIndex = 0; columnIndex < totalColumns; columnIndex++) { double number = numericTable.Independents[rowIndex, columnIndex]; numbers.Add(number); } //Node.SetNumbers(pointers, numbers, branches); //double forecast = Evaluation.Evaluate(modelExpression) * ProcessDefinition.Scale + ProcessDefinition.Offset; double forecast = Forecasting.ForecastFast(numbers, branches, pointers); forecast = Forecasting.ScaleAndOffsetForecast(forecast, ProcessDefinition.Scale, ProcessDefinition.Offset); string row = id + "," + forecast.ToString(); rows.Add(row); } txtForecasts.Text = string.Join(Environment.NewLine, rows.ToArray()); //txtForecasts.Text = ProcessData.NumericTableToCSV(numericTable); }
private void btnProcessDataAndSave_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = FileHelper.FileIO.BuildFilter("csv", "csv"); if (saveFileDialog.ShowDialog() == false) { return; } ProcessDefinition = ProcessDefinition.ToProcessDefinition(ColumnProcessDefinitions); NumericTable numericTable = ProcessDefinition.ToNumericTableUpdateProcessDefinition(RawText, ",", DependantColumnIndex); string csv = ProcessData.NumericTableToCSV(numericTable); File.WriteAllText(saveFileDialog.FileName, csv); }