예제 #1
0
        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));
        }
예제 #2
0
        public void Import_NET_And_MassAlignment_Test1()
        {
            string mzAlignmentInfoFilename  = Path.Combine(FileRefs.OutputFolderPath, "QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_MZAlignment.txt");
            string NETAlignmentInfoFilename = Path.Combine(FileRefs.OutputFolderPath, "QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_ScanNetAlignment.txt");

            RunFactory rf  = new RunFactory();
            Run        run = rf.CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            MassAlignmentInfoFromTextImporter importer = new MassAlignmentInfoFromTextImporter(mzAlignmentInfoFilename);

            run.AlignmentInfo = importer.Import();

            NETAlignmentFromTextImporter netAlignmentInfoImporter = new NETAlignmentFromTextImporter(NETAlignmentInfoFilename);

            netAlignmentInfoImporter.ImportIntoAlignmentInfo(run.AlignmentInfo);   //this will append the NET alignment info to the AlignmentInfo object

            float testScan = 6439;
            float testMZ   = 698.875137f;  //QCSHEW massTag 37003; m/z 698.875137 (2+)   See Redmine issue 627:  http://redmine.pnl.gov/issues/627

            float ppmshift = run.AlignmentInfo.GetPPMShiftFromTimeMZ(testScan, testMZ);

            Console.WriteLine("ppm shift = " + ppmshift);

            float testScan2 = 6005;
            float testNET1  = run.AlignmentInfo.GetNETFromTime(testScan2);

            Assert.AreEqual(0.3253423m, (decimal)testNET1);
            Assert.AreEqual(-4.3, (decimal)Math.Round(ppmshift, 1));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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);
        }
예제 #5
0
        public void ImportMassAndTimePPMCorrections_and_Try_Alignment_Test1()
        {
            string importFilename = Path.Combine(FileRefs.OutputFolderPath, "QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_MZAlignment.txt");

            RunFactory rf  = new RunFactory();
            Run        run = rf.CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            MassAlignmentInfoFromTextImporter importer = new MassAlignmentInfoFromTextImporter(importFilename);

            run.AlignmentInfo = importer.Import();

            float testScan = 6439;
            float testMZ   = 698.875137f;  //QCSHEW massTag 37003; m/z 698.875137 (2+)    See Redmine issue 627:  http://redmine.pnl.gov/issues/627

            float ppmshift = run.AlignmentInfo.GetPPMShiftFromTimeMZ(testScan, testMZ);

            Console.WriteLine("ppm shift = " + ppmshift);

            Assert.AreEqual(-4.3, (decimal)Math.Round(ppmshift, 1));
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }