/// <summary> /// Constructor for holding all read statistics calculated /// from the QC analysis. /// </summary> /// <param name="main"></param> public InputStatistics(Seqcos main) { if (main == null) { throw new ArgumentNullException("Seqcos"); } this.myFilenames = main.FileList; if (main.SequenceQc != null && main.SequenceQc.IsReady) { this.NumberOfReads = main.SequenceQc.Count; this.ReadLengthMin = main.SequenceQc.ReadLengths.Min(); this.ReadLengthMax = main.SequenceQc.ReadLengths.Max(); this.ReadLengthMean = main.SequenceQc.ReadLengths.Average(); this.ReadGcContentMin = main.SequenceQc.GCContentBySequenceArray.Min(); this.ReadGcContentMax = main.SequenceQc.GCContentBySequenceArray.Max(); this.ReadGcContentMean = main.SequenceQc.GCContentBySequenceArray.Mean(); this.ReadGcContentStd = main.SequenceQc.GCContentBySequenceArray.Std(); } if (main.QualityScoreQc != null && main.QualityScoreQc.IsReady) { if (this.NumberOfReads == 0) { this.NumberOfReads = main.QualityScoreQc.Count; } this.BasePhredScoreMin = main.QualityScoreQc.BaseQualityScoreMin; this.BasePhredScoreMax = main.QualityScoreQc.BaseQualityScoreMax; this.BasePhredScoreMean = main.QualityScoreQc.BaseQualityScoreMean; this.ReadPhredScoreMin = main.QualityScoreQc.ReadQualityScoreMin; this.ReadPhredScoreMax = main.QualityScoreQc.ReadQualityScoreMax; this.ReadPhredScoreMean = main.QualityScoreQc.ReadQualityScoreMean; this.FastQFormat = main.QualityScoreQc.FormatType.ToString(); } }
/// <summary> /// Controls execution of QC steps /// </summary> /// <param name="parser">ISequenceParser object holding the input sequence data</param> /// <param name="filename">Input filename</param> /// <param name="runSequenceQc">Indicates whether the sequence-level QC module should be initialized</param> /// <param name="runQualityScoreQc">Indicates whether the quality score-level QC module should be initialized</param> /// <param name="runBlast">Indicates whether the sequence contamination finder module should be initialized</param> /// <param name="format">FastQ Format Type, if applicable. Otherwise use 'null'.</param> /// <param name="dir">Output directory</param> public Seqcos(ISequenceParser parser, string filename, bool runSequenceQc, bool runQualityScoreQc, bool runBlast, string format, string dir = null) { if (parser == null) { throw new ArgumentNullException("parser"); } if (filename == null) { throw new ArgumentNullException("filename"); } // (deprecated) Register AssemblyResolve event handler - for dealing with Sho libaries that are located // externally from this application's install folder //AppDomain currentDomain = AppDomain.CurrentDomain; //currentDomain.AssemblyResolve += new ResolveEventHandler(OnAssemblyResolveEventHandler); this.myFilenames = new Filenames(filename, Resource.ChartFormat); this.SelectedParser = parser; this.OutputDirectory = (dir == null) ? Path.GetDirectoryName(filename) + @"\" + myFilenames.Prefix : dir; //string customOutputPath = Path.GetDirectoryName(this.OutputDirectory); this.InitialWorkingDirectory = Path.GetDirectoryName(filename); Directory.SetCurrentDirectory(this.InitialWorkingDirectory); if (!Directory.Exists(this.OutputDirectory)) { Directory.CreateDirectory(this.OutputDirectory); } // Initialize SequenceAnalyzer this.SequenceQc = runSequenceQc ? new SequenceAnalyzer(this.SelectedParser, myFilenames.FileName) : null; // Initialize QualityScoreAnalyzer if (runQualityScoreQc && !(parser is FastAParser)) { if (format == null) { throw new ArgumentNullException("format"); } FastQFormatType myFormat = BioHelper.GetQualityFormatType(format); if (runSequenceQc && this.SequenceQc != null) { this.QualityScoreQc = new QualityScoreAnalyzer(this.SelectedParser, this.SequenceQc.ReadLengthMax, this.SequenceQc.Count, myFormat, myFilenames.FileName); } else { this.QualityScoreQc = new QualityScoreAnalyzer(this.SelectedParser, myFormat, myFilenames.FileName); } } else { this.QualityScoreQc = null; } // Initialize ContaminationFinder this.ContaminationFinder = runBlast ? new SequenceContaminationFinder(this.SelectedParser) : null; this.HasPlottedSequenceStats = false; this.HasPlottedQualityScoreStats = false; }