public void Import_NET_And_MassAlignment_Test1() { var mzAlignmentInfoFilename = Path.Combine(FileRefs.ImportedData, "QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_MZAlignment.txt"); var NETAlignmentInfoFilename = Path.Combine(FileRefs.ImportedData, "QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_ScanNetAlignment.txt"); var rf = new RunFactory(); var run = rf.CreateRun(DeconTools.UnitTesting2.FileRefs.RawDataMSFiles.OrbitrapStdFile1); var importer = new MassAlignmentInfoFromTextImporter(mzAlignmentInfoFilename); var massAlignmentData = importer.Import(); var massAlignmentInfo = new MassAlignmentInfoLcmsWarp(); massAlignmentInfo.SetMassAlignmentData(massAlignmentData); run.MassAlignmentInfo = massAlignmentInfo; var netAlignmentInfoImporter = new NETAlignmentFromTextImporter(NETAlignmentInfoFilename); var scanNETdata = netAlignmentInfoImporter.Import(); run.NetAlignmentInfo.SetScanToNETAlignmentData(scanNETdata); float testScan = 6439; var testMZ = 698.875137f; //QCSHEW massTag 37003; m/z 698.875137 (2+) See Redmine issue 627: http://redmine.pnl.gov/issues/627 var ppmshift = run.MassAlignmentInfo.GetPpmShift(testMZ, (int)testScan); Console.WriteLine("ppm shift = " + ppmshift); var testScan2 = 6005; var testNET1 = run.NetAlignmentInfo.GetNETValueForScan(testScan2); Assert.AreEqual(0.3252918m, (decimal)Math.Round(testNET1, 7)); Assert.AreEqual(-4.3, (decimal)Math.Round(ppmshift, 1)); }
public void ApplyViperMassAlignmentDataFromViperTest1() { var testFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.RAW"; var run = new RunFactory().CreateRun(testFile); var calibrationData = new ViperMassCalibrationData(); calibrationData.MassError = -3.6; var massAlignmentInfo = new MassAlignmentInfoLcmsWarp(); massAlignmentInfo.SetMassAlignmentData(calibrationData); run.MassAlignmentInfo = massAlignmentInfo; var testMZ = 974.504343924692; var alignedMZ = run.GetAlignedMZ(testMZ); var ppmDiff = (testMZ - alignedMZ) / testMZ * 1e6; Console.WriteLine("input m/z= " + testMZ); Console.WriteLine("aligned m/z= " + alignedMZ); Console.WriteLine("ppmDiff= " + ppmDiff); Assert.AreEqual(-3.6, (decimal)Math.Round(ppmDiff, 1)); }
public void ImportMassAndTimePPMCorrections_and_Try_Alignment_Test1() { var importFilename = Path.Combine(FileRefs.ImportedData, "QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_MZAlignment.txt"); var rf = new RunFactory(); var run = rf.CreateRun(DeconTools.UnitTesting2.FileRefs.RawDataMSFiles.OrbitrapStdFile1); var importer = new MassAlignmentInfoFromTextImporter(importFilename); var massAlignmentData = importer.Import(); var massAlignmentInfo = new MassAlignmentInfoLcmsWarp(); massAlignmentInfo.SetMassAlignmentData(massAlignmentData); run.MassAlignmentInfo = massAlignmentInfo; float testScan = 6439; var testMZ = 698.875137f; //QCSHEW massTag 37003; m/z 698.875137 (2+) See Redmine issue 627: http://redmine.pnl.gov/issues/627 var ppmshift = run.MassAlignmentInfo.GetPpmShift(testMZ, (int)testScan); Console.WriteLine("ppm shift = " + ppmshift); Assert.AreEqual(-4.3, (decimal)Math.Round(ppmshift, 1)); }
public void Execute(Run run) { Check.Require(run != null, "Run is not defined."); Check.Require(_featuresToBeAligned.HasResults, "Features for alignment have not been defined."); Check.Require(_massTagList != null && _massTagList.Count > 0, "The reference set of MassTags used in alignment have not been defined."); var lcmswarpAlignmentInfo = GetAlignment(_massTagList, _featuresToBeAligned.Results); var massAlignmentInfo = new MassAlignmentInfoLcmsWarp(); massAlignmentInfo.AlignmentInfo = lcmswarpAlignmentInfo; run.MassAlignmentInfo = massAlignmentInfo; }
public void LoadAndApplyMassAlignmentFromViperDataTest1() { var testFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.RAW"; var run = new RunFactory().CreateRun(testFile); var viperMassAlignmentFile = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\AlignmentInfo\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_MassAndGANETErrors_BeforeRefinement.txt"; var loader = new ViperMassCalibrationLoader(viperMassAlignmentFile); /* * From unit test: targetedWorkflow_alignUsingDataFromFiles * TargetID = 24702 * ChargeState = 3 * theor monomass= 2920.5319802 * theor m/z= 974.517936556667 * obs monomass= 2920.49120230408 * obs m/z= 974.504343924692 * ppmError before= 13.9597398284934 * ppmError after= 10.8899784905986 * calibrated mass= 2920.50017566955 * calibrated mass2= 2920.50017566955 * Database NET= 0.4197696 * Result NET= 0.42916464805603 * Result NET Error= -0.00934833288192749 * NumChromPeaksWithinTol= 3 * * */ var calibrationData = loader.ImportMassCalibrationData(); var massAlignmentInfo = new MassAlignmentInfoLcmsWarp(); massAlignmentInfo.SetMassAlignmentData(calibrationData); run.MassAlignmentInfo = massAlignmentInfo; var testMZ = 974.504343924692; var alignedMZ = run.GetAlignedMZ(testMZ); var ppmDiff = (testMZ - alignedMZ) / testMZ * 1e6; Console.WriteLine("input m/z= " + testMZ); Console.WriteLine("aligned m/z= " + alignedMZ); Console.WriteLine("ppmDiff= " + ppmDiff); Assert.AreEqual(-3.6, (decimal)Math.Round(ppmDiff, 1)); }
public void check_alignment_of_MZ() { var mzAlignmentInfoFilename = Path.Combine(FileRefs.ImportedData, "QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_MZAlignment.txt"); var NETAlignmentInfoFilename = Path.Combine(FileRefs.ImportedData, "QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_ScanNetAlignment.txt"); var rf = new RunFactory(); var run = rf.CreateRun(DeconTools.UnitTesting2.FileRefs.RawDataMSFiles.OrbitrapStdFile1); var importer = new MassAlignmentInfoFromTextImporter(mzAlignmentInfoFilename); var massAlignmentData = importer.Import(); var massAlignmentInfo = new MassAlignmentInfoLcmsWarp(); massAlignmentInfo.SetMassAlignmentData(massAlignmentData); run.MassAlignmentInfo = massAlignmentInfo; var netAlignmentInfoImporter = new NETAlignmentFromTextImporter(NETAlignmentInfoFilename); var scanNETdata = netAlignmentInfoImporter.Import(); run.NetAlignmentInfo.SetScanToNETAlignmentData(scanNETdata); float testScan = 6439; var theorMZ = 698.875137f; //QCSHEW massTag 37003; m/z 698.875137 (2+) See Redmine issue 627: http://redmine.pnl.gov/issues/627 var ppmshift = run.MassAlignmentInfo.GetPpmShift(theorMZ, (int)testScan); Console.WriteLine("ppm shift = " + ppmshift); var observedMZ = 698.8721; var alignedTargetMZ = run.GetTargetMZAligned(theorMZ); var differenceInMZ = Math.Abs(observedMZ - alignedTargetMZ); Console.WriteLine("theor m/z of monoisotopic peak = " + theorMZ.ToString("0.0000")); Console.WriteLine("observed m/z of monoisotopic peak = " + observedMZ.ToString("0.0000")); Console.WriteLine("aligned theor m/z = " + alignedTargetMZ.ToString("0.00000")); Assert.IsTrue(differenceInMZ < 0.001); }
public void GetCalibratedMass1() { //see https://jira.pnnl.gov/jira/browse/OMCS-870 var testFile = @"\\protoapps\DataPkgs\Public\2013\743_Mycobacterium_tuberculosis_Cys_and_Ser_ABP\IQ_Analysis\Testing\LNA_A_Stat_Sample_SC_28_LNA_ExpA_Expo_Stat_SeattleBioMed_15Feb13_Cougar_12-12-36.raw"; var run = new RunFactory().CreateRun(testFile); var calibrationData = new ViperMassCalibrationData(); calibrationData.MassError = 4.8; var massAlignmentInfo = new MassAlignmentInfoLcmsWarp(); massAlignmentInfo.SetMassAlignmentData(calibrationData); run.MassAlignmentInfo = massAlignmentInfo; var observedMZ = 440.5887078; var theorMZ = 440.5858315; var calibratedMZ = run.GetAlignedMZ(observedMZ); Assert.AreEqual(440.5866m, (decimal)Math.Round(calibratedMZ, 4)); var ppmDiffBefore = (observedMZ - theorMZ) / theorMZ * 1e6; var ppmDiffAfter = (calibratedMZ - theorMZ) / theorMZ * 1e6; Console.WriteLine("input m/z= " + observedMZ); Console.WriteLine("calibrated m/z= " + calibratedMZ); Console.WriteLine("ppmDiffBeforeCalibration= " + ppmDiffBefore); Console.WriteLine("ppmDiffAftereCalibration= " + ppmDiffAfter); var theorMZToLookForInRawData = run.GetTargetMZAligned(theorMZ); var ppmDiffTheor = (theorMZToLookForInRawData - theorMZ) / theorMZ * 1e6; Console.WriteLine(); Console.WriteLine("Theor m/z = " + theorMZ); Console.WriteLine("Theor m/z to look for = " + theorMZToLookForInRawData); Console.WriteLine("ppmDiff = " + ppmDiffTheor); Assert.AreEqual(4.8m, (decimal)Math.Round(ppmDiffTheor, 1)); }
public static bool AlignRunUsingAlignmentInfoInFiles(Run run, string alignmentDataFolder = "") { bool alignmentSuccessful; string basePath; if (string.IsNullOrEmpty(alignmentDataFolder)) { basePath = run.DataSetPath; } else { if (Directory.Exists(alignmentDataFolder)) { basePath = alignmentDataFolder; } else { throw new DirectoryNotFoundException( "Cannot align dataset. Source alignment folder does not exist. Alignment folder = " + alignmentDataFolder); } } var expectedMZAlignmentFile = Path.Combine(basePath, run.DatasetName + "_MZAlignment.txt"); var expectedNETAlignmentFile = Path.Combine(basePath, run.DatasetName + "_NETAlignment.txt"); //first will try to load the multiAlign alignment info if (File.Exists(expectedMZAlignmentFile)) { var importer = new MassAlignmentInfoFromTextImporter(expectedMZAlignmentFile); var massAlignmentData = importer.Import(); var massAlignmentInfo = new MassAlignmentInfoLcmsWarp(); massAlignmentInfo.SetMassAlignmentData(massAlignmentData); run.MassAlignmentInfo = massAlignmentInfo; } if (File.Exists(expectedNETAlignmentFile)) { var netAlignmentInfoImporter = new NETAlignmentFromTextImporter(expectedNETAlignmentFile); var scanNETList = netAlignmentInfoImporter.Import(); NetAlignmentInfo netAlignmentInfo = new NetAlignmentInfoBasic(run.MinLCScan, run.MaxLCScan); netAlignmentInfo.SetScanToNETAlignmentData(scanNETList); run.NetAlignmentInfo = netAlignmentInfo; } //if still not aligned, try to get the NET alignment from UMCs file. (this is the older way to do it) if (run.NETIsAligned) { alignmentSuccessful = true; } else { var alignmentDirInfo = new DirectoryInfo(basePath); var umcFileInfo = alignmentDirInfo.GetFiles("*_umcs.txt"); var umcFileCount = umcFileInfo.Count(); if (umcFileCount == 1) { var targetUmcFileName = umcFileInfo.First().FullName; var importer = new UMCFileImporter(targetUmcFileName, '\t'); var umcs = importer.Import(); var scannetPairs = umcs.GetScanNETLookupTable(); NetAlignmentInfo netAlignmentInfo = new NetAlignmentInfoBasic(run.MinLCScan, run.MaxLCScan); netAlignmentInfo.SetScanToNETAlignmentData(scannetPairs); run.NetAlignmentInfo = netAlignmentInfo; Console.WriteLine(run.DatasetName + " aligned."); alignmentSuccessful = true; } else if (umcFileCount > 1) { var expectedUMCName = Path.Combine(basePath, run.DatasetName + "_UMCs.txt"); if (File.Exists(expectedUMCName)) { var importer = new UMCFileImporter(expectedUMCName, '\t'); var umcs = importer.Import(); var scannetPairs = umcs.GetScanNETLookupTable(); NetAlignmentInfo netAlignmentInfo = new NetAlignmentInfoBasic(run.MinLCScan, run.MaxLCScan); netAlignmentInfo.SetScanToNETAlignmentData(scannetPairs); run.NetAlignmentInfo = netAlignmentInfo; Console.WriteLine(run.DatasetName + " NET aligned using UMC file: " + expectedUMCName); alignmentSuccessful = true; } else { throw new FileNotFoundException("Trying to align dataset: " + run.DatasetName + " but UMC file not found."); } } else { Console.WriteLine(run.DatasetName + " is NOT NET aligned."); alignmentSuccessful = false; } } //mass is still not aligned... use data in viper output file: _MassAndGANETErrors_BeforeRefinement.txt if (run.MassIsAligned == false) { var expectedViperMassAlignmentFile = Path.Combine(basePath, run.DatasetName + "_MassAndGANETErrors_BeforeRefinement.txt"); if (File.Exists(expectedViperMassAlignmentFile)) { var importer = new ViperMassCalibrationLoader(expectedViperMassAlignmentFile); var viperCalibrationData = importer.ImportMassCalibrationData(); var massAlignmentInfo = new MassAlignmentInfoLcmsWarp(); massAlignmentInfo.SetMassAlignmentData(viperCalibrationData); run.MassAlignmentInfo = massAlignmentInfo; Console.WriteLine(run.DatasetName + "- mass aligned using file: " + expectedViperMassAlignmentFile); alignmentSuccessful = true; } else { Console.WriteLine(run.DatasetName + " is NOT mass aligned"); } } return(alignmentSuccessful); }
public void ensure_alignmentIsBeingUsed_duringProcessing_test2() { var massTagFile = @"\\protoapps\UserData\Slysz\Data\MassTags\QCShew_Formic_MassTags_Bin10_all.txt"; var mzAlignmentInfoFilename = @"D:\Data\Orbitrap\QC_Shew_08_04-pt1-3_15Apr09_Sphinx_09-02-16_MZAlignment.txt"; var NETAlignmentInfoFilename = @"D:\Data\Orbitrap\QC_Shew_08_04-pt1-3_15Apr09_Sphinx_09-02-16_NETAlignment.txt"; var rawDataFile = @"D:\Data\Orbitrap\QC_Shew_08_04-pt1-3_15Apr09_Sphinx_09-02-16.RAW"; var peaksDataFile = @"D:\Data\Orbitrap\QC_Shew_08_04-pt1-3_15Apr09_Sphinx_09-02-16_peaks.txt"; var run = DeconTools.Backend.Utilities.RunUtilities.CreateAndLoadPeaks(rawDataFile, peaksDataFile); var importer = new MassAlignmentInfoFromTextImporter(mzAlignmentInfoFilename); var massAlignmentData = importer.Import(); var massAlignmentInfo = new MassAlignmentInfoLcmsWarp(); massAlignmentInfo.SetMassAlignmentData(massAlignmentData); run.MassAlignmentInfo = massAlignmentInfo; var mtc = new TargetCollection(); var mtimporter = new MassTagFromTextFileImporter(massTagFile); mtc = mtimporter.Import(); var testMassTagID = 24730; run.CurrentMassTag = (from n in mtc.TargetList where n.ID == testMassTagID && n.ChargeState == 2 select n).First(); //first will execute workflow on a dataset that was NOT aligned TargetedWorkflowParameters parameters = new BasicTargetedWorkflowParameters(); parameters.ChromNETTolerance = 0.2; //use a very wide tolerance parameters.ChromGenTolerance = 5; parameters.MSToleranceInPPM = 15; var workflow = new BasicTargetedWorkflow(run, parameters); workflow.Execute(); var result = run.ResultCollection.GetTargetedResult(run.CurrentMassTag); Assert.IsTrue(result.ChromPeakSelected != null); Assert.AreEqual(9367, (int)result.ChromPeakSelected.XValue); var netDiff = result.Target.NormalizedElutionTime - result.GetNET(); Console.WriteLine("NET diff before alignment = " + netDiff); var expectedNETDiff = 0.071m; Assert.AreEqual(expectedNETDiff, (decimal)Math.Round(netDiff, 3)); //import NET alignment information var netAlignmentInfoImporter = new NETAlignmentFromTextImporter(NETAlignmentInfoFilename); var scanNETdata = netAlignmentInfoImporter.Import(); run.NetAlignmentInfo.SetScanToNETAlignmentData(scanNETdata); parameters = new BasicTargetedWorkflowParameters(); parameters.ChromNETTolerance = 0.01; //use a more narrow tolerance parameters.ChromGenTolerance = 5; parameters.MSToleranceInPPM = 15; workflow = new BasicTargetedWorkflow(run, parameters); workflow.Execute(); netDiff = result.Target.NormalizedElutionTime - result.GetNET(); Console.WriteLine("NET diff after alignment = " + netDiff); Assert.IsTrue(result.ChromPeakSelected != null); var expectedNETDiffMaximum = 0.01; Assert.IsTrue(netDiff < expectedNETDiffMaximum); }