Exemple #1
0
        public void TestFeatureAlignment()
        {
            const string outFilePath = @"\\protoapps\UserData\Jungkap\Lewy\aligned\promex_crosstab_temp.tsv";


            //CPTAC_Intact_CR32A_24Aug15_Bane_15-02-06-RZ
            var prsmReader = new ProteinSpectrumMatchReader();
            var tolerance  = new Tolerance(10);
            var alignment  = new LcMsFeatureAlignment(new AnalysisCompRef.CompRefFeatureComparer(tolerance));

            for (var i = 0; i < NdataSet; i++)
            {
                var rawFile   = string.Format(@"{0}\{1}.pbf", PbfPath, GetDataSetNames(i));
                var mspFile   = string.Format(@"{0}\{1}_IcTda.tsv", MsPfFolder, GetDataSetNames(i));
                var mspFile2  = string.Format(@"{0}\{1}_IcTda.tsv", MsPfFolder2, GetDataSetNames(i));
                var ms1FtFile = string.Format(@"{0}\{1}.ms1ft", Ms1FtFolder, GetDataSetNames(i));
                Console.WriteLine(rawFile);
                var run       = PbfLcMsRun.GetLcMsRun(rawFile);
                var prsmList1 = prsmReader.LoadIdentificationResult(mspFile, ProteinSpectrumMatch.SearchTool.MsPathFinder);
                var prsmList2 = prsmReader.LoadIdentificationResult(mspFile2, ProteinSpectrumMatch.SearchTool.MsPathFinder);
                prsmList1.AddRange(prsmList2);

                var prsmList = MergePrsm(prsmList1);
                var features = LcMsFeatureAlignment.LoadProMexResult(i, ms1FtFile, run);

                for (var j = 0; j < prsmList.Count; j++)
                {
                    var match = prsmList[j];
                    match.ProteinId = match.ProteinName;
                }

                // tag features by PrSMs
                for (var j = 0; j < features.Count; j++)
                {
                    //features[j].ProteinSpectrumMatches = new ProteinSpectrumMatchSet(i);
                    var massTol = tolerance.GetToleranceAsTh(features[j].Mass);
                    foreach (var match in prsmList)
                    {
                        if (features[j].MinScanNum < match.ScanNum && match.ScanNum < features[j].MaxScanNum && Math.Abs(features[j].Mass - match.Mass) < massTol)
                        {
                            features[j].ProteinSpectrumMatches.Add(match);
                        }
                    }
                }

                alignment.AddDataSet(i, features, run);
            }

            alignment.AlignFeatures();

            Console.WriteLine("{0} alignments ", alignment.CountAlignedFeatures);

            for (var i = 0; i < NdataSet; i++)
            {
                alignment.FillMissingFeatures(i);
                Console.WriteLine("{0} has been processed", GetDataSetNames(i));
            }

            OutputCrossTabWithId(outFilePath, alignment);
        }
Exemple #2
0
        public void ScorePSM(int scan, string sequenceStr)
        {
            // Set input file paths.
            const string specFilePath =
                @"\\protoapps\userdata\Wilkins\UIMF Files\9 pep mix 365 mTorr with ims 45V CID\9 pep mix 365 mTorr with ims 45V CID.pbf";

            var lcmsRun = PbfLcMsRun.GetLcMsRun(specFilePath);

            var productSpectrum = lcmsRun.GetSpectrum(scan) as ProductSpectrum;

            Assert.NotNull(productSpectrum);

            var modification = Modification.RegisterAndGetModification("oh->nh2", new Composition(0, 1, 1, -1, 0));

            Assert.NotNull(modification);

            var searchModifications = new List <SearchModification>
            {
                new SearchModification(Modification.Get("oh->nh2"), 'M', SequenceLocation.ProteinCTerm, true),
                new SearchModification(Modification.Get("oh->nh2"), 'Q', SequenceLocation.ProteinCTerm, true),
                new SearchModification(Modification.PyroGluE, 'R', SequenceLocation.ProteinNTerm, true)
            };

            var aminoAcidSet = new AminoAcidSet(searchModifications, 1);
            var sequence     = this.LoadSequence(sequenceStr, aminoAcidSet);

            //var scorerFactory = new ScorerFactory(new Tolerance(30, ToleranceUnit.Ppm), 1, 5);
            //var scorer = scorerFactory.GetScorer(productSpectrum);

            //var score = IonUtils.ScoreSequence(scorer, sequence);

            //Console.WriteLine(score);
        }
Exemple #3
0
        public void TestDeconvolution()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            if (!File.Exists(TestRawFilePath))
            {
                Assert.Ignore(@"Skipping test " + methodName + @" since file not found: " + TestRawFilePath);
            }

            const int minScanNum = 46454;   // 635.43
            const int maxScanNum = 46661;   // 638.90
            const int MAX_POINTS = 50;

            var run = PbfLcMsRun.GetLcMsRun(TestRawFilePath) as PbfLcMsRun;

            if (run == null)
            {
                return;
            }
            var summedSpec = run.GetSummedMs1Spectrum(minScanNum, maxScanNum);

            summedSpec.FilterNoise(50.0);
            // summedSpec.Display(MAX_POINTS);

            var deconvoluted = ProductScorerBasedOnDeconvolutedSpectra.GetDeconvolutedSpectrum(summedSpec, 2, 45, new Tolerance(10), 0.9, 2);

            deconvoluted.Display(MAX_POINTS);
        }
Exemple #4
0
        /// <summary>
        /// Shows or hides instrument Precursor m/z and mass from the instrument
        /// Reads data from LCMSRun if necessary
        /// </summary>
        /// <param name="value">Should the instrument data be shown?</param>
        /// <param name="pbfLcmsRun">LCMSRun for this data set.</param>
        /// <returns>Asynchronous task.</returns>
        public async Task ToggleShowInstrumentDataAsync(bool value, PbfLcMsRun pbfLcmsRun)
        {
            if (value)
            {
                if (pbfLcmsRun != null)
                {
                    var scans = this.Data;
                    foreach (var scan in scans.Where(scan => scan.Sequence.Count == 0))
                    {
                        PrSm            scan1           = scan;
                        IsolationWindow isolationWindow = await Task.Run(() => pbfLcmsRun.GetIsolationWindow(scan1.Scan));

                        scan.PrecursorMz = isolationWindow.MonoisotopicMz ?? double.NaN;
                        scan.Charge      = isolationWindow.Charge ?? 0;
                        scan.Mass        = isolationWindow.MonoisotopicMass ?? double.NaN;
                    }
                }
            }
            else
            {
                var scans = this.Data;
                foreach (var scan in scans.Where(scan => scan.Sequence.Count == 0))
                {
                    scan.PrecursorMz = double.NaN;
                    scan.Charge      = 0;
                    scan.Mass        = double.NaN;
                }
            }
        }
