Exemplo n.º 1
0
        /// <summary>
        /// worker_RunWorkerCompleted
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // new score calculation
            double newScore = ORF.CPBcalculator(optimizedORF);

            //new orf to display
            textBox.Text = newScore.ToString();
            optimizedORF.Insert(0, textBox.Text);
            Data.Rows.Add(optimizedORF.ToArray());
            OptimizationDataGrid.ItemsSource = Data.DefaultView;
            SaveToFASTAButton.IsEnabled      = true;

            //max score Textbox update
            if (MaximalizeRadioButton.IsChecked == true)
            {
                maxScores.Add(newScore);
                BestMaxCPBscoreTextBox.Text = maxScores.Max().ToString();
            }

            //min score Textbox update
            if (MinimalizeRadioButton.IsChecked == true)
            {
                minScores.Add(newScore);
                BestMinCPBscoreTextBox.Text = minScores.Min().ToString();
            }

            NcScoreOptimizedTextBox.Text = ORF.NcCalculator(optimizedORF, ORF.aminoAcidCounts).ToString();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method for calculating and displaying
        /// </summary>
        /// <param name="orf"></param>
        /// <param name="amino"></param>
        private void CalculateAndDisplayORF(List <string> orf, List <string> amino)
        {
            Data = new DataTable();
            int columnIdx = 0;

            Data.Columns.Add(new DataColumn("CPB"));
            foreach (var k in ORF.aminoORFseq)
            {
                Data.Columns.Add(new DataColumn(columnIdx.ToString()));
                columnIdx++;
            }

            // CPBcalculator method initialization
            try
            {
                OriginalCPBscoreTextBox.Text = ORF.CPBcalculator(ORF.orfSeq).ToString();
                // datagrid filling
                ORF.aminoORFseq.Insert(0, "");
                ORF.orfSeq.Insert(0, OriginalCPBscoreTextBox.Text);
                Data.Rows.Add(ORF.aminoORFseq.ToArray());
                Data.Rows.Add(ORF.orfSeq.ToArray());
                ORF.aminoORFseq.RemoveAt(0);
                ORF.orfSeq.RemoveAt(0);
                OptimizationDataGrid.ItemsSource = Data.DefaultView;
                GeneticCode.UploadGeneticCode();
                ORF.aminoAcidCounts = ORF.aminoORFseq.GroupBy(i => i)
                                      .ToDictionary(i => i.Key, i => i.Count());
                NcScoreTextBox.Text = ORF.NcCalculator(ORF.orfSeq, ORF.aminoAcidCounts).ToString();
            }
            catch
            {
                string message = "Something went wrong. Please verify your FASTA file for incorrect codons or check your ranking.";
                ModernDialog.ShowMessage(message.ToString(), "Error", MessageBoxButton.OK);
            }
        }