static void Main(string[] args) { Console.Error.WriteLine(SplashString()); CommandLineOptions myArgs = ProcessCommandLine(args); #region Discarding // Determine parser InputSubmission input = new InputSubmission(myArgs.FileList[0]); input.DetermineParserUtil(); // Create a sequence formatter object ISequenceFormatter filteredFormatter; ISequenceFormatter discardedFormatter = null; // If the format is FASTA, then output will be FASTA. // Everything else (assuming quality scores are available) // will be outputted to FASTQ. if (input.Parser is FastAParser) { filteredFormatter = new FastAFormatter(myArgs.FileList[1]); if (myArgs.DiscardedFile != null) { discardedFormatter = new FastAFormatter(myArgs.DiscardedFile); } } else { filteredFormatter = new FastQFormatter(myArgs.FileList[1]); if (myArgs.DiscardedFile != null) { discardedFormatter = new FastQFormatter(myArgs.DiscardedFile); } } // Initialize a Trimmer object Discarder myDiscarder = null; // By now, we should have sanity checked the command line arguments. So we should be able to // figure out what mode is being used simply by checking the properties. if (myArgs.DiscardByLength > 0) { myDiscarder = new DiscardByLength(input.Parser, filteredFormatter, discardedFormatter, myArgs.DiscardByLength); } else if (myArgs.DiscardByQuality > 0) { if (!(input.Parser is FastQParser)) { Console.Error.WriteLine("Input file must be in FASTQ format."); Environment.Exit(-1); } myDiscarder = new DiscardByMeanQuality(input.Parser, filteredFormatter, discardedFormatter, (byte)myArgs.DiscardByQuality); } else { // Should never reach this line. Console.Error.WriteLine("Invalid trim mode. Use '-l' or '-q'."); Environment.Exit(-1); } myDiscarder.DiscardReads(); #endregion if (myArgs.Verbose) { Console.Error.WriteLine("Discarded {0}/{1} sequences.", myDiscarder.DiscardCount, myDiscarder.Counted); Console.Error.WriteLine("Non-discarded sequences saved in {0}.", Path.GetFullPath(myArgs.FileList[1])); if (myArgs.DiscardedFile != null) { Console.Error.WriteLine("Discarded sequences saved in {0}.", Path.GetFullPath(myArgs.DiscardedFile)); discardedFormatter.Close(); } Console.Error.WriteLine("Warning: Output may not be in the same order as the original input."); } input.Parser.Close(); filteredFormatter.Close(); if (discardedFormatter != null) { discardedFormatter.Close(); } }
/// <summary> /// Constructor for DiscardByLength Event Args /// </summary> /// <param name="input">Input information</param> /// <param name="filtered">Output sequence formatter</param> /// <param name="discarded">Discarded reads sequence formatter</param> /// <param name="length">Length threshold for discarding reads</param> /// <param name="outFile">Output filename</param> public DiscardByLengthArgs(InputSubmission input, ISequenceFormatter filtered, ISequenceFormatter discarded, long length, string outFile) : base(input, outFile) { discarder = new DiscardByLength(input.Parser, filtered, discarded, length); }