Exemple #5
0
 public static string ConvertToPbf(string specFilePath, IMassSpecDataReader specReader,
                                   double precursorSignalToNoiseRatioThreshold, double productSignalToNoiseRatioThreshold, string pbfFilePath = null,
                                   IProgress <ProgressData> progress = null)
 {
     return(PbfLcMsRun.ConvertToPbf(specFilePath, MassSpecDataReaderFactory.GetMassSpecDataReader(specFilePath),
                                    precursorSignalToNoiseRatioThreshold, productSignalToNoiseRatioThreshold, pbfFilePath, progress));
 }
Exemple #6
0
 public void WriteAsPbf(string outputFilePath, IProgress <ProgressData> progress = null)
 {
     using (var writer = new BinaryWriter(File.Open(outputFilePath, FileMode.Create)))
     {
         PbfLcMsRun.WriteAsPbf(this, writer, progress);
     }
 }
Exemple #7
0
        /// <summary>
        /// Returns InformedProteomics LcMsRun object from mass spec data types including .raw and .mzml
        /// </summary>
        /// <param name="rawFilePath"></param>
        /// <returns></returns>
        public LcMsRun GetLcMsData(string rawFilePath)
        {
            var progress = new Progress <ProgressData>();

            progress.ProgressChanged += Progress_ProgressChanged;

            var run = PbfLcMsRun.GetLcMsRun(rawFilePath, progress);

            /*
             * string ext = Path.GetExtension(rawFilePath);
             * switch (ext.ToLower())
             * {
             *  case ".raw":
             *      run = PbfLcMsRun.GetLcMsRun(rawFilePath, MassSpecDataType.XCaliburRun);
             *      break;
             *  case ".mzml":
             *      run = PbfLcMsRun.GetLcMsRun(rawFilePath, MassSpecDataType.MzMLFile);
             *      break;
             *  case ".gz":
             *      if (rawFilePath.ToLower().EndsWith(".mzml.gz"))
             *      {
             *          run = PbfLcMsRun.GetLcMsRun(rawFilePath, MassSpecDataType.MzMLFile);
             *      }
             *      break;
             * }*/

            return(run);
        }
Exemple #8
0
        public void TestGeneratingProductXic()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            if (!File.Exists(TestRawFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, TestRawFilePath);
            }

            var run = InMemoryLcMsRun.GetLcMsRun(TestRawFilePath);

//            const string rafFilePath = @"C:\cygwin\home\kims336\Data\QCShewQE\QC_Shew_13_04_A_17Feb14_Samwise_13-07-28.raf";
            const string rafFilePath = @"H:\Research\Jarret\10mz\raw\Q_2014_0523_50_10_fmol_uL_10mz.raf";

            if (!File.Exists(rafFilePath))
            {
                Assert.Ignore(@"Skipping raf portion of test {0} since file not found: {1}", methodName, rafFilePath);
            }

            var rafRun = new PbfLcMsRun(rafFilePath);

            const double precursorIonMz = 815.16;
            const double productIonMz   = 902.445;
            var          tolerance      = new Tolerance(10);
            var          xic1           = run.GetFullProductExtractedIonChromatogram(productIonMz, tolerance, precursorIonMz);
//            xic1.Display();
            var xic2 = rafRun.GetFullProductExtractedIonChromatogram(productIonMz, tolerance, precursorIonMz);

//            xic2.Display();
            Assert.True(xic1.Equals(xic2));
            Console.WriteLine(@"Done");
        }
Exemple #9
0
        public void TestProMexFilter()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            const string specFilePath = @"\\proto-2\UnitTest_Files\InformedProteomics_TestFiles\TopDown\ProductionQCShew\QC_Shew_Intact_26Sep14_Bane_C2Column3.raw";

            if (!File.Exists(specFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, specFilePath);
            }

            var run = PbfLcMsRun.GetLcMsRun(specFilePath, 0, 0);

            const string ms1FtPath = @"\\proto-2\UnitTest_Files\InformedProteomics_TestFiles\TopDown\ProductionQCShew\QC_Shew_Intact_26Sep14_Bane_C2Column3.ms1ft";

            if (!File.Exists(ms1FtPath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, ms1FtPath);
            }

            var filter = new Ms1FtFilter(run, new Tolerance(10), ms1FtPath);

//            Console.WriteLine("ScanNums: {0}", string.Join("\t",filter.GetMatchingMs2ScanNums(8480.327609)));
            Assert.IsTrue(filter.GetMatchingMs2ScanNums(8480.327609).Contains(5255));
        }
Exemple #10
0
        public void TestIsosFilter()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            const string isosFilePath = @"H:\Research\QCShew_TopDown\Production\ICRTools\QC_Shew_Intact_26Sep14_Bane_C2Column3_Isos.csv";

            if (!File.Exists(isosFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, isosFilePath);
            }

            const string rawFilePath = @"H:\Research\QCShew_TopDown\Production\QC_Shew_Intact_26Sep14_Bane_C2Column3.raw";

            if (!File.Exists(rawFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, rawFilePath);
            }

            var run    = PbfLcMsRun.GetLcMsRun(rawFilePath);
            var filter = new IsosFilter(run, new Tolerance(10), isosFilePath);

            Console.WriteLine(string.Join("\t", filter.GetMatchingMs2ScanNums(30261.68374)));
        }
Exemple #11
0
        public void TestSumMs1Spectra()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            if (!File.Exists(TestRawFilePath))
            {
                Assert.Ignore(@"Skipping test " + methodName + @" since file not found: " + TestRawFilePath);
            }

            const int minScanNum = 46454;
            const int maxScanNum = 46661;
            const int MAX_POINTS = 50;

            var run = PbfLcMsRun.GetLcMsRun(TestRawFilePath) as PbfLcMsRun;

            if (run == null)
            {
                return;
            }
            var summedSpec = run.GetSummedMs1Spectrum(minScanNum, maxScanNum);

            summedSpec.Display(MAX_POINTS);
        }
