public static void QcDIA(IRawDataPlus rawFile, WorkflowParameters parameters) { rawFile.SelectInstrument(Device.MS, 1); rawFile.CheckIfBoxcar(); ScanIndex Index = Extract.ScanIndices(rawFile); MethodDataContainer methodData = Extract.MethodData(rawFile, Index); CentroidStreamCollection centroidStreams = new CentroidStreamCollection(); SegmentScanCollection segmentScans = new SegmentScanCollection(); (centroidStreams, segmentScans) = Extract.MsData(rawFile: rawFile, index: Index); TrailerExtraCollection trailerExtras = Extract.TrailerExtras(rawFile, Index); RetentionTimeCollection retentionTimes = Extract.RetentionTimes(rawFile, Index); ScanMetaDataCollectionDIA metaData = MetaDataProcessingDIA.AggregateMetaDataDIA(centroidStreams, segmentScans, methodData, trailerExtras, retentionTimes, Index); RawMetricsDataDIA metrics = MetaDataProcessingDIA.GetMetricsDataDIA(metaData, methodData, rawFile.FileName, retentionTimes, Index); QcDataContainer qcData = new QcDataContainer(); qcData.DIA = metrics; QcDataCollection qcDataCollection = QC.QcWorkflow.LoadOrCreateQcCollection(parameters); QC.QcWorkflow.UpdateQcCollection(qcDataCollection, qcData, methodData, rawFile.FileName); }
public static RawMetricsDataDIA GetMetricsDataDIA(ScanMetaDataCollectionDIA metaData, MethodDataContainer methodData, string rawFileName, RetentionTimeCollection retentionTimes, ScanIndex index) { RawMetricsDataDIA metricsData = new RawMetricsDataDIA(); metricsData.DateAcquired = methodData.CreationDate; metricsData.Instrument = methodData.Instrument; Console.WriteLine("Calculating metrics"); metricsData.RawFileName = rawFileName; metricsData.Instrument = methodData.Instrument; metricsData.MS1Analyzer = methodData.MassAnalyzers[MSOrderType.Ms]; metricsData.MS2Analyzer = methodData.MassAnalyzers[MSOrderType.Ms2]; metricsData.TotalAnalysisTime = retentionTimes[index.ScanEnumerators[MSOrderType.Any].Last()] - retentionTimes[index.ScanEnumerators[MSOrderType.Any].First()]; metricsData.NumberOfEsiFlags = MetricsCalculations.NumberOfEsiFlags(metaData, index); metricsData.TotalScans = index.TotalScans; metricsData.MS1Scans = index.ScanEnumerators[MSOrderType.Ms].Length; metricsData.MS2Scans = index.ScanEnumerators[MSOrderType.Ms2].Length; metricsData.MSOrder = methodData.AnalysisOrder; metricsData.MedianSummedMS1Intensity = MetricsCalculations.GetMedianSummedMSIntensity(metaData.SummedIntensity, index, MSOrderType.Ms); metricsData.MedianSummedMS2Intensity = MetricsCalculations.GetMedianSummedMSIntensity(metaData.SummedIntensity, index, MSOrderType.Ms2); metricsData.MedianMS1FillTime = MetricsCalculations.GetMedianMSFillTime(metaData.FillTime, index, MSOrderType.Ms); metricsData.MedianMS2FillTime = MetricsCalculations.GetMedianMSFillTime(metaData.FillTime, index, MSOrderType.Ms2); metricsData.MeanDutyCycle = MetricsCalculations.GetMedianDutyCycle(metaData.DutyCycle, index); metricsData.MedianMs2FractionConsumingTop80PercentTotalIntensity = MetricsCalculations.GetMedianMs2FractionConsumingTop80PercentTotalIntensity( metaData.FractionConsumingTop80PercentTotalIntensity, index); metricsData.MS1ScanRate = metricsData.MS1Scans / metricsData.TotalAnalysisTime; metricsData.MS2ScanRate = metricsData.MS2Scans / metricsData.TotalAnalysisTime; (double timeBefore, double timeAfter, double fracAbove) = MetricsCalculations.ChromIntensityMetrics(metaData, retentionTimes, index); metricsData.TimeBeforeFirstScanToExceedPoint1MaxIntensity = timeBefore; metricsData.TimeAfterLastScanToExceedPoint1MaxIntensity = timeAfter; metricsData.FractionOfRunAbovePoint1MaxIntensity = fracAbove; metricsData.Ms1FillTimeDistribution = new Distribution((from x in index.ScanEnumerators[MSOrderType.Ms] select metaData.FillTime[x]).ToArray()); metricsData.Ms2FillTimeDistribution = new Distribution((from x in index.ScanEnumerators[MSOrderType.Ms2] select metaData.FillTime[x]).ToArray()); return(metricsData); }
public static void ParseDIA(IRawFileThreadManager rawFile, WorkflowParameters parameters) { var staticRawFile = rawFile.CreateThreadAccessor(); staticRawFile.SelectInstrument(Device.MS, 1); staticRawFile.CheckIfBoxcar(); ScanIndex Index = Extract.ScanIndices(rawFile.CreateThreadAccessor()); TrailerExtraCollection trailerExtras = Extract.TrailerExtras(rawFile.CreateThreadAccessor(), Index); MethodDataContainer methodData = Extract.MethodData(rawFile.CreateThreadAccessor(), Index); PrecursorScanCollection precursorScans = Extract.PrecursorScansByMasterScanMs2Only(rawFile.CreateThreadAccessor(), trailerExtras, Index); (CentroidStreamCollection centroidStreams, SegmentScanCollection segmentScans) = Extract.MsData(rawFile: rawFile.CreateThreadAccessor(), index: Index); RetentionTimeCollection retentionTimes = Extract.RetentionTimes(rawFile.CreateThreadAccessor(), Index); ScanMetaDataCollectionDIA metaData = MetaDataProcessingDIA.AggregateMetaDataDIA(centroidStreams, segmentScans, methodData, trailerExtras, retentionTimes, Index); RawMetricsDataDIA metrics = null; if (parameters.ParseParams.Metrics) { metrics = MetaDataProcessingDIA.GetMetricsDataDIA(metaData, methodData, staticRawFile.FileName, retentionTimes, Index); MetricsWriter.WriteMatrix(metrics, staticRawFile.FileName, parameters.ParseParams.OutputDirectory); } if (parameters.ParseParams.Parse) { string matrixFileName = ReadWrite.GetPathToFile(parameters.ParseParams.OutputDirectory, staticRawFile.FileName, "._parse.txt"); //MatrixWriter.ParseQuantDIA() //ParseWriter writerDIA = new ParseWriter(matrixFileName, centroidStreams, segmentScans, metaData, // retentionTimes, trailerExtras, precursorScans, Index); //writerDIA.WriteMatrixDIA(); } // I'm not sure what goes into a DIA mgf file, so we aren't making one yet //if (parameters.ParseParams.WriteMgf) //{ // ParseWriter writerMGF = new ParseWriter(centroidStreams, segmentScans, parameters, retentionTimes, precursorMasses, precursorScans, trailerExtras, methodData, Index); // writerMGF.WriteMGF(staticRawFile.FileName); //} }