Ejemplo n.º 1
0
        /// <summary>
        /// Get the aligner input paramater from the controls in stack panel
        /// </summary>
        /// <param name="assemblyInput">aligner input object</param>
        /// <returns>Are parameters valid</returns>
        public AlignerInputEventArgs GetAlignmentInput()
        {
            StackPanel            stkPanel     = this.stkAlingerParam;
            AlignerInputEventArgs alignerInput = new AlignerInputEventArgs();
            TextBox textBox;
            int     intValue;
            float   floatValue;

            alignerInput.Aligner = this.Aligner;

            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
                        {
                            MessageBox.Show(
                                Properties.Resources.INVALID_TEXT
                                + PairwiseAlignmentAttributes.GapOpenCost
                                + Properties.Resources.VALUE_TEXT,
                                Properties.Resources.CAPTION,
                                MessageBoxButton.OK, MessageBoxImage.Error);

                            return(null);
                        }

                        break;

                    case PairwiseAlignmentAttributes.GapExtensionCost:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.GapExtensionCost = intValue;
                        }
                        else
                        {
                            MessageBox.Show(
                                Properties.Resources.INVALID_TEXT
                                + PairwiseAlignmentAttributes.GapExtensionCost
                                + Properties.Resources.VALUE_TEXT,
                                Properties.Resources.CAPTION,
                                MessageBoxButton.OK, MessageBoxImage.Error);

                            return(null);
                        }

                        break;

                    case MUMmerAttributes.LengthOfMUM:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.LengthOfMUM = intValue;
                        }
                        else
                        {
                            MessageBox.Show(
                                Properties.Resources.INVALID_TEXT
                                + NUCmerAttributes.LengthOfMUM
                                + Properties.Resources.VALUE_TEXT,
                                Properties.Resources.CAPTION,
                                MessageBoxButton.OK, MessageBoxImage.Error);

                            return(null);
                        }

                        break;

                    case NUCmerAttributes.FixedSeparation:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.FixedSeparation = intValue;
                        }
                        else
                        {
                            MessageBox.Show(
                                Properties.Resources.INVALID_TEXT
                                + NUCmerAttributes.FixedSeparation
                                + Properties.Resources.VALUE_TEXT,
                                Properties.Resources.CAPTION,
                                MessageBoxButton.OK, MessageBoxImage.Error);

                            return(null);
                        }

                        break;

                    case NUCmerAttributes.MaximumSeparation:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.MaximumSeparation = intValue;
                        }
                        else
                        {
                            MessageBox.Show(
                                Properties.Resources.INVALID_TEXT
                                + NUCmerAttributes.MaximumSeparation
                                + Properties.Resources.VALUE_TEXT,
                                Properties.Resources.CAPTION,
                                MessageBoxButton.OK, MessageBoxImage.Error);

                            return(null);
                        }

                        break;

                    case NUCmerAttributes.MinimumScore:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.MinimumScore = intValue;
                        }
                        else
                        {
                            MessageBox.Show(
                                Properties.Resources.INVALID_TEXT
                                + NUCmerAttributes.MinimumScore
                                + Properties.Resources.VALUE_TEXT,
                                Properties.Resources.CAPTION,
                                MessageBoxButton.OK, MessageBoxImage.Error);

                            return(null);
                        }

                        break;

                    case NUCmerAttributes.SeparationFactor:
                        if (float.TryParse(textBox.Text.Trim(), out floatValue))
                        {
                            alignerInput.SeparationFactor = floatValue;
                        }
                        else
                        {
                            MessageBox.Show(
                                Properties.Resources.INVALID_TEXT
                                + NUCmerAttributes.SeparationFactor
                                + Properties.Resources.VALUE_TEXT,
                                Properties.Resources.CAPTION,
                                MessageBoxButton.OK, MessageBoxImage.Error);

                            return(null);
                        }

                        break;

                    case NUCmerAttributes.BreakLength:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.BreakLength = intValue;
                        }
                        else
                        {
                            MessageBox.Show(
                                Properties.Resources.INVALID_TEXT
                                + NUCmerAttributes.BreakLength
                                + Properties.Resources.VALUE_TEXT,
                                Properties.Resources.CAPTION,
                                MessageBoxButton.OK, MessageBoxImage.Error);

                            return(null);
                        }

                        break;

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

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

                        if (comboBox.SelectedIndex > 0)     // user selected a SM other than 'DiagonalSM'
                        {
                            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
                            {
                                MessageBox.Show(
                                    Properties.Resources.INVALID_TEXT + PairwiseAlignmentAttributes.SimilarityMatrix + Properties.Resources.VALUE_TEXT,
                                    Properties.Resources.CAPTION,
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);

                                return(null);
                            }
                        }
                        else
                        {
                            // If DSM is selected
                            alignerInput.SimilarityMatrix = new DiagonalSimilarityMatrix(this.MatchScore, this.MisMatchScore);
                        }

                        break;

                    default:
                        break;
                    }
                }
            }

            return(alignerInput);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Assign the aligner specific parameters
        /// </summary>
        /// <param name="sequenceAligner">Sequence Aligner object</param>
        /// <param name="alignerInput">Aligner Input object</param>
        private static void AssignAlignerParameter(ISequenceAligner sequenceAligner, AlignerInputEventArgs alignerInput)
        {
            if (sequenceAligner is NucmerPairwiseAligner)
            {
                var nucmer = sequenceAligner as NucmerPairwiseAligner;

                nucmer.LengthOfMUM = alignerInput.LengthOfMUM;
                nucmer.FixedSeparation = alignerInput.FixedSeparation;
                nucmer.MaximumSeparation = alignerInput.MaximumSeparation;
                nucmer.MinimumScore = alignerInput.MinimumScore;
                nucmer.SeparationFactor = alignerInput.SeparationFactor;
                nucmer.BreakLength = alignerInput.BreakLength;
            }
            else if (sequenceAligner is MUMmerAligner)
            {
                var mummer = sequenceAligner as MUMmerAligner;

                mummer.LengthOfMUM = alignerInput.LengthOfMUM;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the aligner input parameter from the controls in stack panel
        /// </summary>
        /// <returns>Are parameters valid</returns>
        public AlignerInputEventArgs GetAlignmentInput()
        {
            StackPanel stkPanel = this.stkAlingerParam;
            AlignerInputEventArgs alignerInput = new AlignerInputEventArgs { Aligner = this.Aligner };

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

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

                                return null;
                            }

                            break;

                        case PairwiseAlignmentAttributes.GapExtensionCost:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.GapExtensionCost = intValue;
                            }
                            else
                            {
                                MessageBox.Show(
                                        Properties.Resources.INVALID_TEXT
                                            + PairwiseAlignmentAttributes.GapExtensionCost
                                            + Properties.Resources.VALUE_TEXT,
                                        Properties.Resources.CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);

                                return null;
                            }

                            break;

                        case MUMmerAttributes.LengthOfMUM:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.LengthOfMUM = intValue;
                            }
                            else
                            {
                                MessageBox.Show(
                                        Properties.Resources.INVALID_TEXT
                                            + NUCmerAttributes.LengthOfMUM
                                            + Properties.Resources.VALUE_TEXT,
                                        Properties.Resources.CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);

                                return null;
                            }

                            break;

                        case NUCmerAttributes.FixedSeparation:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.FixedSeparation = intValue;
                            }
                            else
                            {
                                MessageBox.Show(
                                        Properties.Resources.INVALID_TEXT
                                            + NUCmerAttributes.FixedSeparation
                                            + Properties.Resources.VALUE_TEXT,
                                        Properties.Resources.CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);

                                return null;
                            }

                            break;

                        case NUCmerAttributes.MaximumSeparation:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.MaximumSeparation = intValue;
                            }
                            else
                            {
                                MessageBox.Show(
                                        Properties.Resources.INVALID_TEXT
                                            + NUCmerAttributes.MaximumSeparation
                                            + Properties.Resources.VALUE_TEXT,
                                        Properties.Resources.CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);

                                return null;
                            }

                            break;

                        case NUCmerAttributes.MinimumScore:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.MinimumScore = intValue;
                            }
                            else
                            {
                                MessageBox.Show(
                                        Properties.Resources.INVALID_TEXT
                                            + NUCmerAttributes.MinimumScore
                                            + Properties.Resources.VALUE_TEXT,
                                        Properties.Resources.CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);

                                return null;
                            }

                            break;

                        case NUCmerAttributes.SeparationFactor:
                            float floatValue;
                            if (float.TryParse(textBox.Text.Trim(), out floatValue))
                            {
                                alignerInput.SeparationFactor = floatValue;
                            }
                            else
                            {
                                MessageBox.Show(
                                        Properties.Resources.INVALID_TEXT
                                            + NUCmerAttributes.SeparationFactor
                                            + Properties.Resources.VALUE_TEXT,
                                        Properties.Resources.CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);

                                return null;
                            }

                            break;

                        case NUCmerAttributes.BreakLength:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.BreakLength = intValue;
                            }
                            else
                            {
                                MessageBox.Show(
                                        Properties.Resources.INVALID_TEXT
                                            + NUCmerAttributes.BreakLength
                                            + Properties.Resources.VALUE_TEXT,
                                        Properties.Resources.CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);

                                return null;
                            }

                            break;

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

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

                            if (comboBox.SelectedIndex > 0) // user selected a SM other than 'DiagonalSM'
                            {
                                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
                                {
                                    MessageBox.Show(
                                            Properties.Resources.INVALID_TEXT + PairwiseAlignmentAttributes.SimilarityMatrix + Properties.Resources.VALUE_TEXT,
                                            Properties.Resources.CAPTION,
                                            MessageBoxButton.OK,
                                            MessageBoxImage.Error);

                                    return null;
                                }
                            }
                            else
                            {
                                // If DSM is selected
                                alignerInput.SimilarityMatrix = new DiagonalSimilarityMatrix(this.MatchScore, this.MisMatchScore);
                            }

                            break;

                        default:
                            break;
                    }
                }
            }

            return alignerInput;
        }