Exemple #12
0
        public void TestFeatureAlignment()
        {
            const string outFilePath = @"\\protoapps\UserData\Jungkap\CompRef\aligned\promex_crosstab_temp.tsv";

            var runLabels = new[] { "32A", "32B", "32C", "32D", "32E", "32F", "32G", "33A", "33B", "33C", "33D", "33E", "33F", "33G" };
            var nDataset  = runLabels.Length;

            var prsmReader = new ProteinSpectrumMatchReader();
            var tolerance  = new Tolerance(10);
            var alignment  = new LcMsFeatureAlignment(new CompRefFeatureComparer(tolerance));

            for (var i = 0; i < nDataset; i++)
            {
                var rawFile   = string.Format(@"{0}\CPTAC_Intact_CR{1}_24Aug15_Bane_15-02-06-RZ.pbf", RawFolder, runLabels[i]);
                var mspFile   = string.Format(@"{0}\CPTAC_Intact_CR{1}_24Aug15_Bane_15-02-06-RZ_IcTda.tsv", MsPfFolder, runLabels[i]);
                var ms1FtFile = string.Format(@"{0}\CPTAC_Intact_CR{1}_24Aug15_Bane_15-02-06-RZ.ms1ft", Ms1FtFolder, runLabels[i]);

                var run      = PbfLcMsRun.GetLcMsRun(rawFile);
                var features = LcMsFeatureAlignment.LoadProMexResult(i, ms1FtFile, run);

                if (File.Exists(mspFile))
                {
                    var prsmList = prsmReader.LoadIdentificationResult(mspFile, ProteinSpectrumMatch.SearchTool.MsPathFinder);

                    for (var j = 0; j < prsmList.Count; j++)
                    {
                        var match = prsmList[j];
                        match.ProteinId = match.ProteinName;
                    }

                    // tag features by PrSMs
                    for (var j = 0; j < features.Count; j++)
                    {
                        //features[j].ProteinSpectrumMatches = new ProteinSpectrumMatchSet(i);
                        var massTol = tolerance.GetToleranceAsMz(features[j].Mass);
                        foreach (var match in prsmList)
                        {
                            if (features[j].MinScanNum < match.ScanNum && match.ScanNum < features[j].MaxScanNum && Math.Abs(features[j].Mass - match.Mass) < massTol)
                            {
                                features[j].ProteinSpectrumMatches.Add(match);
                            }
                        }
                    }
                }

                alignment.AddDataSet(i, features, run);
            }

            alignment.AlignFeatures();

            Console.WriteLine("{0} alignments ", alignment.CountAlignedFeatures);

            for (var i = 0; i < nDataset; i++)
            {
                alignment.FillMissingFeatures(i);
                Console.WriteLine("{0} has been processed", runLabels[i]);
            }

            OutputCrossTabWithId(outFilePath, alignment, runLabels);
        }
        public void DoAnalysis()
        {
            InitilizeMatrix(_spectrumMatchesMatrix);
            InitilizeMatrix(_tagsGeneratedMatrix);
            InitilizeMatrix(_dataBaseHitMatrix);
            GetFilteredFeatures(_filteredFile);

            for (var i = 0; i < _rawFiles.Length; i++)
            {
                Console.WriteLine("Processing File {0}...............", i);
                var run     = PbfLcMsRun.GetLcMsRun(_rawFiles[i]);
                var ms2List = run.GetScanNumbers(2);
                Console.WriteLine("# of scans {0}", ms2List.Count);
                for (var j = 0; j < _filteredFeatures.Count; j++)
                {
                    var matchedSpecList = GetMatchedSpectrums(run, ms2List, _filteredFeatures[j], i);
                    _spectrumMatchesMatrix[j][i] = matchedSpecList.Count;

                    var tags = GetTags(matchedSpecList);
                    _tagsGeneratedMatrix[j][i] = tags.Count;

                    var hitCount = TagsInDatabase(tags);
                    _dataBaseHitMatrix[j][i] = hitCount;
                }
            }
        }
Exemple #14
0
        public void TestDisplaySpectrum(string rawFile, string tsvFile)
        {
            // init
            var idFileReader = IdFileReaderFactory.CreateReader(tsvFile);
            var ids          = idFileReader.Read();
            var lcms         = PbfLcMsRun.GetLcMsRun(rawFile);
            var idList       = ids.ToList();

            foreach (var id in idList)
            {
                id.LcMs        = lcms;
                id.RawFileName = Path.GetFileNameWithoutExtension(rawFile);
            }

            // init SpectrumPlotViewModel
            var dialogService         = new TestableMainDialogService();
            var spectrumPlotViewModel = new SpectrumPlotViewModel(dialogService, new FragmentationSequenceViewModel(), 1.05, false);

            // init test data
            idList.Sort(new PrSm.PrSmScoreComparer());
            var prsm = idList[0];

            // init test ions
            var ions = new ReactiveList <LabeledIonViewModel>();

            spectrumPlotViewModel.Spectrum = prsm.Ms2Spectrum;
            ////spectrumPlotViewModel.Ions = ions;

            // plot should not be null
            Assert.NotNull(spectrumPlotViewModel.PlotModel);

            // plot should contain 1 stem series (the spectrum stem series)
            Assert.True(spectrumPlotViewModel.PlotModel.Series.Count == 1);
        }
Exemple #15
0
        private void AlignFeatures(List <string> datasets, string mspfFolder, string ms1ftFolder, string outFilePath)
        {
            var nDataset   = datasets.Count;
            var prsmReader = new ProteinSpectrumMatchReader();
            var tolerance  = new Tolerance(12);
            var alignment  = new LcMsFeatureAlignment(new AnalysisCompRef.CompRefFeatureComparer(tolerance));

            for (var i = 0; i < nDataset; i++)
            {
                var rawFile    = string.Format(@"{0}\{1}.pbf", PbfPath, datasets[i]);
                var mspFile    = string.Format(@"{0}\{1}_IcTda.tsv", mspfFolder, datasets[i]);
                var ms1FtFile  = string.Format(@"{0}\{1}.ms1ft", ms1ftFolder, datasets[i]);
                var ms1FtFile2 = string.Format(@"{0}\{1}.seqtag.ms1ft", ms1ftFolder, datasets[i]);

                var run       = PbfLcMsRun.GetLcMsRun(rawFile);
                var features  = LcMsFeatureAlignment.LoadProMexResult(i, ms1FtFile, run);
                var features2 = LcMsFeatureAlignment.LoadProMexResult(i, ms1FtFile2, run);
                features.AddRange(features2);

                if (File.Exists(mspFile))
                {
                    var prsmList = prsmReader.LoadIdentificationResult(mspFile, ProteinSpectrumMatch.SearchTool.MsPathFinder);
                    //var prsmFeatureMatch = new bool[prsmList.Count];

                    foreach (var match in prsmList)
                    {
                        match.ProteinId = match.ProteinName;
                    }

                    // tag features by PrSMs
                    foreach (var feature in features)
                    {
                        //features[j].ProteinSpectrumMatches = new ProteinSpectrumMatchSet(i);
                        var massTol = tolerance.GetToleranceAsMz(feature.Mass);
                        foreach (var match in prsmList)
                        {
                            if (feature.MinScanNum < match.ScanNum && match.ScanNum < feature.MaxScanNum && Math.Abs(feature.Mass - match.Mass) < massTol)
                            {
                                feature.ProteinSpectrumMatches.Add(match);
                                //prsmFeatureMatch[k] = true;
                            }
                        }
                    }
                }

                alignment.AddDataSet(i, features, run);
            }

            alignment.AlignFeatures();

            Console.WriteLine("{0} alignments ", alignment.CountAlignedFeatures);

            for (var i = 0; i < nDataset; i++)
            {
                alignment.FillMissingFeatures(i);
                Console.WriteLine("{0} has been processed", datasets[i]);
            }

            AnalysisCompRef.OutputCrossTabWithId(outFilePath, alignment, datasets);
        }
