public void exporterTest1() { var testFile = DeconTools.UnitTesting2.FileRefs.RawDataMSFiles.OrbitrapStdFile1; var peaksTestFile = DeconTools.UnitTesting2.FileRefs.PeakDataFiles.OrbitrapPeakFile_scans5500_6500; var massTagFile = @"\\protoapps\UserData\Slysz\Data\MassTags\qcshew_standard_file_NETVals0.3-0.33.txt"; var exportedResultFile = Path.Combine(FileRefs.OutputFolderPath, "UnlabelledTargetedResultsExporterOutput1.txt"); if (File.Exists(exportedResultFile)) { File.Delete(exportedResultFile); } var run = RunUtilities.CreateAndAlignRun(testFile, peaksTestFile); var mtc = new TargetCollection(); var mtimporter = new MassTagFromTextFileImporter(massTagFile); mtc = mtimporter.Import(); var selectedMassTags = mtc.TargetList.OrderBy(p => p.ID).Take(10).ToList(); TargetedWorkflowParameters parameters = new BasicTargetedWorkflowParameters(); var workflow = new BasicTargetedWorkflow(run, parameters); foreach (var mt in selectedMassTags) { run.CurrentMassTag = mt; workflow.Execute(); } var repo = new TargetedResultRepository(); repo.AddResults(run.ResultCollection.GetMassTagResults()); var exporter = new UnlabelledTargetedResultToTextExporter(exportedResultFile); exporter.ExportResults(repo.Results); }
public void Execute() { Check.Require(_run != null, "Run has not been defined."); //Use Features file if it exists; if not, find the quality Features List <MassTagResultBase> resultsPassingCriteria; _targetedResultRepository = new TargetedResultRepository(); if (ImportedFeaturesFilename == null || ImportedFeaturesFilename.Length == 0) { Check.Require(_run.ResultCollection.MSPeakResultList != null && _run.ResultCollection.MSPeakResultList.Count > 0, "Dataset's Peak-level data is empty. This is needed for chromatogram generation."); resultsPassingCriteria = FindTargetsThatPassCriteria(); _targetedResultRepository.AddResults(resultsPassingCriteria); if (AreFeaturesSavedToTextFile) { string outputfolder; if (ExportAlignmentFolder == null || ExportAlignmentFolder.Length == 0) { outputfolder = _run.DataSetPath; } else { outputfolder = ExportAlignmentFolder; } string exportTargetedFeaturesFile = Path.Combine(outputfolder, _run.DatasetName + "_alignedFeatures.txt"); UnlabelledTargetedResultToTextExporter exporter = new UnlabelledTargetedResultToTextExporter(exportTargetedFeaturesFile); exporter.ExportResults(_targetedResultRepository.Results); } } else { //load them from the Features file UnlabelledTargetedResultFromTextImporter importer = new UnlabelledTargetedResultFromTextImporter(ImportedFeaturesFilename); TargetedResultRepository repo = importer.Import(); _targetedResultRepository.Results = repo.Results; } //do alignment NETAndMassAligner aligner = new NETAndMassAligner(); aligner.SetFeaturesToBeAligned(_targetedResultRepository.Results); aligner.SetReferenceMassTags(this.MassTagList); aligner.Execute(this._run); //save the alignment data if (IsAlignmentInfoExported) { string outputfolder; if (ExportAlignmentFolder == null || ExportAlignmentFolder.Length == 0) { outputfolder = _run.DataSetPath; } else { outputfolder = ExportAlignmentFolder; } string exportNETAlignmentFilename = Path.Combine(outputfolder, _run.DatasetName + "_NETAlignment.txt"); string exportMZAlignmentFilename = Path.Combine(outputfolder, _run.DatasetName + "_MZAlignment.txt"); MassAlignmentInfoToTextExporter mzAlignmentExporter = new MassAlignmentInfoToTextExporter(exportMZAlignmentFilename); mzAlignmentExporter.ExportAlignmentInfo(_run.AlignmentInfo); NETAlignmentInfoToTextExporter netAlignmentExporter = new NETAlignmentInfoToTextExporter(exportNETAlignmentFilename); netAlignmentExporter.ExportAlignmentInfo(_run.AlignmentInfo); } }
public void executeWorkflowTest1() { var testFile = FileRefs.SipperRawDataFile; var exportedResultFile = Path.Combine(FileRefs.OutputFolderPath, "ExportedSipperResults1.txt"); var peaksFile = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\SIPPER_standard_testing\Yellow_C13_070_23Mar10_Griffin_10-01-28_peaks.txt"; var run = RunUtilities.CreateAndLoadPeaks(testFile, peaksFile); var lcmsfeaturesFile = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\SIPPER_standard_testing\Yellow_C13_070_23Mar10_Griffin_10-01-28_LCMSFeatures.txt"; // load LCMSFeatures as targets var importer = new LcmsTargetFromFeaturesFileImporter(lcmsfeaturesFile); var lcmsTargetCollection = importer.Import(); // load MassTags var massTagFile1 = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\SIPPER_standard_testing\Yellow_C13_070_23Mar10_Griffin_10-01-28_MassTags.txt"; var massTagImporter = new MassTagFromTextFileImporter(massTagFile1); var massTagCollection = massTagImporter.Import(); //enriched var testMassTags = new int[] { 355116553, 355129038, 355160150, 355162540, 355163371 }; var filteredLcmsFeatureTargets = (from n in lcmsTargetCollection.TargetList where testMassTags.Contains(((LcmsFeatureTarget)n).FeatureToMassTagID) select n).ToList(); TargetCollection.UpdateTargetsWithMassTagInfo(filteredLcmsFeatureTargets, massTagCollection.TargetList); TargetedWorkflowParameters parameters = new BasicTargetedWorkflowParameters(); parameters.ChromPeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget; var workflow = new SipperTargetedWorkflow(run, parameters); foreach (var target in filteredLcmsFeatureTargets) { run.CurrentMassTag = target; workflow.Execute(); } var results = run.ResultCollection.GetMassTagResults(); var repo = new TargetedResultRepository(); repo.AddResults(run.ResultCollection.GetMassTagResults()); var exporter = new SipperResultToLcmsFeatureExporter(exportedResultFile); exporter.ExportResults(repo.Results); }
public void SetFeaturesToBeAligned(List <TargetedResultBase> featuresToAlign) { _featuresToBeAligned.Clear(); _featuresToBeAligned.AddResults(featuresToAlign); }
public override void Execute() { List <TargetedResultBase> resultsPassingCriteria; _targetedResultRepository = new TargetedResultRepository(); var featuresAreImportedFromFile = !string.IsNullOrEmpty(AlignerParameters.ImportedFeaturesFilename); if (featuresAreImportedFromFile) { //load them from the Features file var importer = new UnlabelledTargetedResultFromTextImporter(AlignerParameters.ImportedFeaturesFilename); var repo = importer.Import(); _targetedResultRepository.Results = repo.Results; } else { Check.Require(Run.ResultCollection.MSPeakResultList != null && Run.ResultCollection.MSPeakResultList.Count > 0, "Dataset's Peak-level data is empty. This is needed for chromatogram generation."); //execute targeted feature finding to find the massTags in the raw data _workflow = new BasicTargetedWorkflow(Run, AlignerParameters); var netGrouping = 0.2; double chromTolerance = 5; //in ppm var progressString = "First trying to find alignment targets using narrow mass tolerances.... "; ReportProgress(0, progressString); var firstPassResults = FindTargetsThatPassSpecifiedMassTolerance(netGrouping, chromTolerance); if (firstPassResults.Count < 10) { //try another netGrouping netGrouping = 0.3; chromTolerance = 20; progressString = "Couldn't find enough. Now trying wider mass tolerance = " + chromTolerance; ReportProgress(0, progressString); var secondPassResults = FindTargetsThatPassSpecifiedMassTolerance(netGrouping, chromTolerance); firstPassResults.AddRange(secondPassResults); } if (firstPassResults.Count < 10) { netGrouping = 0.4; chromTolerance = 50; progressString = "Ok this is a tough one. Now going even wider. Mass tolerance = " + chromTolerance; ReportProgress(0, progressString); var thirdPassResults = FindTargetsThatPassSpecifiedMassTolerance(netGrouping, chromTolerance); firstPassResults.AddRange(thirdPassResults); } var ppmErrors = getMassErrors(firstPassResults); var filteredUsingGrubbsPPMErrors = MathUtilities.filterWithGrubbsApplied(ppmErrors); var canUseNarrowTolerances = executeDecisionOnUsingTightTolerances(filteredUsingGrubbsPPMErrors); if (canUseNarrowTolerances) { var avgPPMError = filteredUsingGrubbsPPMErrors.Average(); var stdev = MathUtilities.GetStDev(filteredUsingGrubbsPPMErrors); var tolerance = Math.Abs(avgPPMError) + 2 * stdev; this.AlignerParameters.ChromGenTolerance = (int)Math.Ceiling(tolerance); this.AlignerParameters.MSToleranceInPPM = (int)Math.Ceiling(tolerance); progressString = "STRICT_Matches_AveragePPMError = \t" + avgPPMError.ToString("0.00") + "; Stdev = \t" + stdev.ToString("0.00000"); ReportProgress(0, progressString); progressString = "NOTE: using the new PPMTolerance= " + this.AlignerParameters.ChromGenTolerance; ReportProgress(0, progressString); _workflow = new BasicTargetedWorkflow(Run, AlignerParameters); } else { double avgPPMError = 0; double stdev = 0; if (filteredUsingGrubbsPPMErrors.Count != 0) { avgPPMError = filteredUsingGrubbsPPMErrors.Average(); stdev = MathUtilities.GetStDev(filteredUsingGrubbsPPMErrors); } progressString = "STRICT_Matches_AveragePPMError = \t" + avgPPMError.ToString("0.00") + "; Stdev = \t" + stdev.ToString("0.00000"); ReportProgress(0, progressString); progressString = "Cannot use narrow ppm tolerances during NET/Mass alignment. Either the massError was too high or couldn't find enough strict matches."; ReportProgress(0, progressString); // find a way to work with datasets with masses way off but low stdev } resultsPassingCriteria = FindTargetsThatPassCriteria(); _targetedResultRepository.AddResults(resultsPassingCriteria); } var canDoAlignment = _targetedResultRepository.Results.Count > 0; if (canDoAlignment) { doAlignment(); } }