Example #1
0
        /// <summary>
        /// Gets called when submit button is clicked.
        /// </summary>
        /// <param name="sender">Submit button.</param>
        /// <param name="e">Event data.</param>
        private void OnSubmitButtonClicked(object sender, RoutedEventArgs e)
        {
            bool valid = this.ParseValues();

            // Validation required. Try to read the arguments and validate the input
            AlignerInputEventArgs alignerInput = new AlignerInputEventArgs();

            valid = valid && GetAlignmentInput(stkAlingerParam, alignerInput, null);

            if (valid)
            {
                this.submit = true;
                this.Close();
            }
        }
Example #2
0
        /// <summary>
        /// Get the aligner input parameter from the controls in stack panel
        /// </summary>
        /// <param name="stkPanel">Stack panel object</param>
        /// <param name="assemblyInput">aligner input object</param>
        /// <param name="alphabet"> Alphabet of the Selected sequences.</param>
        /// <returns>Are parameters valid</returns>
        public bool GetAlignmentInput(
            StackPanel stkPanel,
            AlignerInputEventArgs alignerInput, IAlphabet alphabet)
        {
            TextBox textBox;
            int     intValue;
            float   floatValue;

            foreach (UIElement uiElement in stkPanel.Children)
            {
                if (uiElement is TextBox)
                {
                    textBox = uiElement as TextBox;

                    switch (textBox.Tag.ToString())
                    {
                    case PairwiseAlignmentAttributes.GapOpenCost:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.GapCost = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + PairwiseAlignmentAttributes.GapOpenCost
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case PairwiseAlignmentAttributes.GapExtensionCost:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.GapExtensionCost = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + PairwiseAlignmentAttributes.GapExtensionCost
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case MUMmerAttributes.LengthOfMUM:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.LengthOfMUM = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.LengthOfMUM
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case NUCmerAttributes.FixedSeparation:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.FixedSeparation = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.FixedSeparation
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case NUCmerAttributes.MaximumSeparation:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.MaximumSeparation = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.MaximumSeparation
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case NUCmerAttributes.MinimumScore:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.MinimumScore = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.MinimumScore
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case NUCmerAttributes.SeparationFactor:
                        if (float.TryParse(textBox.Text.Trim(), out floatValue))
                        {
                            alignerInput.SeparationFactor = floatValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.SeparationFactor
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case NUCmerAttributes.BreakLength:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.BreakLength = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.BreakLength
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    default:
                        break;
                    }
                }
                else if (uiElement is ComboBox)
                {
                    ComboBox comboBox = uiElement as ComboBox;

                    switch (comboBox.Tag.ToString())
                    {
                    case PairwiseAlignmentAttributes.SimilarityMatrix:

                        if (comboBox.SelectedValue != null && comboBox.SelectedIndex == 0)     // DSM
                        {
                            int matchScore     = 0;
                            int missmatchScore = 0;

                            int.TryParse(txtMatchScore.Text, out matchScore);
                            int.TryParse(txtMisMatchScore.Text, out missmatchScore);

                            alignerInput.SimilarityMatrix = new DiagonalSimilarityMatrix(matchScore, missmatchScore);
                        }

                        if (null != comboBox.SelectedValue && comboBox.SelectedIndex > 0)
                        {
                            string similarityMatrixOption = comboBox.SelectedValue.ToString();

                            if (Enum.IsDefined(
                                    typeof(SimilarityMatrix.StandardSimilarityMatrix),
                                    similarityMatrixOption))
                            {
                                SimilarityMatrix.StandardSimilarityMatrix matrix =
                                    (SimilarityMatrix.StandardSimilarityMatrix)Enum.Parse(
                                        typeof(SimilarityMatrix.StandardSimilarityMatrix),
                                        similarityMatrixOption,
                                        true);
                                alignerInput.SimilarityMatrix = new SimilarityMatrix(matrix);
                            }
                            else
                            {
                                MessageDialogBox.Show(
                                    Resource.INVALID_TEXT
                                    + PairwiseAlignmentAttributes.SimilarityMatrix
                                    + Resource.VALUE_TEXT,
                                    Properties.Resource.CAPTION,
                                    MessageDialogButton.OK);

                                return(false);
                            }
                        }

                        break;

                    default:
                        break;
                    }
                }
            }

            return(true);
        }
Example #3
0
        public bool GetPamsamInput(
            StackPanel stkPanel,
            AlignerInputEventArgs alignerInput, IAlphabet alphabet)
        {
            TextBox textBox;
            int     intValue;

            try
            {
                foreach (UIElement uiElement in stkPanel.Children)
                {
                    if (uiElement is TextBox)
                    {
                        textBox = uiElement as TextBox;

                        switch (textBox.Tag.ToString())
                        {
                        case PamsamAlignmentAttributes.KmerLength:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.KmerLength = intValue;
                            }
                            else
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.KmerLength);
                            }
                            break;

                        case PamsamAlignmentAttributes.GapOpenPenalty:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.GapOpenPenalty = intValue;
                            }
                            else
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.GapOpenPenalty);
                            }
                            break;

                        case PamsamAlignmentAttributes.GapExtendPenalty:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.GapExtendPenalty = intValue;
                            }
                            else
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.GapExtendPenalty);
                            }
                            break;

                        case PamsamAlignmentAttributes.NumberOfPartitions:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.NumberOfPartitions = intValue;
                            }
                            else
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.NumberOfPartitions);
                            }
                            break;

                        case PamsamAlignmentAttributes.DegreeOfParallelism:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.DegreeOfParallelism = intValue;
                            }
                            else
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.DegreeOfParallelism);
                            }
                            break;
                        }
                    }
                    else if (uiElement is ComboBox)
                    {
                        ComboBox comboBox = uiElement as ComboBox;

                        switch (comboBox.Tag.ToString())
                        {
                        case PamsamAlignmentAttributes.SimilarityMatrix:
                            if (null != comboBox.SelectedValue)
                            {
                                string similarityMatrixOption = comboBox.SelectedValue.ToString();

                                if (Enum.IsDefined(
                                        typeof(SimilarityMatrix.StandardSimilarityMatrix),
                                        similarityMatrixOption))
                                {
                                    SimilarityMatrix.StandardSimilarityMatrix matrix =
                                        (SimilarityMatrix.StandardSimilarityMatrix)Enum.Parse(
                                            typeof(SimilarityMatrix.StandardSimilarityMatrix),
                                            similarityMatrixOption,
                                            true);
                                    alignerInput.SimilarityMatrix = new SimilarityMatrix(matrix);
                                }
                                else
                                {
                                    MessageDialogBox.Show(
                                        Resource.INVALID_TEXT
                                        + PairwiseAlignmentAttributes.SimilarityMatrix
                                        + Resource.VALUE_TEXT,
                                        Properties.Resource.CAPTION,
                                        MessageDialogButton.OK);

                                    return(false);
                                }
                            }
                            break;

                        case PamsamAlignmentAttributes.DistanceFunctionType:
                            if (!Enum.TryParse <DistanceFunctionTypes>(comboBox.Text, out alignerInput.DistanceFunctionName))
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.DistanceFunctionType);
                            }
                            break;

                        case PamsamAlignmentAttributes.UpdateDistanceMethodsType:
                            if (!Enum.TryParse <UpdateDistanceMethodsTypes>(comboBox.Text, out alignerInput.UpdateDistanceMethodsType))
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.UpdateDistanceMethodsType);
                            }
                            break;

                        case PamsamAlignmentAttributes.ProfileAlignerName:
                            if (!Enum.TryParse <ProfileAlignerNames>(comboBox.Text, out alignerInput.ProfileAlignerName))
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.ProfileAlignerName);
                            }
                            break;

                        case PamsamAlignmentAttributes.ProfileScoreFunctionName:
                            if (!Enum.TryParse <ProfileScoreFunctionNames>(comboBox.Text, out alignerInput.ProfileScoreFunctionName))
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.ProfileScoreFunctionName);
                            }
                            break;
                        }
                    }
                }
            }
            catch (ArgumentException ae)
            {
                MessageDialogBox.Show(Resource.INVALID_TEXT
                                      + ae.Message
                                      + Resource.VALUE_TEXT,
                                      Properties.Resource.CAPTION,
                                      MessageDialogButton.OK);

                return(false);
            }

            return(true);
        }