Exemple #16
0
        public void TestMaxEntDeconvoluter()
        {
            const string rawFileFolder = @"\\proto-11\MSXML_Cache\PBF_Gen_1_214\2015_4";
            const string fname         = "WHIM2_LoHi_T2DD_HCD_GF07_02";
            var          rawFile       = string.Format(@"{0}\{1}.pbf", rawFileFolder, fname);
            var          ms1ft         = string.Format(@"\\protoapps\UserData\Jungkap\CompRef\lowRes\{0}.ms1ft", fname);

            var run         = PbfLcMsRun.GetLcMsRun(rawFile, 1.4826, 0);
            var ms1ScanNums = run.GetMs1ScanVector();

            var featureFinder = new LcMsPeakMatrixLowResolution(run);

            foreach (var scan in ms1ScanNums)
            {
                var fts = featureFinder.DetectMs1Features(scan);
                //Console.WriteLine("{0}\t{1}",scan, fts.Count);
            }

            var features = featureFinder.GetLcMsFeatures();

            var writer = new StreamWriter(ms1ft);
            var id     = 1;

            writer.WriteLine("FeatureID\tMinScan\tMaxScan\tMinCharge\tMaxCharge\tMonoMass\tAbundance\tRepScan\tMaxElutionTime\tElutionLength\tLikelihoodRatio");
            foreach (var feature in features.OrderBy(f => f.Mass))
            {
                writer.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}", id, feature.MinScanNum, feature.MaxScanNum, feature.MinCharge,
                                 feature.MaxCharge, feature.Mass, feature.Abundance, feature.RepresentativeScanNum, feature.MinElutionTime, feature.MaxElutionTime, 0);
                id++;
            }
            writer.Close();
        }
Exemple #17
0
        public void TestReadingBrukerDaltonDataSet()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            const string specFilePath = @"D:\MassSpecFiles\ICR\20141212FGWT1_F5_1_01_3230.mzML";

            if (!File.Exists(specFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, specFilePath);
            }

            Console.WriteLine(@"Test start");

            var pbf = new PbfLcMsRun(specFilePath, null, null, 1.4826, 1.4826);

            //var pbf = new PbfLcMsRun(specFilePath, null, null, 3, 1.4826);

            /*
             * foreach (var spec in reader.ReadAllSpectra())
             * {
             *  if (spec != null)
             *  {
             *      Console.WriteLine(spec.ScanNum);
             *  }
             * }*/
            Console.WriteLine(@"Test end");
        }
        /// <summary>
        /// Gets the appropriate IMassSpecDataReader for the supplied path.
        /// It is recommended that "NormalizeDatasetPath" be called prior to calling this function, and that the returned string be used instead of the original path
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        /// <remarks>It is recommended that "NormalizeDatasetPath" be called prior to calling this function, and that the returned string be used instead of the original path</remarks>
        public static IMassSpecDataReader GetMassSpecDataReader(string filePath)
        {
            filePath = NormalizeDatasetPath(filePath);
            var type = GetMassSpecDataType(filePath);
            IMassSpecDataReader reader = null;
            switch (type)
            {
                case MassSpecDataType.XCaliburRun:
                    reader = new XCaliburReader(filePath);
                    break;
                case MassSpecDataType.MzMLFile:
                    reader = new MzMLReader(filePath);
                    break;
                case MassSpecDataType.PbfFile:
                    reader = new PbfLcMsRun(filePath);
                    break;
                case MassSpecDataType.Unknown:
                    if (_pwizAvailable)
                    {
                        reader = new ProteoWizardReader(filePath);
                    }
                    break;
            }

            return reader;
        }
Exemple #19
0
        public void TestMatchedPeakPostScorer()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            // Parameters
            var productIonTolerance = new Tolerance(10);
            var scorer = new MatchedPeakPostScorer(productIonTolerance, 1, 10);
            var sw     = new System.Diagnostics.Stopwatch();

            const int ms2ScanNum = 4658;
            var       sequence   = new Sequence("GYSIKDIIYQGEKSGVHNWQTLSGQNFYWHPDWLHIAEDLTGHKATASIQAEGTKATQNEAEQTIVKHLNKS", new AminoAcidSet());

            var specFilePath = Path.Combine(Utils.DEFAULT_SPEC_FILES_FOLDER, "QC_Shew_Intact_26Sep14_Bane_C2Column3.raw");

            if (!File.Exists(specFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, specFilePath);
            }

            var run  = PbfLcMsRun.GetLcMsRun(specFilePath, 0, 0);
            var spec = run.GetSpectrum(ms2ScanNum) as ProductSpectrum;

            Assert.True(spec != null);

            sw.Start();
            var score = scorer.ComputeScore(spec, sequence);

            Console.WriteLine("{0}\t{1}\t{2}", sequence, ms2ScanNum, score);

            sw.Stop();

            Console.WriteLine(@"Elapsed Time: {0:f4} sec", sw.Elapsed.TotalSeconds);
        }
Exemple #20
0
        public void TestAbpSumMs1Spectra()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            var specFilePath = Path.Combine(Utils.DEFAULT_TEST_FILE_FOLDER, @"TestYufengData\QC_ShewIntact_2ug_3k_CID_4Apr14_Bane_PL011402.raw");

            if (!File.Exists(specFilePath))
            {
                Assert.Ignore(@"Skipping test " + methodName + @" since file not found: " + specFilePath);
            }

            const int minScanNum = 5657;
            const int maxScanNum = 5699;
            const int MAX_POINTS = 50;

            var run = PbfLcMsRun.GetLcMsRun(specFilePath);

            if (run == null)
            {
                return;
            }
            var summedSpec       = run.GetSummedMs1Spectrum(minScanNum, maxScanNum);
            var peakList         = summedSpec.GetPeakListWithin(1180.0, 1192.0);
            var filteredPeakList = new List <Peak>();

            PeakListUtils.FilterNoise(peakList, ref filteredPeakList);
            new Spectrum(filteredPeakList, 0).Display(MAX_POINTS);
        }
