public void Test1() { TargetedWorkflowParameters o16o18workflowParameters = new O16O18WorkflowParameters(); var parentWorkflow = new O16O18IqWorkflow(o16o18workflowParameters); TargetedWorkflowParameters workflowParameters = new BasicTargetedWorkflowParameters(); var childWorkflow = new BasicIqWorkflow(workflowParameters); IqTarget parentTarget = new IqChargeStateTarget(); IqTarget childTarget1 = new IqChargeStateTarget(); IqTarget childTarget2 = new IqChargeStateTarget(); IqTarget childTarget3 = new IqChargeStateTarget(); parentTarget.AddTarget(childTarget1); parentTarget.AddTarget(childTarget2); parentTarget.AddTarget(childTarget3); var workflowAssigner = new IqWorkflowAssigner(); workflowAssigner.AssignWorkflowToParent(parentWorkflow, parentTarget); workflowAssigner.AssignWorkflowToChildren(childWorkflow, parentTarget); Assert.IsNotNull(parentTarget.ChildTargets().First().Workflow); var childTargets = parentTarget.ChildTargets(); foreach (var childTarget in childTargets) { Assert.IsTrue(childTarget.Workflow is BasicIqWorkflow); } Assert.IsTrue(parentTarget.Workflow is O16O18IqWorkflow); }
public void MSAlignTargetDataTest() { var testFile = @"\\protoapps\UserData\Fujimoto\TopDownTesting\Charles_Data\SBEP_STM_001_02222012_Aragon.raw"; var targetsFile = @"\\protoapps\UserData\Fujimoto\TopDownTesting\Charles_Data\salmonella_top_target.txt"; var resultsFolder = @"\\protoapps\UserData\Fujimoto\TopDownTesting\Charles_Data\Results"; //Backend.Utilities.SipperDataDump.DataDumpSetup(@"\\protoapps\UserData\Fujimoto\TopDownTesting\Charles_Data\Results\detailed_results.txt"); WorkflowExecutorBaseParameters executorBaseParameters = new BasicTargetedWorkflowExecutorParameters(); executorBaseParameters.ChromGenSourceDataPeakBR = 3; executorBaseParameters.ChromGenSourceDataSigNoise = 2; executorBaseParameters.TargetsFilePath = targetsFile; executorBaseParameters.OutputFolderBase = resultsFolder; var run = new RunFactory().CreateRun(testFile); var executor = new TopDownMSAlignExecutor(executorBaseParameters, run); var s = Stopwatch.StartNew(); executor.LoadAndInitializeTargets(targetsFile); s.Stop(); var rt = s.Elapsed; Console.WriteLine("import: " + rt); var targetedWorkflowParameters = new BasicTargetedWorkflowParameters(); targetedWorkflowParameters.ChromNETTolerance = 0.05; targetedWorkflowParameters.ChromatogramCorrelationIsPerformed = true; targetedWorkflowParameters.ChromSmootherNumPointsInSmooth = 15; targetedWorkflowParameters.MSToleranceInPPM = 15; targetedWorkflowParameters.NumMSScansToSum = 5; //define workflows for parentTarget and childTargets var parentWorkflow = new ChromPeakDeciderTopDownIqWorkflow(run, targetedWorkflowParameters); var childWorkflow = new ChargeStateChildTopDownIqWorkflow(run, targetedWorkflowParameters); var workflowAssigner = new IqWorkflowAssigner(); workflowAssigner.AssignWorkflowToParent(parentWorkflow, executor.Targets); workflowAssigner.AssignWorkflowToChildren(childWorkflow, executor.Targets); var stopwatch = Stopwatch.StartNew(); //Main line for executing IQ: executor.Execute(); stopwatch.Stop(); var runtime = stopwatch.Elapsed; Console.WriteLine("Runtime: " + runtime); }
public void ChromCorrelatorTest1() { var rawFilename = @"D:\Data\O16O18\Vlad_Mouse\mhp_plat_test_1_14April13_Frodo_12-12-04.raw"; var run = new RunFactory().CreateRun(rawFilename); WorkflowExecutorBaseParameters executorBaseParameters = new BasicTargetedWorkflowExecutorParameters(); var executor = new IqExecutor(executorBaseParameters, run); executor.LoadChromData(run); var workflowAssigner = new IqWorkflowAssigner(); TargetedWorkflowParameters workflowParameters = new O16O18WorkflowParameters(); IqWorkflow workflow = new O16O18IqWorkflow(run, workflowParameters); IqTarget iqTarget = new IqChargeStateTarget(); iqTarget.EmpiricalFormula = "C58H100N18O20"; iqTarget.Code = "GAAQNIIPASTGAAK"; iqTarget.ID = 1093; iqTarget.ChargeState = 0; var iqTargetList = new List <IqTarget>(); iqTargetList.Add(iqTarget); var utilities = new IqTargetUtilities(); utilities.CreateChildTargets(iqTargetList); workflowAssigner.AssignWorkflowToParent(workflow, iqTargetList); workflowAssigner.AssignWorkflowToChildren(workflow, iqTargetList); var theorFeatureGenerator = new JoshTheorFeatureGenerator(); foreach (var target in iqTarget.ChildTargets()) { utilities.UpdateTargetMissingInfo(target); target.TheorIsotopicProfile = theorFeatureGenerator.GenerateTheorProfile(target.EmpiricalFormula, target.ChargeState); } foreach (var childTarget in iqTarget.ChildTargets()) { var result = childTarget.CreateResult(); var correlator = new O16O18ChromCorrelator(7, 0.1, 20, Globals.ToleranceUnit.PPM); var corrData = correlator.CorrelateData(run, result, 5700, 6500); var corrDataItem1 = corrData.CorrelationDataItems.First(); Console.WriteLine("z= \t" + childTarget.ChargeState + "\tCorrelationData (slope,intercept,rsquared)= \t" + corrDataItem1); } }
public void ProblemTesting_correlationProb1() { //see JIRA https://jira.pnnl.gov/jira/browse/OMCS-628 var executorParameters = new BasicTargetedWorkflowExecutorParameters(); var testDatasetPath = @"D:\Data\O16O18\Vlad_Mouse\mhp_plat_test_1B_8Apr13_Cougar_13-03-25.raw"; executorParameters.IsMassAlignmentPerformed = true; executorParameters.IsNetAlignmentPerformed = true; executorParameters.ReferenceTargetsFilePath = @"\\protoapps\DataPkgs\Public\2013\795_Iq_analysis_of_mouse_O16O18\Targets\MT_Mouse_MHP_O18_Set3_P892_targets.txt"; var run = new RunFactory().CreateRun(testDatasetPath); var executor = new IqExecutor(executorParameters, run); var targetsFile = @"\\protoapps\DataPkgs\Public\2013\795_Iq_analysis_of_mouse_O16O18\Targets\MT_Mouse_MHP_O18_Set3_P892_targets.txt"; executor.LoadAndInitializeTargets(targetsFile); executor.SetupMassAndNetAlignment(); var testTarget = 6955012; executor.Targets = (from n in executor.Targets where n.ID == testTarget select n).ToList(); var targetedWorkflowParameters = new BasicTargetedWorkflowParameters(); targetedWorkflowParameters.LoadParameters(@"\\protoapps\DataPkgs\Public\2013\795_Iq_analysis_of_mouse_O16O18\Parameters\O16O18WorkflowParameters_2011_08_23_sum5.xml"); //define workflows for parentTarget and childTargets var parentWorkflow = new O16O18ParentIqWorkflow(run, targetedWorkflowParameters); var childWorkflow = new O16O18IqWorkflow(run, targetedWorkflowParameters); var workflowAssigner = new IqWorkflowAssigner(); workflowAssigner.AssignWorkflowToParent(parentWorkflow, executor.Targets); workflowAssigner.AssignWorkflowToChildren(childWorkflow, executor.Targets); executor.DoAlignment(); executor.Execute(); }
public void ExecuteMultipleTargetsTest1() { var util = new IqTargetUtilities(); var testFile = UnitTesting2.FileRefs.RawDataMSFiles.OrbitrapStdFile1; var peaksTestFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_scans5500-6500_peaks.txt"; var targetsFile = @"\\protoapps\UserData\Slysz\Data\MassTags\QCShew_Formic_MassTags_Bin10_all.txt"; WorkflowExecutorBaseParameters executorBaseParameters = new BasicTargetedWorkflowExecutorParameters(); executorBaseParameters.ChromGenSourceDataPeakBR = 3; executorBaseParameters.ChromGenSourceDataSigNoise = 2; executorBaseParameters.TargetsFilePath = targetsFile; executorBaseParameters.OutputFolderBase = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\Unlabelled"; var expectedResultsFilename = Path.Combine(executorBaseParameters.OutputFolderBase, "IqResults", RunUtilities.GetDatasetName(testFile) + "_iqResults.txt"); if (File.Exists(expectedResultsFilename)) { File.Delete(expectedResultsFilename); } var run = new RunFactory().CreateRun(testFile); var executor = new IqExecutor(executorBaseParameters, run); executor.ChromSourceDataFilePath = peaksTestFile; executor.LoadAndInitializeTargets(targetsFile); executor.Targets = (from n in executor.Targets where n.ElutionTimeTheor > 0.305 && n.ElutionTimeTheor < 0.325 select n).Take(10).ToList(); var targetedWorkflowParameters = new BasicTargetedWorkflowParameters(); targetedWorkflowParameters.ChromNETTolerance = 0.5; //define workflows for parentTarget and childTargets var parentWorkflow = new BasicIqWorkflow(run, targetedWorkflowParameters); var childWorkflow = new BasicIqWorkflow(run, targetedWorkflowParameters); var workflowAssigner = new IqWorkflowAssigner(); workflowAssigner.AssignWorkflowToParent(parentWorkflow, executor.Targets); workflowAssigner.AssignWorkflowToChildren(childWorkflow, executor.Targets); //Main line for executing IQ: executor.Execute(); //Test the results... Assert.IsTrue(File.Exists(expectedResultsFilename), "results file doesn't exist"); var numResultsInResultsFile = 0; var outputToConsole = true; using (var reader = new StreamReader(expectedResultsFilename)) { while (reader.Peek() != -1) { var line = reader.ReadLine(); numResultsInResultsFile++; if (outputToConsole) { Console.WriteLine(line); } } } Assert.IsTrue(numResultsInResultsFile > 1, "No results in output file"); //the Result Tree is flattened out in the results file. Assert.IsTrue(numResultsInResultsFile == 11); //the results in the Executor are in the a Result tree. So there should be just 10. Assert.AreEqual(10, executor.Results.Count); }
public void IqExecutor_StandardO16O18Testing_VladAlz() { //see JIRA https://jira.pnnl.gov/jira/browse/OMCS-628 var executorParametersFile = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\O16O18_standard_testing\Test1_VladAlz\Parameters\ExecutorParameters1.xml"; var executorParameters = new BasicTargetedWorkflowExecutorParameters(); executorParameters.LoadParameters(executorParametersFile); executorParameters.OutputFolderBase = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\O16O18_standard_testing\Test1_VladAlz"; var testDatasetPath = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\O16O18_standard_testing\Test1_VladAlz\RawData\Alz_P01_A01_097_26Apr12_Roc_12-03-15.RAW"; executorParameters.IsMassAlignmentPerformed = true; executorParameters.IsNetAlignmentPerformed = true; executorParameters.ReferenceTargetsFilePath = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\O16O18_standard_testing\Test1_VladAlz\Targets\MT_Human_ALZ_O18_P836\MassTags_PMT2.txt"; var expectedResultsFilename = Path.Combine(executorParameters.OutputFolderBase, "IqResults", RunUtilities.GetDatasetName(testDatasetPath) + "_iqResults.txt"); if (File.Exists(expectedResultsFilename)) { File.Delete(expectedResultsFilename); } var autoSavedExecutorParametersFile = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\O16O18_standard_testing\Test1_VladAlz\Parameters\ExecutorParameters1_autosaved.xml"; executorParameters.SaveParametersToXML(autoSavedExecutorParametersFile); var run = new RunFactory().CreateRun(testDatasetPath); var executor = new IqExecutor(executorParameters, run); var targetsFile = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\O16O18_standard_testing\Test1_VladAlz\Targets\MT_Human_ALZ_O18_P836\MassTags_PMT2_First60.txt"; targetsFile = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\O16O18_standard_testing\Test1_VladAlz\Targets\MT_Human_ALZ_O18_P836\MassTags_PMT2.txt"; executor.LoadAndInitializeTargets(targetsFile); executor.SetupMassAndNetAlignment(); var testTarget = 9282; executor.Targets = (from n in executor.Targets where n.ID == testTarget select n).ToList(); var targetedWorkflowParameters = new BasicTargetedWorkflowParameters(); targetedWorkflowParameters.ChromNETTolerance = 0.025; targetedWorkflowParameters.ChromGeneratorMode = Globals.ChromatogramGeneratorMode.O16O18_THREE_MONOPEAKS; //define workflows for parentTarget and childTargets var parentWorkflow = new O16O18ParentIqWorkflow(run, targetedWorkflowParameters); var childWorkflow = new O16O18IqWorkflow(run, targetedWorkflowParameters); var workflowAssigner = new IqWorkflowAssigner(); workflowAssigner.AssignWorkflowToParent(parentWorkflow, executor.Targets); workflowAssigner.AssignWorkflowToChildren(childWorkflow, executor.Targets); executor.DoAlignment(); executor.Execute(); IqResultImporter importer = new IqResultImporterBasic(expectedResultsFilename); var allResults = importer.Import(); var result1 = allResults.First(p => p.Target.ID == 9282 && p.Target.ChargeState == 2); Assert.AreEqual(9282, result1.Target.ID); Assert.AreEqual(0.32678m, (decimal)result1.ElutionTimeObs); Assert.AreEqual(4545, result1.LcScanObs); Assert.AreEqual(0.02, (decimal)result1.FitScore); }
public override void LoadAndInitializeTargets(string targetsFilePath) { if (string.IsNullOrEmpty(targetsFilePath)) { IqLogger.Log.Info("IqMassAndNetAligner - no alignment targets were loaded. The inputted targets file path is NULL."); return; } if (!File.Exists(targetsFilePath)) { IqLogger.Log.Info("IqMassAndNetAligner - no alignment targets were loaded. The inputted targets file path is does not exist."); return; } var importer = new IqTargetsFromFirstHitsFileImporter(targetsFilePath); Targets = importer.Import().Where(p => p.QualityScore < 0.01).OrderBy(p => p.ID).ToList(); //Targets = Targets.Where(p => p.Code.Contains("FEQDGENYTGTIDGNMGAYAR")).ToList(); var filteredList = new List <IqTarget>(); //calculate empirical formula for targets using Code and then monoisotopic mass foreach (var iqTarget in Targets) { iqTarget.Code = _peptideUtils.CleanUpPeptideSequence(iqTarget.Code); if (_peptideUtils.ValidateSequence(iqTarget.Code)) { iqTarget.EmpiricalFormula = _peptideUtils.GetEmpiricalFormulaForPeptideSequence(iqTarget.Code, true, true); var calcMonoMass = EmpiricalFormulaUtilities.GetMonoisotopicMassFromEmpiricalFormula(iqTarget.EmpiricalFormula); var monoMassFromFirstHitsFile = iqTarget.MonoMassTheor; var massCalculationsAgree = Math.Abs(monoMassFromFirstHitsFile - calcMonoMass) < 0.02; if (massCalculationsAgree) { iqTarget.MonoMassTheor = calcMonoMass; iqTarget.ElutionTimeTheor = iqTarget.ScanLC / (double)Run.MaxLCScan; filteredList.Add(iqTarget); _targetUtilities.UpdateTargetMissingInfo(iqTarget, true); var chargeStateTarget = new IqTargetMsgfFirstHit(); _targetUtilities.CopyTargetProperties(iqTarget, chargeStateTarget); iqTarget.AddTarget(chargeStateTarget); } } } filteredList = (from n in filteredList group n by new { n.Code, n.ChargeState } into grp select grp.OrderBy(p => p.QualityScore).First() ).ToList(); Targets = filteredList; TargetedWorkflowParameters workflowParameters = new BasicTargetedWorkflowParameters(); workflowParameters.ChromNETTolerance = 0.005; workflowParameters.ChromGenTolerance = 50; //define workflows for parentTarget and childTargets var parentWorkflow = new ChromPeakDeciderIqWorkflow(Run, workflowParameters); var childWorkflow = new ChargeStateChildIqWorkflow(Run, workflowParameters); var workflowAssigner = new IqWorkflowAssigner(); workflowAssigner.AssignWorkflowToParent(parentWorkflow, Targets); workflowAssigner.AssignWorkflowToChildren(childWorkflow, Targets); if (Targets.Count > 0) { IqLogger.Log.Info("IqMassAndNetAligner - Loaded " + Targets.Count + " targets for use in mass and net alignment"); } else { IqLogger.Log.Info("IqMassAndNetAligner - NOTE - no targets have been loaded."); } //IqWorkflowAssigner workflowAssigner = new IqWorkflowAssigner(); //workflowAssigner.AssignWorkflowToParent(workflow, Targets); }
public void ExecutorTest1() { Console.WriteLine(Environment.CurrentDirectory); var util = new IqTargetUtilities(); var testFile = @"\\proto-5\External_Waters_TOF_Xfer\MzML_Files\130716_iPRG14_004.mzML"; //string peaksTestFile = //@"\\protoapps\UserData\Slysz\DeconTools_TestFiles\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_scans5500-6500_peaks.txt"; var targetsFile = @"\\protoapps\UserData\Fujimoto\SangtaeBottomUp\msgfPlus\C~~data~iPRG 2014~130716_iPRG14_004.raw.-1_Filtered.tsv"; WorkflowExecutorBaseParameters executorBaseParameters = new BasicTargetedWorkflowExecutorParameters(); executorBaseParameters.ChromGenSourceDataPeakBR = 3; executorBaseParameters.ChromGenSourceDataSigNoise = 2; executorBaseParameters.TargetsFilePath = targetsFile; executorBaseParameters.OutputFolderBase = @"\\protoapps\UserData\Fujimoto\SangtaeBottomUp\Results"; var expectedResultsFilename = Path.Combine(executorBaseParameters.OutputFolderBase, "IqResults", RunUtilities.GetDatasetName(testFile) + "_iqResults.txt"); if (File.Exists(expectedResultsFilename)) { File.Delete(expectedResultsFilename); } var run = new RunFactory().CreateRun(testFile); var executor = new IqExecutor(executorBaseParameters, run); //executor.ChromSourceDataFilePath = peaksTestFile; executor.LoadAndInitializeTargets(targetsFile); var targetedWorkflowParameters = new BasicTargetedWorkflowParameters(); targetedWorkflowParameters.ChromNETTolerance = 0.05; //define workflows for parentTarget and childTargets var parentWorkflow = new ChromPeakDeciderIqWorkflow(run, targetedWorkflowParameters); var childWorkflow = new ChargeStateChildIqWorkflow(run, targetedWorkflowParameters); var workflowAssigner = new IqWorkflowAssigner(); workflowAssigner.AssignWorkflowToParent(parentWorkflow, executor.Targets); workflowAssigner.AssignWorkflowToChildren(childWorkflow, executor.Targets); //SipperDataDump.DataDumpSetup(@"\\pnl\projects\MSSHARE\Merkley_Eric\For_Grant\IqResults\EXP6B_F1_CSCL_LIGHT_130520020056\EXP6B_F1_CSCL_LIGHT_FULLRESULTS.txt"); //Main line for executing IQ: executor.Execute(); //Test the results... var numResultsInResultsFile = 0; var outputToConsole = true; using (var reader = new StreamReader(expectedResultsFilename)) { while (reader.Peek() != -1) { var line = reader.ReadLine(); numResultsInResultsFile++; if (outputToConsole) { Console.WriteLine(line); } } } }
static int Main(string[] args) { var options = new IqConsoleOptions(); var datasetList = new List <string>(); if (!CommandLine.Parser.Default.ParseArguments(args, options)) { return(-1); } var inputFile = options.InputFile; var inputFileIsAListOfDatasets = inputFile.ToLower().EndsWith(".txt"); if (inputFileIsAListOfDatasets) { using (var reader = new StreamReader(inputFile)) { while (reader.Peek() != -1) { var datsetName = reader.ReadLine(); datasetList.Add(datsetName); } } } else { datasetList.Add(options.InputFile); } var numDatasets = datasetList.Count; var datasetCounter = 0; foreach (var dataset in datasetList) { datasetCounter++; var datasetNameContainsPath = dataset.Contains(@"\"); string currentDatasetPath; if (datasetNameContainsPath) { currentDatasetPath = dataset; } else { if (string.IsNullOrEmpty(options.TemporaryWorkingFolder)) { IqLogger.Log.Fatal("Trying to grab .raw file from DMS, but no temporary working folder was declared. Use option -f. "); break; } if (string.IsNullOrEmpty(options.OutputFolder)) { options.OutputFolder = options.TemporaryWorkingFolder; } var datasetutil = new DatasetUtilities(); //TODO: figure out how to do this while supporting other file types currentDatasetPath = Path.Combine(datasetutil.GetDatasetPath(dataset), dataset + ".raw"); if (currentDatasetPath.ToLower().Contains("purged")) { currentDatasetPath = Path.Combine(datasetutil.GetDatasetPathArchived(dataset), dataset + ".raw"); } } if (!File.Exists(currentDatasetPath)) { IqLogger.Log.Fatal("!!!!!!!!! Dataset not found! Dataset path = " + currentDatasetPath); return(-2); } if (string.IsNullOrEmpty(options.OutputFolder)) { options.OutputFolder = RunUtilities.GetDatasetParentFolder(currentDatasetPath); } var executorParameters = GetExecutorParameters(options); IqLogger.Log.Info("IQ analyzing dataset " + datasetCounter + " of " + numDatasets + ". Dataset = " + dataset); if (options.UseOldIq) { TargetedWorkflowExecutor executor = new BasicTargetedWorkflowExecutor(executorParameters, currentDatasetPath); //executor.Targets.TargetList = executor.Targets.TargetList.Take(10).ToList(); executor.MsgfFdrScoreCutoff = 0.1; executor.Execute(); } else { var run = new RunFactory().CreateRun(currentDatasetPath); var executor = new IqExecutor(executorParameters, run); executor.LoadAndInitializeTargets(executorParameters.TargetsFilePath); executor.SetupMassAndNetAlignment(); executor.DoAlignment(); foreach (var iqTarget in executor.Targets) { TargetedWorkflowParameters workflowParameters = new O16O18WorkflowParameters(); if (iqTarget.ElutionTimeTheor > 0.7 || iqTarget.ElutionTimeTheor < 0.15) { //TODO: remove the hard-coded value workflowParameters.ChromNETTolerance = 0.1; } else { //TODO: remove the hard-coded value workflowParameters.ChromNETTolerance = 0.025; } if (run.MassAlignmentInfo != null && run.MassAlignmentInfo.StdevPpmShiftData > 0) { workflowParameters.ChromGenTolerance = run.MassAlignmentInfo.StdevPpmShiftData * 3; } //define workflows for parentTarget and childTargets // Note: this is currently hard-coded to user O16O18IqWorkflow var parentWorkflow = new ChromPeakDeciderIqWorkflow(run, workflowParameters); var childWorkflow = new O16O18IqWorkflow(run, workflowParameters); var workflowAssigner = new IqWorkflowAssigner(); workflowAssigner.AssignWorkflowToParent(parentWorkflow, iqTarget); workflowAssigner.AssignWorkflowToChildren(childWorkflow, iqTarget); } executor.Execute(); run.Dispose(); } } return(0); }