public static void RunXTandem(WorkflowParameters parameters, MethodDataContainer methodData, string mgfFile, string outputFile, bool genDecoy) { XElement customPars, taxonomy; // make a decoy database, if requested if (genDecoy) { // check if the decoy database already exists if (!parameters.QcParams.FastaDatabase.EndsWith(".TARGET_DECOY.fasta")) { FastaManipulation.ReverseDecoy(parameters.QcParams.FastaDatabase); parameters.QcParams.FastaDatabase = parameters.QcParams.FastaDatabase + ".TARGET_DECOY.fasta"; } } // write out the default input file XElement.Parse(Properties.Resources.XTandem_default_config).Save(Path.Combine(parameters.QcParams.XTandemDirectory, "RawTools_default_config.xml")); // set up and write the taxonomy file taxonomy = XElement.Parse(Properties.Resources.XTandem_taxonomy); taxonomy.UpdateTaxonomy(parameters); taxonomy.Save(Path.Combine(parameters.QcParams.XTandemDirectory, "RawTools_taxonomy.xml")); // set up and write the custom input file customPars = XElement.Parse(Properties.Resources.XTandem_custom_config); customPars.UpdateCustomXParameters(parameters, methodData, mgfFile, outputFile); string xTandemParameters = Path.Combine(parameters.QcParams.XTandemDirectory, "RawTools_custom_config.xml"); customPars.Save(xTandemParameters); ConsoleUtils.VoidBash(Path.Combine(parameters.QcParams.XTandemDirectory, "tandem.exe"), xTandemParameters); }
public static void RunIdentipy(WorkflowParameters parameters, MethodDataContainer methodData, string mgfFile, string outputFile) { string pyExec, idpyScript; // get the path to the python executable and identipy start script if they have not been specified if (parameters.QcParams.PythonExecutable == null & parameters.QcParams.IdentipyScript == null) { string pyDir = GetPythonDir(); pyExec = GetPythonExec(pyDir); idpyScript = GetIdentipyExec(pyDir); Log.Information("Found python directory: {PyDir}", pyDir); Log.Information("Found python executable: {PyExec}", pyExec); Log.Information("Found identipy start script: {IdpyScript}", idpyScript); } else { pyExec = parameters.QcParams.PythonExecutable; idpyScript = parameters.QcParams.IdentipyScript; } // run identipy, supresseing RunTimeWarnings //IdentipyExecute(idpyExec, idpyPars.FastaDatabase, idpyPars.FixedMods, idpyPars.VariableMods, mgfFile); Console.WriteLine("Starting Identipy"); Log.Information("Starting Identipy"); IdentipyExecute(pyExec, idpyScript, mgfFile, parameters, methodData.MassAnalyzers[MSOrderType.Ms2]); }
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 void RunSearch(WorkflowParameters parameters, MethodDataContainer methodData, string rawFileName) { string mgfFile = Path.Combine(parameters.QcParams.QcSearchDataDirectory, Path.GetFileName(rawFileName) + ".mgf"); string outputFile = Path.Combine(parameters.QcParams.QcSearchDataDirectory, Path.GetFileName(rawFileName) + ".pep.xml"); if (parameters.QcParams.SearchAlgorithm == SearchAlgorithm.XTandem) { XTandem.RunXTandem(parameters, methodData, mgfFile, outputFile, genDecoy: true); } }
public SearchMetricsContainer(string rawFile, DateTime dateAquired, MethodDataContainer methodData) { RawFile = rawFile; Instrument = methodData.Instrument; DateAcquired = dateAquired; LabelingEfficiencyAtX = LabelingEfficiencyAtNTerm = LabelingEfficiencyAtK = -1; DigestionEfficiency = IdentificationRate = MissedCleavageRate = -1; ChargeRatio3to2 = ChargeRatio4to2 = -1; MedianMassDrift = -1; SearchData = new SearchData(); }
public SearchMetricsContainer(string rawFile, DateTime dateAquired, MethodDataContainer methodData) { RawFile = rawFile; Instrument = methodData.Instrument; DateAcquired = dateAquired; DigestionEfficiency = IdentificationRate = MissedCleavageRate = -1; ChargeRatio3to2 = ChargeRatio4to2 = -1; MedianMassDrift = -1; SearchData = new SearchData(); ModificationFrequency = new SerializableDictionary <string, double>(); }
public static double Ms1IsoWindow(MethodDataContainer methodData) { double isoWindow; if (methodData.AnalysisOrder == MSOrderType.Ms2) { isoWindow = methodData.IsolationWindow.MS2; } else { isoWindow = methodData.IsolationWindow.MS3.MS1Window; } return(isoWindow); }
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); //} }
public static MethodDataContainer MethodData(IRawDataPlus rawFile, ScanIndex index) { rawFile.SelectInstrument(Device.MS, 1); Log.Information("Extracting method/instrument information"); MethodDataContainer methodData = new MethodDataContainer(); methodData.CreationDate = rawFile.CreationDate; methodData.Instrument = rawFile.GetInstrumentData().Name; methodData.AnalysisOrder = index.AnalysisOrder; int firstQuantScan = index.ScanEnumerators[index.AnalysisOrder][0]; methodData.QuantAnalyzer = index.allScans[firstQuantScan].MassAnalyzer; int firstMs1Scan = index.ScanEnumerators[MSOrderType.Ms][0]; methodData.MassAnalyzers.Add(MSOrderType.Ms, index.allScans[firstMs1Scan].MassAnalyzer); methodData.MSOrderEnumerator.Add(MSOrderType.Ms); if (methodData.AnalysisOrder == MSOrderType.Ms2) { int firstMs2Scan = index.ScanEnumerators[MSOrderType.Ms2][0]; methodData.MassAnalyzers.Add(MSOrderType.Ms2, index.allScans[firstMs2Scan].MassAnalyzer); methodData.MSOrderEnumerator.Add(MSOrderType.Ms2); } else if (methodData.AnalysisOrder == MSOrderType.Ms3) { int firstMs2Scan = index.ScanEnumerators[MSOrderType.Ms2][0]; methodData.MassAnalyzers.Add(MSOrderType.Ms2, index.allScans[firstMs2Scan].MassAnalyzer); methodData.MSOrderEnumerator.Add(MSOrderType.Ms2); int n = index.ScanEnumerators[MSOrderType.Ms2].Count(); double ms2window = rawFile.GetScanEventForScanNumber(index.ScanEnumerators[MSOrderType.Ms2][n / 2]).GetIsolationWidth(0); int firstMs3Scan = index.ScanEnumerators[MSOrderType.Ms3][0]; methodData.MassAnalyzers.Add(MSOrderType.Ms3, index.allScans[firstMs3Scan].MassAnalyzer); methodData.MSOrderEnumerator.Add(MSOrderType.Ms3); double ms3ms1window = rawFile.GetScanEventForScanNumber(firstMs3Scan).GetIsolationWidth(0); double ms3ms2window = rawFile.GetScanEventForScanNumber(firstMs3Scan).GetIsolationWidth(1); methodData.IsolationWindow = (MS2 : ms2window, (MS1Window : ms3ms1window, MS2Window : ms3ms2window)); } else { Console.WriteLine("This raw file contains only MS1 scans."); } return(methodData); }
public static MethodDataContainer Ms1MethodData(IRawDataPlus rawFile, ScanIndex index) { rawFile.SelectInstrument(Device.MS, 1); Log.Information("Extracting method/instrument information"); MethodDataContainer methodData = new MethodDataContainer(); methodData.CreationDate = rawFile.CreationDate; methodData.Instrument = rawFile.GetInstrumentData().Name; methodData.AnalysisOrder = index.AnalysisOrder; int firstQuantScan = index.ScanEnumerators[index.AnalysisOrder][0]; methodData.QuantAnalyzer = index.allScans[firstQuantScan].MassAnalyzer; int firstMs1Scan = index.ScanEnumerators[MSOrderType.Ms][0]; methodData.MassAnalyzers.Add(MSOrderType.Ms, index.allScans[firstMs1Scan].MassAnalyzer); methodData.MSOrderEnumerator.Add(MSOrderType.Ms); return(methodData); }
public static void UpdateQcCollection(QcDataCollection qcDataCollection, QcDataContainer newQcData, MethodDataContainer methodData, string rawFileName) { qcDataCollection.QcData.Add(methodData.CreationDate, newQcData); qcDataCollection.ProcessedRawFiles.Add(Path.GetFileName(rawFileName)); qcDataCollection.WriteQcToTable(); Console.WriteLine("QC data written to csv file."); try { XmlSerialization.WriteToXmlFile <QcDataCollection>(qcDataCollection.QcFile, qcDataCollection); Log.Information("QC file saved successfully"); Console.WriteLine("QC file saved successfully"); } catch (Exception e) { Log.Error(e, "Failed during serialization of QC data"); Console.WriteLine("ERROR: failure during serialization of QC data."); Environment.Exit(1); } }
public static RawMetricsDataDDA GetMetricsDataDDA(ScanMetaDataCollectionDDA metaData, MethodDataContainer methodData, string rawFileName, RetentionTimeCollection retentionTimes, ScanIndex index, PrecursorPeakCollection peakData, PrecursorScanCollection precursorScans, QuantDataCollection quantData = null) { RawMetricsDataDDA metricsData = new RawMetricsDataDDA(); 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; if (methodData.AnalysisOrder == MSOrderType.Ms3) { metricsData.MS3Analyzer = methodData.MassAnalyzers[MSOrderType.Ms3]; metricsData.MS3Scans = index.ScanEnumerators[MSOrderType.Ms3].Length; } else { metricsData.MS3Analyzer = MassAnalyzerType.Any; metricsData.MS3Scans = 0; } var pickedMs1 = new HashSet <int>((from x in index.ScanEnumerators[methodData.AnalysisOrder] select precursorScans[x].MasterScan)).ToList(); metricsData.MSOrder = methodData.AnalysisOrder; metricsData.MedianSummedMS1Intensity = MetricsCalculations.GetMedianSummedMSIntensity(metaData.SummedIntensity, index, MSOrderType.Ms); metricsData.MedianSummedMS2Intensity = MetricsCalculations.GetMedianSummedMSIntensity(metaData.SummedIntensity, index, MSOrderType.Ms2); metricsData.MedianPrecursorIntensity = (from x in peakData.Keys select peakData[x].ParentIntensity).ToArray().Percentile(50); metricsData.MedianMS1FillTime = MetricsCalculations.GetMedianMSFillTime(metaData.FillTime, index, MSOrderType.Ms); metricsData.MedianMS2FillTime = MetricsCalculations.GetMedianMSFillTime(metaData.FillTime, index, MSOrderType.Ms2); if (methodData.AnalysisOrder == MSOrderType.Ms3) { metricsData.MedianMS3FillTime = MetricsCalculations.GetMedianMSFillTime(metaData.FillTime, index, MSOrderType.Ms3); } metricsData.MeanTopN = MetricsCalculations.GetMeanMs2ScansPerCycle(metaData.MS2ScansPerCycle); 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; if (methodData.AnalysisOrder == MSOrderType.Ms3) { metricsData.MS3ScanRate = metricsData.MS3Scans / metricsData.TotalAnalysisTime; } metricsData.MedianBaselinePeakWidth = peakData.PeakShapeMedians.Width.P10; metricsData.MedianHalfHeightPeakWidth = peakData.PeakShapeMedians.Width.P50; // we can't access the instrument method in Linux, so we will assume the gradient length is the length of the MS acquisition metricsData.Gradient = retentionTimes[index.allScans.Keys.Max()]; metricsData.PeakCapacity = metricsData.Gradient / metricsData.MedianHalfHeightPeakWidth; metricsData.MedianAsymmetryFactor = peakData.PeakShapeMedians.Asymmetry.P10; // add isolation interference metricsData.MedianMs1IsolationInterference = (from scan in index.ScanEnumerators[methodData.AnalysisOrder] select metaData.Ms1IsolationInterference[scan]).ToArray().Percentile(50); (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()); if (methodData.AnalysisOrder == MSOrderType.Ms3) { metricsData.Ms3FillTimeDistribution = new Distribution((from x in index.ScanEnumerators[MSOrderType.Ms3] select metaData.FillTime[x]).ToArray()); } metricsData.PeakShape.Asymmetry.P10 = peakData.PeakShapeMedians.Asymmetry.P10; metricsData.PeakShape.Asymmetry.P50 = peakData.PeakShapeMedians.Asymmetry.P50; metricsData.PeakShape.Width.P10 = peakData.PeakShapeMedians.Width.P10; metricsData.PeakShape.Width.P50 = peakData.PeakShapeMedians.Width.P50; // now add the quant meta data, if quant was performed double medianReporterIntensity = 0; QuantMetaData quantMetaData = new QuantMetaData(); SerializableDictionary <string, double> medianReporterIntensityByChannel = new SerializableDictionary <string, double>(); if (quantData != null) { string reagent = quantData.LabelingReagents; string[] allTags = new LabelingReagents().Reagents[reagent].Labels; List <double> allChannels = new List <double>(); Dictionary <string, List <double> > byChannel = new Dictionary <string, List <double> >(); foreach (string tag in allTags) { byChannel.Add(tag, new List <double>()); } foreach (int scan in index.ScanEnumerators[methodData.AnalysisOrder]) { foreach (string tag in allTags) { byChannel[tag].Add(quantData[scan][tag].Intensity); allChannels.Add(quantData[scan][tag].Intensity); } } medianReporterIntensity = allChannels.ToArray().Percentile(50); foreach (string tag in allTags) { medianReporterIntensityByChannel[tag] = byChannel[tag].ToArray().Percentile(50); } quantMetaData.medianReporterIntensity = medianReporterIntensity; quantMetaData.medianReporterIntensityByChannel = medianReporterIntensityByChannel; quantMetaData.quantTags = allTags; metricsData.QuantMeta = quantMetaData; metricsData.IncludesQuant = true; } return(metricsData); }
public static ScanMetaDataCollectionDDA AggregateMetaDataDDA(CentroidStreamCollection centroidStreams, SegmentScanCollection segmentScans, MethodDataContainer methodData, PrecursorScanCollection precursorScans, TrailerExtraCollection trailerExtras, PrecursorMassCollection precursorMasses, RetentionTimeCollection retentionTimes, ScanDependentsCollections scanDependents, ScanEventReactionCollection reactions, ScanIndex index) { //ProgressIndicator progress = new ProgressIndicator(index.ScanEnumerators[MSOrderType.Any].Count(), // "Formatting scan meta data"); ScanMetaDataCollectionDDA metaData = new ScanMetaDataCollectionDDA(); int[] scans = index.ScanEnumerators[MSOrderType.Any]; double isoWindow = MetaDataCalculations.Ms1IsoWindow(methodData); Console.WriteLine("Calculating meta data"); Console.WriteLine(" MS1 isolation interference"); metaData.Ms1IsolationInterference = MetaDataCalculations.Ms1Interference(centroidStreams, precursorMasses, trailerExtras, precursorScans, reactions, index); Console.WriteLine(" MS2 scan cycle density"); metaData.MS2ScansPerCycle = MetaDataCalculations.MS2ScansPerCycle(scanDependents, index); Console.WriteLine(" Ion injection time"); metaData.FillTime = MetaDataCalculations.FillTimes(trailerExtras, index); Console.WriteLine(" Duty cycle"); metaData.DutyCycle = MetaDataCalculations.DutyCycle(retentionTimes, index); Console.WriteLine(" Intensity distribution"); metaData.IntensityDistribution = MetaDataCalculations.IntensityDistributions(centroidStreams, segmentScans, index); Console.WriteLine(" Summed intensities"); metaData.SummedIntensity = MetaDataCalculations.SummedIntensities(centroidStreams, segmentScans, index); metaData.FractionConsumingTop80PercentTotalIntensity = MetaDataCalculations.Top80Frac(centroidStreams, segmentScans, index); //Task.WaitAll(); return(metaData); }
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 UpdateCustomXParameters(this XElement customParameters, WorkflowParameters parameters, MethodDataContainer methodData, string mgfFile, string outputFile) { // add fixed modifications customParameters.AddNoteToXTandemParameters(type: "input", label: "residue, modification mass", value: parameters.QcParams.FixedMods); // add the variable modifications var tempMods = from x in (new string[] { parameters.QcParams.NMod, parameters.QcParams.KMod, parameters.QcParams.XMod }) where x != null select x; if (tempMods.Count() > 0) { string vmods = tempMods.Aggregate((i, j) => i + "," + j); customParameters.AddNoteToXTandemParameters(type: "input", label: "residue, potential modification mass", value: vmods); } // add the parent and fragment mass errors // we assume the parent scan is in the FTMS customParameters.AddNoteToXTandemParameters(type: "input", label: "spectrum, parent monoisotopic mass error plus", value: "10"); customParameters.AddNoteToXTandemParameters(type: "input", label: "spectrum, parent monoisotopic mass error minus", value: "10"); customParameters.AddNoteToXTandemParameters(type: "input", label: "spectrum, parent monoisotopic mass isotope error", value: "yes"); customParameters.AddNoteToXTandemParameters(type: "input", label: "spectrum, parent monoisotopic mass error units", value: "ppm"); // need to check where the fragment scan is happening to assign mass error if (methodData.MassAnalyzers[MSOrderType.Ms2] == MassAnalyzerType.MassAnalyzerFTMS) { customParameters.AddNoteToXTandemParameters(type: "input", label: "spectrum, fragment monoisotopic mass error", value: "0.5"); } else { customParameters.AddNoteToXTandemParameters(type: "input", label: "spectrum, fragment monoisotopic mass error", value: "0.05"); } customParameters.AddNoteToXTandemParameters(type: "input", label: "spectrum, fragment monoisotopic mass error units", value: "Daltons"); // add default parameter file customParameters.AddNoteToXTandemParameters(type: "input", label: "list path, default parameters", value: Path.Combine(parameters.QcParams.XTandemDirectory, "RawTools_default_config.xml")); // add taxonomy file customParameters.AddNoteToXTandemParameters(type: "input", label: "list path, taxonomy information", value: Path.Combine(parameters.QcParams.XTandemDirectory, "RawTools_taxonomy.xml")); // add input and output customParameters.AddNoteToXTandemParameters(type: "input", label: "spectrum, path", value: mgfFile); customParameters.AddNoteToXTandemParameters(type: "input", label: "output, path", value: outputFile); // add number of threads to be used int numProcessors = Environment.ProcessorCount; customParameters.AddNoteToXTandemParameters(type: "input", label: "spectrum, threads", value: (numProcessors - 1).ToString()); }
public static ScanMetaDataCollectionDIA AggregateMetaDataDIA(CentroidStreamCollection centroidStreams, SegmentScanCollection segmentScans, MethodDataContainer methodData, TrailerExtraCollection trailerExtras, RetentionTimeCollection retentionTimes, ScanIndex index, int maxProcesses) { //ProgressIndicator progress = new ProgressIndicator(index.ScanEnumerators[MSOrderType.Any].Count(), // "Formatting scan meta data"); ScanMetaDataCollectionDIA metaData = new ScanMetaDataCollectionDIA(); int[] scans = index.ScanEnumerators[MSOrderType.Any]; double isoWindow = MetaDataCalculations.Ms1IsoWindow(methodData); Console.WriteLine("Aggregating meta data"); metaData.FillTime = MetaDataCalculations.FillTimes(trailerExtras, index); metaData.DutyCycle = MetaDataCalculations.DutyCycle(retentionTimes, index); metaData.IntensityDistribution = MetaDataCalculations.IntensityDistributions(centroidStreams, segmentScans, index, maxProcesses); metaData.SummedIntensity = MetaDataCalculations.SummedIntensities(centroidStreams, segmentScans, index, maxProcesses); metaData.FractionConsumingTop80PercentTotalIntensity = MetaDataCalculations.Top80Frac(centroidStreams, segmentScans, index, maxProcesses); //Task.WaitAll(); return(metaData); }
public static void WriteSearchMGF(WorkflowParameters parameters, CentroidStreamCollection centroids, SegmentScanCollection segments, RetentionTimeCollection retentionTimes, PrecursorMassCollection precursorMasses, PrecursorScanCollection precursorScans, TrailerExtraCollection trailerExtras, MethodDataContainer methodData, ScanIndex index, string rawFileName, bool fixedScans = false) { var pars = parameters.QcParams.SearchParameters; int[] scans = AdditionalMath.SelectRandomScans(scans: index.ScanEnumerators[MSOrderType.Ms2], num: parameters.QcParams.NumberSpectra, fixedScans: parameters.QcParams.FixedScans); string mgfFile = ReadWrite.GetPathToFile(parameters.QcParams.QcSearchDataDirectory, rawFileName, ".mgf"); MgfWriter.WriteMGF(rawFileName, centroids, segments, parameters, retentionTimes, precursorMasses, precursorScans, trailerExtras, methodData, index, outputFile: mgfFile, scans: scans); }
public static QuantDataCollection Quantify(CentroidStreamCollection centroidScans, SegmentScanCollection segmentScans, WorkflowParameters parameters, MethodDataContainer methodData, ScanIndex index) { int[] scans = index.ScanEnumerators[index.AnalysisOrder]; QuantDataCollection quantData = new QuantDataCollection(); ProgressIndicator progress = new ProgressIndicator(scans.Length, "Quantifying reporter ions"); string labelingReagents = parameters.ParseParams.LabelingReagents; quantData.LabelingReagents = labelingReagents; foreach (int scan in scans) { if (methodData.QuantAnalyzer == MassAnalyzerType.MassAnalyzerFTMS) { quantData.Add(scan, QuantifyReporters.QuantifyOneScan(centroidScans[scan], labelingReagents)); } else { quantData.Add(scan, QuantifyReporters.QuantifyOneScan(segmentScans[scan], labelingReagents)); } progress.Update(); } progress.Done(); return(quantData); }