Exemple #21
0
        public void TestSumMs2Spectra()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            var specFilePath = Path.Combine(Utils.DEFAULT_TEST_FILE_FOLDER, @"TestYufengData\NewQC_LongSep_29Sep14_141001104925.raw");

            if (!File.Exists(specFilePath))
            {
                Assert.Ignore(@"Skipping test " + methodName + @" since file not found: " + specFilePath);
            }

            const int minScanNum = 1289;
            //const int maxScanNum = 1389;
            const int minCharge = 6;
            //const int maxCharge = 6;
            const string sequence = "EIRGYRPPEPYKGKGVRYDDEEVRRKEAKKK";
            var          aaSet    = new AminoAcidSet();

            var run = PbfLcMsRun.GetLcMsRun(specFilePath);

            var scorer = new InformedTopDownScorer(run, aaSet, 1, minCharge - 1, new Tolerance(10));

            scorer.GetScores(AminoAcid.ProteinNTerm, sequence, AminoAcid.ProteinCTerm,
                             Composition.Parse("C(166) H(270) N(52) O(49) S(0)"), minCharge, minScanNum);
        }
Exemple #22
0
        public void TestRunningTimeSummingSpectra()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            if (!File.Exists(TestRawFilePath))
            {
                Assert.Ignore(@"Skipping test " + methodName + @" since file not found: " + TestRawFilePath);
            }

            var run = PbfLcMsRun.GetLcMsRun(TestRawFilePath, 1.4826, 1.4826) as PbfLcMsRun;

            var sw = new Stopwatch();

            sw.Start();

            const int windowSize = 5;

            foreach (var scanNum in run.GetScanNumbers(1))
            {
                //var spec = run.GetSpectrum(scanNum);
                var spec = run.GetSummedMs1Spectrum(Math.Max(scanNum - windowSize, run.MinLcScan),
                                                    Math.Min(scanNum + windowSize, run.MaxLcScan));
            }
            sw.Stop();

            Console.WriteLine(@"{0:f4} sec", sw.Elapsed.TotalSeconds);
        }
Exemple #23
0
        public void TestGetChrom()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            var pbfFilePath = Path.Combine(Utils.DEFAULT_TEST_FILE_FOLDER, @"TopDown\ProductionQCShew\QC_Shew_13_04_A_17Feb14_Samwise_13-07-28.pbf");

            if (!File.Exists(pbfFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, pbfFilePath);
            }

            var pbfRun = new PbfLcMsRun(pbfFilePath);

            Console.WriteLine(@"Chromatogram");
            // chromatogram comparison
            const double targetMz  = 655.01;
            var          tolerance = new Tolerance(10);
            var          xic       = pbfRun.GetFullPrecursorIonExtractedIonChromatogram(targetMz, tolerance);

            const int MAX_POINTS = 50;

            xic.Display(MAX_POINTS);

            Console.WriteLine(@"Done");
        }
Exemple #24
0
        public void TestGetChrom()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            const string rafFilePath = @"\\proto-2\UnitTest_Files\InformedProteomics_TestFiles\TopDown\ProductionQCShew\QC_Shew_13_04_A_17Feb14_Samwise_13-07-28.pbf";

            if (!File.Exists(rafFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, rafFilePath);
            }

            var pbfRun = new PbfLcMsRun(rafFilePath);

            Console.WriteLine(@"Chromatogram");
            // chromatogram comparison
            const double targetMz  = 655.01;
            var          tolerance = new Tolerance(10);
            var          xic       = pbfRun.GetFullPrecursorIonExtractedIonChromatogram(targetMz, tolerance);

            const int MAX_POINTS = 50;

            xic.Display(MAX_POINTS);

            Console.WriteLine(@"Done");
        }
Exemple #25
0
        /// <summary>
        /// Gets the appropriate IMassSpecDataReader for the supplied path.
        /// It is recommended that "NormalizeDatasetPath" be called prior to calling this function, and that the returned string be used instead of the original path
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        /// <remarks>It is recommended that "NormalizeDatasetPath" be called prior to calling this function, and that the returned string be used instead of the original path</remarks>
        public static IMassSpecDataReader GetMassSpecDataReader(string filePath)
        {
            filePath = NormalizeDatasetPath(filePath);
            var type = GetMassSpecDataType(filePath);
            IMassSpecDataReader reader = null;

            switch (type)
            {
            case MassSpecDataType.XCaliburRun:
                reader = new XCaliburReader(filePath);
                break;

            case MassSpecDataType.MzMLFile:
                reader = new MzMLReader(filePath);
                break;

            case MassSpecDataType.PbfFile:
                reader = new PbfLcMsRun(filePath);
                break;

            case MassSpecDataType.Unknown:
                if (_pwizAvailable)
                {
                    reader = new ProteoWizardReader(filePath);
                }
                break;
            }

            return(reader);
        }
        public void TestDisplaySpectra(string rawFile, string idFile)
        {
            // init
            var idFileReader = IdFileReaderFactory.CreateReader(idFile);
            var ids          = idFileReader.Read();
            var lcms         = PbfLcMsRun.GetLcMsRun(rawFile);
            var idList       = ids.ToList();

            foreach (var id in idList)
            {
                id.LcMs        = lcms;
                id.RawFileName = Path.GetFileNameWithoutExtension(rawFile);
            }
            idList.Sort(new PrSm.PrSmScoreComparer());

            var prsm = idList[0];

            // init XicPlotViewModel
            var dialogService     = new TestableMainDialogService();
            var spectrumViewModel = new SpectrumViewModel(dialogService, lcms);

            // init test ions
            var baseIonTypes = new List <BaseIonType> {
                BaseIonType.B, BaseIonType.Y
            };
            var neutralLosses = new List <NeutralLoss> {
                NeutralLoss.NoLoss
            };
            const int charge = 1;
            const int minCharge = 1, maxCharge = 2;
            var       ionTypeFactory = new IonTypeFactory(maxCharge);
            var       ionTypes       = IonUtils.GetIonTypes(ionTypeFactory, baseIonTypes, neutralLosses, minCharge, maxCharge);
            var       ions           = IonUtils.GetFragmentIonLabels(prsm.Sequence, charge, ionTypes);
            var       ionVms         = ions.Select(label => new LabeledIonViewModel(label.Composition, label.IonType, label.IsFragmentIon, lcms, label.PrecursorIon, label.IsChargeState, label.Index)).ToList();
        }
