Exemplo n.º 1
0
        /// <summary>
        /// If all input parameters are satisfactory, this method is called to
        /// prepare the parameters for analysis/post-QC filtering
        /// </summary>
        /// <param name="sender">Run button element</param>
        /// <param name="e">Routed event args</param>
        protected override void PrepareRun(object sender, RoutedEventArgs e)
        {
            #region Prepare event arguments for trimming

            // Build event arguments
            bool trimFromStart = this.comboItemFromLeft.IsSelected;

            // Verify input parser
            bool canAutoParse = base.VerifyInputParser(this.ioControl.Input, this.ioControl.SelectedInputParserType);
            if (!canAutoParse)
            {
                MessageBox.Show(Resource.AUTOPARSE_FAIL);
            }
            else
            {
                // Verify output sequence formatters
                ISequenceFormatter filtered  = DetermineSequenceFormatter(this.ioControl.SelectedOutputParserType, this.ioControl.OutputFilename);
                ISequenceFormatter discarded = DetermineSequenceFormatter(this.ioControl.SelectedOutputParserType, this.ioControl.DiscardedFilename);
                if (filtered == null)
                {
                    // The program shouldn't reach here
                    throw new ApplicationException(Resource.NonsenseError);
                }

                FilterToolArgs args;

                if (this.IsInByLengthMode)
                {
                    args = new TrimByLengthArgs(Convert.ToDouble(this.trimLengthValue.Text), trimFromStart, this.ioControl.Input, filtered, discarded, this.ioControl.OutputFilename);
                }
                else if (this.IsInByQualityMode)
                {
                    int minLength = this.trimQualityMinLengthValue.Text.Equals("") ? TrimByQuality.MIN_LENGTH_DEFAULT : Convert.ToInt32(this.trimQualityMinLengthValue.Text);
                    args = new TrimByQualityArgs(Convert.ToByte(this.trimQualityValue.Text), trimFromStart, minLength, this.ioControl.Input, filtered, discarded, this.ioControl.OutputFilename);
                }
                else if (this.IsInByRegexMode)
                {
                    args = new TrimByRegexArgs(this.ioControl.Input, filtered, discarded, this.trimRegexPattern.Text, this.ioControl.OutputFilename);
                }
                else
                {
                    // The program shouldn't reach here either.
                    throw new ApplicationException(Resource.NonsenseError);
                }

                this.PrepareToTrim(sender, args);

                // release files from memory
                filtered.Dispose();
                if (discarded != null)
                {
                    discarded.Dispose();
                }
            }
            #endregion
        }
Exemplo n.º 2
0
        /// <summary>
        /// If all input parameters are satisfactory, this method is called to
        /// prepare the parameters for analysis/post-QC filtering
        /// </summary>
        /// <param name="sender">Run button element</param>
        /// <param name="e">Routed event args</param>
        protected override void PrepareRun(object sender, RoutedEventArgs e)
        {
            #region Prepare event arguments for discarding

            // Verify input parser
            bool canAutoParse = base.VerifyInputParser(this.ioControl.Input, this.ioControl.SelectedInputParserType);
            if (!canAutoParse)
            {
                MessageBox.Show(Resource.AUTOPARSE_FAIL);
            }
            else
            {
                // Verify output sequence formatters
                ISequenceFormatter filtered  = DetermineSequenceFormatter(this.ioControl.SelectedOutputParserType, this.ioControl.OutputFilename);
                ISequenceFormatter discarded = DetermineSequenceFormatter(this.ioControl.SelectedOutputParserType, this.ioControl.DiscardedFilename);
                if (filtered == null)
                {
                    // The program shouldn't reach here
                    throw new ApplicationException(Resource.NonsenseError);
                }

                FilterToolArgs args;

                if (this.IsInByLengthMode)
                {
                    args = new DiscardByLengthArgs(this.ioControl.Input, filtered, discarded, Convert.ToInt64(this.discardLengthValue.Text), this.ioControl.OutputFilename);
                }
                else if (this.IsInByQualityMode)
                {
                    args = new DiscardByMeanQualityArgs(this.ioControl.Input, filtered, discarded, Convert.ToByte(this.discardQualityValue), this.ioControl.OutputFilename);
                }
                else if (this.IsInByRegexMode)
                {
                    args = new DiscardByRegexArgs(this.ioControl.Input, filtered, discarded, this.discardRegexPattern.Text, this.ioControl.OutputFilename);
                }
                else
                {
                    // The program shouldn't reach here either.
                    throw new ApplicationException(Resource.NonsenseError);
                }

                this.PrepareToDiscard(sender, args);

                filtered.Dispose();
                if (discarded != null)
                {
                    discarded.Dispose();
                }
            }

            #endregion
        }
Exemplo n.º 3
0
        public static void ConvertFromOneFormatToAnother(string inputFileName, string outputFileName, ISequenceFormatter targetFormatter)
        {
            var parser       = SequenceParsers.FindParserByFileName(inputFileName);
            var sequenceList = parser.Parse();
            var sequences    = Helper.ConvertIenumerableToList(sequenceList);

            targetFormatter.Open(outputFileName);

            foreach (var sequence in sequences)
            {
                targetFormatter.Write(sequence);
            }

            targetFormatter.Close();
            targetFormatter.Dispose();
        }
Exemplo n.º 4
0
        public static void ConvertFromOneFormatToAnother(string inputFileName, string outputFileName, ISequenceFormatter targetFormatter)
        {
            var parser = SequenceParsers.FindParserByFileName(inputFileName);
            var sequenceList = parser.Parse();
            var sequences = Helper.ConvertIenumerableToList(sequenceList);

            targetFormatter.Open(outputFileName);

            foreach (var sequence in sequences)
            {
                targetFormatter.Write(sequence);
            }

            targetFormatter.Close();
            targetFormatter.Dispose();
        }