public void Execute(Run run)
        {
            Check.Require(run != null, "'Run' has not be defined");
            Check.Require(run.Filename != null &&
                          run.Filename.Length > 0, "MS data file ('run') has not been initialized");
            //Check.Require(run.ScanSetCollection != null && run.ScanSetCollection.ScanSetList.Count > 0, "ChromAligner failed. ScanSets have not been defined.");

            if (m_targetUMCFileStoringAlignmentInfo == null)
            {
                var baseFileName = Path.Combine(run.DataSetPath, run.DatasetName);
                m_targetUMCFileStoringAlignmentInfo = baseFileName + "_UMCs.txt";
            }
            Check.Require(File.Exists(m_targetUMCFileStoringAlignmentInfo), "ChromAligner failed. The UMC file from which alignment data is extracted does not exist.");

            var umcs = new UMCCollection();

            var importer = new UMCFileImporter(m_targetUMCFileStoringAlignmentInfo, '\t');

            umcs = importer.Import();

            var scannetPairs = umcs.GetScanNETLookupTable();

            run.NetAlignmentInfo = new NetAlignmentInfoBasic(run.MinLCScan, run.MaxLCScan);
            run.NetAlignmentInfo.SetScanToNETAlignmentData(scannetPairs);
        }
Exemplo n.º 2
0
        public void importUMCsWithO16O18PairedDataTest1()
        {
            UMCCollection   umcs     = new UMCCollection();
            UMCFileImporter importer = new UMCFileImporter(umcO16O18TestFile1, '\t');

            importer.Import(umcs);

            Assert.AreEqual(23073, umcs.UMCList.Count);
        }
Exemplo n.º 3
0
        public void importUMCsTest1()
        {
            UMCCollection   umcs     = new UMCCollection();
            UMCFileImporter importer = new UMCFileImporter(umcTestfile1, '\t');

            importer.Import(umcs);

            Assert.AreEqual(15381, umcs.UMCList.Count);
        }
Exemplo n.º 4
0
        public void filterUMCsByMassTagsTest2()
        {
            UMCCollection   umcs     = new UMCCollection();
            UMCFileImporter importer = new UMCFileImporter(umcO16O18TestFile1, '\t');

            importer.Import(umcs);


            UMCCollection filteredUMCs = new UMCCollection();

            filteredUMCs.UMCList = umcs.FilterUMCsByMassTagMatch(new List <int> {
                22807265, 22580887, 20791942, 20791939, 20750857, 20908613, 20842966, 22598396, 174124103
            });

            Assert.AreEqual(8, filteredUMCs.UMCList.Count);

            filteredUMCs.DisplayUMCExpressionInfo();
        }
Exemplo n.º 5
0
        public void filterOutPairedUMCsTest1()
        {
            UMCCollection   umcs     = new UMCCollection();
            UMCFileImporter importer = new UMCFileImporter(umcO16O18TestFile1, '\t');

            importer.Import(umcs);


            UMCCollection filteredUMCs = new UMCCollection();

            filteredUMCs.UMCList = umcs.FilterOutPairedData();



            Assert.AreEqual(1734, filteredUMCs.UMCList.Count);



            filteredUMCs.DisplayUMCExpressionInfo();
        }
Exemplo n.º 6
0
        public void umcTest2()
        {
            UMCCollection   umcs     = new UMCCollection();
            UMCFileImporter importer = new UMCFileImporter(umcTestfile1, '\t');

            importer.Import(umcs);

            Stopwatch sw = new Stopwatch();

            sw.Start();

            Dictionary <int, double> lookupTable = umcs.GetScanNETLookupTable();

            sw.Stop();

            double netVal = lookupTable[6005];

            netVal = lookupTable[6004];
            Console.Write(sw.ElapsedMilliseconds);
            Assert.AreEqual(0.3216, netVal);
        }
Exemplo n.º 7
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);
        }