Exemple #27
0
        public void TestFeatureAlignment()
        {
            const string outFilePath = @"\\protoapps\UserData\Jungkap\Quant\aligned\promex_crosstab.tsv";
            //const string outFolder = @"\\protoapps\UserData\Jungkap\CompRef\aligned";
            var runLabels = new string[] { "1x1", "1x2", "1x3", "1x4", "1x5", "5x1", "5x2", "5x3", "5x4", "5x5", "10x1", "10x2", "10x3", "10x4", "10x5", };
            var nDataset  = runLabels.Length;

            var prsmReader = new ProteinSpectrumMatchReader();
            var tolerance  = new Tolerance(10);
            var alignment  = new LcMsFeatureAlignment(new SpikeInFeatureComparer(tolerance));

            for (var i = 0; i < nDataset; i++)
            {
                var rawFile   = string.Format(@"{0}\{1}.pbf", RawFolder, datasets[i]);
                var mspFile   = string.Format(@"{0}\{1}_IcTda.tsv", MsPfFolder, datasets[i]);
                var ms1FtFile = string.Format(@"{0}\{1}.ms1ft", Ms1FtFolder, datasets[i]);

                var run      = PbfLcMsRun.GetLcMsRun(rawFile);
                var prsmList = prsmReader.LoadIdentificationResult(mspFile, ProteinSpectrumMatch.SearchTool.MsPathFinder);
                var features = LcMsFeatureAlignment.LoadProMexResult(i, ms1FtFile, run);

                for (var j = 0; j < prsmList.Count; j++)
                {
                    var match = prsmList[j];
                    match.ProteinId = match.ProteinName;
                }

                // tag features by PrSMs
                for (var j = 0; j < features.Count; j++)
                {
                    //features[j].ProteinSpectrumMatches = new ProteinSpectrumMatchSet(i);
                    var massTol = tolerance.GetToleranceAsTh(features[j].Mass);
                    foreach (var match in prsmList)
                    {
                        if (features[j].MinScanNum < match.ScanNum && match.ScanNum < features[j].MaxScanNum && Math.Abs(features[j].Mass - match.Mass) < massTol)
                        {
                            features[j].ProteinSpectrumMatches.Add(match);
                        }
                    }
                }

                alignment.AddDataSet(i, features, run);
            }

            alignment.AlignFeatures();

            Console.WriteLine("{0} alignments ", alignment.CountAlignedFeatures);

            /*
             * for (var i = 0; i < nDataset; i++)
             * {
             *  alignment.FillMissingFeatures(i);
             *  Console.WriteLine("{0} has been processed", runLabels[i]);
             * }
             */
            OutputCrossTabWithId(outFilePath, alignment, runLabels);
        }
Exemple #28
0
        private void FeatureMapGeneration()
        {
            var resultsFilePath = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(mFeatureMapPbfFile) + "_FeatureMap.png");

            var map = new LcMsFeatureMap(PbfLcMsRun.GetLcMsRun(mFeatureMapPbfFile), mFeatureMapResultsFile, 2000, 50000);

            map.SaveImage(resultsFilePath);

            Console.WriteLine("Image saved to " + resultsFilePath);
        }
Exemple #29
0
        public void TestSumIsoProfilesAcrossDifferentCharges()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            if (!File.Exists(TestRawFilePath))
            {
                Assert.Ignore(@"Skipping test " + methodName + @" since file not found: " + TestRawFilePath);
            }

            var run = PbfLcMsRun.GetLcMsRun(TestRawFilePath) as PbfLcMsRun;

            //var spec = run.GetSpectrum(46452); // 635.37
            var spec      = run.GetSummedMs1Spectrum(46437, 46466);
            var tolerance = new Tolerance(10);

            const string protSequence =
                "AIPQSVEGQSIPSLAPMLERTTPAVVSVAVSGTHVSKQRVPDVFRYFFGPNAPQEQVQERPFRGLGSGVIIDADKGYIVTNNHVIDGADDIQVGLHDGREVKAKLIGTDSESDIALLQIEAKNLVAIKTSDSDELRVGDFAVAIGNPFGLGQTVTSGIVSALGRSGLGIEMLENFIQTDAAINSGNSGGALVNLKGELIGINTAIVAPNGGNVGIGFAIPANMVKNLIAQIAEHGEVRRGVLGIAGRDLDSQLAQGFGLDTQHGGFVNEVSAGSAAEKAGIKAGDIIVSVDGRAIKSFQELRAKVATMGAGAKVELGLIRDGDKKTVNVTLGEANQTTEKAAGAVHPMLQGASLENASKGVEITDVAQGSPAAMSGLQKGDLIVGINRTAVKDLKSLKELLKDQEGAVALKIVRGKSMLYLVLR";
            //const string annotation = "_." + protSequence + "._";
            var seqGraph = SequenceGraph.CreateGraph(new AminoAcidSet(), AminoAcid.ProteinNTerm, protSequence, AminoAcid.ProteinCTerm);

            if (seqGraph == null)
            {
                return;
            }
            seqGraph.SetSink(0);
            var neutral = seqGraph.GetSinkSequenceCompositionWithH2O();

            var theoProfile = neutral.GetIsotopomerEnvelopeRelativeIntensities();
            var expProfile  = new double[theoProfile.Length];

            for (var charge = 22; charge <= 45; charge++)
            {
                var ion          = new Ion(neutral, charge);
                var isotopePeaks = spec.GetAllIsotopePeaks(ion, tolerance, 0.1);
                if (isotopePeaks == null)
                {
                    continue;
                }
                Assert.True(isotopePeaks.Length == theoProfile.Length);
                for (var i = 0; i < isotopePeaks.Length; i++)
                {
                    if (isotopePeaks[i] != null)
                    {
                        expProfile[i] += isotopePeaks[i].Intensity;
                    }
                }
            }
            for (var i = 0; i < theoProfile.Length; i++)
            {
                Console.WriteLine("{0}\t{1}\t{2}", neutral.GetIsotopeMass(i), theoProfile[i], expProfile[i] / expProfile.Max());
            }
            Console.WriteLine("Corr: " + FitScoreCalculator.GetPearsonCorrelation(theoProfile, expProfile));
        }
Exemple #30
0
        public void TestFitMinusOneScore(int precursor, string adduct, string commonName, string id, string rawFilePath)
        {
            var lipid = new Lipid()
            {
                AdductFull = adduct, CommonName = commonName
            };
            var lipidTarget = lipid.CreateLipidTarget();

            var composition = lipidTarget.Composition;
            var compMinus1  = new Composition(composition.C, composition.H - 1, composition.N, composition.O, composition.S, composition.P); //Subtract one hydrogen to make this a minus1 fit score

            var lcmsRun = PbfLcMsRun.GetLcMsRun(rawFilePath);

            var spectrum = lcmsRun.GetSpectrum(precursor);

            var relativeIntensityThreshold = 0.1;

            var tolerance = new Tolerance(30, ToleranceUnit.Ppm);

            //Get the values to use to calculate pearson correlation
            var observedPeaks = LipidUtil.GetAllIsotopePeaks(spectrum, compMinus1, tolerance,
                                                             relativeIntensityThreshold);

            if (observedPeaks == null)
            {
                Console.WriteLine("Observed peaks is null for scan " + id);
            }

            var isotopomerEnvelope = IsoProfilePredictor.GetIsotopomerEnvelop(
                compMinus1.C,
                compMinus1.H,
                compMinus1.N,
                compMinus1.O,
                compMinus1.S);

            var observedIntensities = new double[observedPeaks.Length];

            for (var i = 0; i < observedPeaks.Length; i++)
            {
                var observedPeak = observedPeaks[i];
                observedIntensities[i] = observedPeak != null ? (float)observedPeak.Intensity : 0.0;
            }

            Console.WriteLine("The theoretical y values are: ");
            foreach (var value in isotopomerEnvelope.Envolope)
            {
                Console.WriteLine(value + ", ");
            }

            Console.WriteLine("The observed peak intensity x values are: ");
            foreach (var value in observedIntensities)
            {
                Console.WriteLine(value + ", ");
            }
        }
Exemple #31
0
 public void CountTagMatches()
 {
     for (var i = 1; i < 52; i++)
     {
         var dataName = "Lewy_intact_" + i.ToString("D2");
         var filePath = string.Format(@"{0}\{1}.pbf", PbfPath, dataName);
         var run      = PbfLcMsRun.GetLcMsRun(filePath);
         var scans    = run.GetScanNumbers(2);
         Console.WriteLine(scans.Count);
     }
 }
Exemple #32
0
        public void TestWritingPbfFile()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            if (!File.Exists(TestRawFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, TestRawFilePath);
            }

            Console.WriteLine(@"Writing...");
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
  
            var outputFilePath = PbfLcMsRun.GetPbfFileName(TestRawFilePath);
            var pbf = new PbfLcMsRun(TestRawFilePath, null, outputFilePath);
            
            Console.WriteLine(@"Done. {0:f4} sec", sw.Elapsed.TotalSeconds);
        }
Exemple #33
0
        public void TestGeneratingProductXics()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            if (!File.Exists(TestRawFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, TestRawFilePath);
            }

            var run = InMemoryLcMsRun.GetLcMsRun(TestRawFilePath);

//            const string rafFilePath = @"C:\cygwin\home\kims336\Data\QCShewQE\QC_Shew_13_04_A_17Feb14_Samwise_13-07-28.raf";
            const string rafFilePath = @"H:\Research\Jarret\10mz\raw\Q_2014_0523_50_10_fmol_uL_10mz.raf";
            if (!File.Exists(rafFilePath))
            {
                Assert.Ignore(@"Skipping raf portion of test {0} since file not found: {1}", methodName, rafFilePath);
            }

            var rafRun = new PbfLcMsRun(rafFilePath);

            var tolerance = new Tolerance(10);

            var mzArr = new double[100000];
            var precursorMzArr = new double[mzArr.Length];
            var rnd = new Random();
            for (var i = 0; i < mzArr.Length; i++)
            {
                mzArr[i] = rnd.NextDouble() * 1450.0 + 50.0;
                precursorMzArr[i] = rnd.NextDouble() * (810.0 - 390.0) + 390.0;
            }

            var sw = new System.Diagnostics.Stopwatch();
            //double sec;

            // method 1
            sw.Start();
            for (var i = 0; i < mzArr.Length; i++)
            {
                var mz = mzArr[i];
                var tolTh = tolerance.GetToleranceAsTh(mz);
                var minMz = mz - tolTh;
                var maxMz = mz + tolTh;
                var xic1 = run.GetFullProductExtractedIonChromatogram(minMz, maxMz, precursorMzArr[i]);
                //var xic2 = rafRun.GetFullProductExtractedIonChromatogram(minMz, maxMz, precursorMzArr[i]);
                //Assert.True(xic1.Equals(xic2));
            }
            sw.Stop();
            
            Console.WriteLine(@"Method 1: {0:f4} sec", sw.Elapsed.TotalSeconds);

            sw.Reset();
            sw.Start();
            for (var i = 0; i < mzArr.Length; i++)
            {
                var mz = mzArr[i];
                var tolTh = tolerance.GetToleranceAsTh(mz);
                var minMz = mz - tolTh;
                var maxMz = mz + tolTh;
                rafRun.GetFullProductExtractedIonChromatogram(minMz, maxMz, precursorMzArr[i]);
            }
            sw.Stop();
            
            Console.WriteLine(@"Method 2: {0:f4} sec", sw.Elapsed.TotalSeconds);

            Console.WriteLine(@"Done");
        }
Exemple #34
0
        public void TestGetChrom()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            const string rafFilePath = @"\\proto-2\UnitTest_Files\InformedProteomics_TestFiles\TopDown\ProductionQCShew\QC_Shew_13_04_A_17Feb14_Samwise_13-07-28.pbf";
            if (!File.Exists(rafFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, rafFilePath);
            }

            var pbfRun = new PbfLcMsRun(rafFilePath);

            Console.WriteLine(@"Chromatogram");
            // chromatogram comparison
            const double targetMz = 655.01;
            var tolerance = new Tolerance(10);
            var xic = pbfRun.GetFullPrecursorIonExtractedIonChromatogram(targetMz, tolerance);

            const int MAX_POINTS = 50;
            xic.Display(MAX_POINTS);

            Console.WriteLine(@"Done");
        }
Exemple #35
0
        public void TestReadingPbfFile()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            const string pbfFilePath = @"\\proto-2\UnitTest_Files\InformedProteomics_TestFiles\TopDown\ProductionQCShew\QC_Shew_13_04_A_17Feb14_Samwise_13-07-28.pbf";
            if (!File.Exists(pbfFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, pbfFilePath);
            }

            var pbfRun = new PbfLcMsRun(pbfFilePath);

            var specFilePath = Path.ChangeExtension(pbfFilePath, "raw");
            if (!File.Exists(specFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, specFilePath);
            }

            Console.WriteLine(@"Loading .pbf into memory");

            var run = InMemoryLcMsRun.GetLcMsRun(specFilePath);

            Console.WriteLine(@"Comparing spectra between .pbf and in-memory spectra");

            // spectrum comparison
            for (var scanNum = run.MinLcScan; scanNum <= run.MaxLcScan; scanNum++)
            {
                var spec1 = run.GetSpectrum(scanNum);
                var spec2 = pbfRun.GetSpectrum(scanNum);

                Assert.IsTrue(spec1.Peaks.Length == spec2.Peaks.Length);
                for (var i = 0; i < spec1.Peaks.Length; i++)
                {
                    var p1 = spec1.Peaks[i];
                    var p2 = spec2.Peaks[i];

                    Assert.True(p1.Equals(p2));

                    Assert.True(Math.Abs(p1.Mz - p2.Mz) < 1e-8);
                    Assert.True(Math.Abs(p1.Intensity - p2.Intensity) < 0.001);
                }
            }

            Console.WriteLine(@"Comparing XICs");
            // chromatogram comparison
            const double targetMz = 655.01;
            var tolerance = new Tolerance(10);
            var xic1 = run.GetFullPrecursorIonExtractedIonChromatogram(targetMz, tolerance);
            var xic2 = pbfRun.GetFullPrecursorIonExtractedIonChromatogram(targetMz, tolerance);
            Assert.True(xic1.Count == xic2.Count);

            for (var i = 0; i < xic1.Count; i++)
            {
                if (!xic1[i].Equals(xic2[i]))
                {
                    Console.WriteLine(@"{0} {1} {2}", i, xic1[i], xic2[i]);
                }
                Assert.True(xic1[i].Equals(xic2[i]));
            }
            Console.WriteLine(@"Done");
        }
Exemple #36
0
        public void TestSpectrumNavigation()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            const string rafFilePath = @"H:\Research\Jarret\10mz\raw\Q_2014_0523_50_10_fmol_uL_10mz.raf";
            if (!File.Exists(rafFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, rafFilePath);
            }

            var rafRun = new PbfLcMsRun(rafFilePath);
           // var spec = rafRun.GetSpectrum(54531);
            var scanNum = rafRun.GetNextScanNum(54530, 1);
            Console.WriteLine(scanNum);
        }
Exemple #37
0
        public void TestReadingBrukerDaltonDataSet()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            const string specFilePath = @"D:\MassSpecFiles\ICR\20141212FGWT1_F5_1_01_3230.mzML";
            if (!File.Exists(specFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, specFilePath);
            }

            Console.WriteLine(@"Test start");

            var pbf = new PbfLcMsRun(specFilePath, null, null, 1.4826, 1.4826);
            //var pbf = new PbfLcMsRun(specFilePath, null, null, 3, 1.4826);
            /*
            foreach (var spec in reader.ReadAllSpectra())
            {
                if (spec != null)
                {
                    Console.WriteLine(spec.ScanNum);
                }
            }*/
            Console.WriteLine(@"Test end");
        }
Exemple #38
0
        public void TestRunningTimeChromGen()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            const string rafFilePath = @"C:\cygwin\home\kims336\Data\QCShewQE\QC_Shew_13_04_A_17Feb14_Samwise_13-07-28.raf";
            if (!File.Exists(rafFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, rafFilePath);
            }

            var rafRun = new PbfLcMsRun(rafFilePath);

            var tolerance = new Tolerance(10);

            const string dbFile = @"D:\Research\Data\CommonContaminants\H_sapiens_Uniprot_SPROT_2013-05-01_withContam.fasta";
            if (!File.Exists(dbFile))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, dbFile);
            }

            var db = new FastaDatabase(dbFile);
            var indexedDb = new IndexedDatabase(db);
            var aaSet = new AminoAcidSet(Modification.Carbamidomethylation);

            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            var numPeptides = 0;
            foreach (var peptide in indexedDb.AnnotationsAndOffsets(6, 30, 2, 2, Enzyme.Trypsin))
            {
                ++numPeptides;
                var comp = new Sequence(peptide.Annotation.Substring(2, peptide.Annotation.Length-4), aaSet).Composition + Composition.H2O;
                var mz = new Ion(comp, 2).GetMonoIsotopicMz();
                //Console.WriteLine(peptide.Annotation + " " + mz);
                rafRun.GetFullPrecursorIonExtractedIonChromatogram(mz, tolerance);
                //run.GetFullPrecursorIonExtractedIonChromatogram(mz, tolerance);

                //var xic1 = run.GetFullPrecursorIonExtractedIonChromatogram(mz, tolerance);
                //var xic2 = rafRun.GetFullPrecursorIonExtractedIonChromatogram(mz, tolerance);
                //Assert.True(xic1.Count == xic2.Count);
                //for (var i = 0; i < xic1.Count; i++)
                //{
                //    if (!xic1[i].Equals(xic2[i]))
                //    {
                //        Console.WriteLine("{0} {1} {2}", i, xic1[i], xic2[i]);
                //    }
                //    Assert.True(xic1[i].Equals(xic2[i]));
                //}

                if (numPeptides == 100000) break;
            }
            sw.Stop();
            
            Console.WriteLine(@"{0:f4} sec", sw.Elapsed.TotalSeconds);
        }
Exemple #39
0
        public void TestGeneratingProductXic()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            if (!File.Exists(TestRawFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, TestRawFilePath);
            }

            var run = InMemoryLcMsRun.GetLcMsRun(TestRawFilePath);

//            const string rafFilePath = @"C:\cygwin\home\kims336\Data\QCShewQE\QC_Shew_13_04_A_17Feb14_Samwise_13-07-28.raf";
            const string rafFilePath = @"H:\Research\Jarret\10mz\raw\Q_2014_0523_50_10_fmol_uL_10mz.raf";
            if (!File.Exists(rafFilePath))
            {
                Assert.Ignore(@"Skipping raf portion of test {0} since file not found: {1}", methodName, rafFilePath);
            }

            var rafRun = new PbfLcMsRun(rafFilePath);

            const double precursorIonMz = 815.16;
            const double productIonMz = 902.445;
            var tolerance = new Tolerance(10);
            var xic1 = run.GetFullProductExtractedIonChromatogram(productIonMz, tolerance, precursorIonMz);
//            xic1.Display();
            var xic2 = rafRun.GetFullProductExtractedIonChromatogram(productIonMz, tolerance, precursorIonMz);
//            xic2.Display();
            Assert.True(xic1.Equals(xic2));
            Console.WriteLine(@"Done");
        }