Пример #1
0
 public void OnUpdateTargetAdductFragmentation(Adduct adduct, FragmentationMode fragmode)
 {
     TargetAdduct            = adduct;
     TargetFragmentationMode = fragmode;
     OnPropertyChanged("TargetAdduct");
     OnPropertyChanged("TargetFragmentationMode");
 }
Пример #2
0
 public SpecificFragment(LipidClass lipidClass, LipidType lipidType, string fragmentDescription, FragmentationMode fragmentationMode, FragmentationType fragmentationType)
 {
     LipidClass          = lipidClass;
     LipidType           = lipidType;
     FragmentDescription = fragmentDescription;
     FragmentationMode   = fragmentationMode;
     FragmentationType   = fragmentationType;
 }
Пример #3
0
        public LipidGroupSearchResult(SpectrumSearchResult spectrumSearchResult, FragmentationMode fragmentationMode, Adduct adduct)
        {
            var msmsSpec = spectrumSearchResult.CidSpectrum ?? spectrumSearchResult.HcdSpectrum;

            LipidTarget          = new LipidTarget(msmsSpec.IsolationWindow.ToString(), LipidClass.Unknown, fragmentationMode, null, null, adduct);
            LipidList            = null;
            SpectrumSearchResult = spectrumSearchResult;
            DisplayScanNum       = msmsSpec.ScanNum;
            DisplayMz            = msmsSpec.IsolationWindow.IsolationWindowTargetMz;
            ShouldExport         = false;
            Score = 0;
        }
Пример #4
0
        public void SearchForTarget(string commonName, Adduct adduct, FragmentationMode fragmentationMode, double hcdMassError, double cidMassError)
        {
            CurrentLipidTarget = LipidUtil.CreateLipidTarget(commonName, fragmentationMode, adduct);
            OnPropertyChanged("CurrentLipidTarget");

            SpectrumSearchResultList = InformedWorkflow.RunInformedWorkflow(CurrentLipidTarget, LcMsRun, hcdMassError, cidMassError, ScoreModel);
            OnPropertyChanged("SpectrumSearchResultList");

            if (SpectrumSearchResultList.Any())
            {
                var spectrumSearchResult = SpectrumSearchResultList.OrderByDescending(x => x.NumMatchingMsMsPeaks).First();
                OnSpectrumSearchResultChange(spectrumSearchResult);
            }
            else
            {
                CurrentSpectrumSearchResult = null;
            }
        }
Пример #5
0
        public LipidTarget(
            string commonName,
            LipidClass lipidClass,
            FragmentationMode fragmentationMode,
            Composition composition,
            IEnumerable <AcylChain> acylChainList,
            Adduct adduct = Adduct.Hydrogen, int charge = 1)
        {
            CommonName        = commonName;
            LipidClass        = lipidClass;
            FragmentationMode = fragmentationMode;
            Composition       = composition;
            AcylChainList     = acylChainList.ToList();
            Adduct            = adduct;
            Charge            = charge;

            LipidType = FigureOutLipidType();
        }
Пример #6
0
        public void SearchForFragments(double hcdError, double cidError, FragmentationMode fragmentationMode, int numResultsPerScanToInclude, int minMatches, Adduct adduct)
        {
            IProgress <int> progress = new Progress <int>(ReportFragmentSearchProgress);

            SpectrumSearchResultList = InformedWorkflow.RunFragmentWorkflow(FragmentSearchList, LcMsRun, hcdError, cidError, minMatches, progress);
            OnPropertyChanged("SpectrumSearchResultList");
            progress.Report(0);
            if (SpectrumSearchResultList.Any())
            {
                var spectrumSearchResult =
                    SpectrumSearchResultList.OrderByDescending(x => x.ApexScanNum).First();
                CurrentLipidTarget = LipidUtil.CreateLipidTarget((spectrumSearchResult.HcdSpectrum ?? spectrumSearchResult.CidSpectrum).IsolationWindow.IsolationWindowTargetMz, fragmentationMode, adduct);
                //OnMsMsSearchResultChange(spectrumSearchResult);
                OnSpectrumSearchResultChange(spectrumSearchResult);
            }
            else
            {
                CurrentSpectrumSearchResult = null;
            }
        }
Пример #7
0
        public void OnProcessAllTarget(double hcdError, double cidError, FragmentationMode fragmentationMode, int numResultsPerScanToInclude)
        {
            IProgress <int> progress = new Progress <int>(ReportGlobalWorkflowProgress);

            // Make sure to only look at targets that match the fragmentation mode
            var targetsToProcess = LipidTargetList.Where(x => x.LipidTarget.FragmentationMode == fragmentationMode);

            // Run global analysis
            LipidGroupSearchResultList = new List <LipidGroupSearchResult>();

            IEnumerable <IGrouping <double, LipidGroupSearchResult> > resultsGrouped;
            List <LipidGroupSearchResult> lipidGroupSearchResultList;

            if (AverageSpec)
            {
                lipidGroupSearchResultList = GlobalWorkflow.RunGlobalWorkflowAvgSpec(targetsToProcess, LcMsRun, hcdError, cidError, ScoreModel, progress);
                resultsGrouped             = lipidGroupSearchResultList.GroupBy(x => x.SpectrumSearchResult.HcdSpectrum?.IsolationWindow.IsolationWindowTargetMz ?? x.SpectrumSearchResult.CidSpectrum.IsolationWindow.IsolationWindowTargetMz);
            }
            else
            {
                lipidGroupSearchResultList = GlobalWorkflow.RunGlobalWorkflow(targetsToProcess, LcMsRun, hcdError, cidError, ScoreModel, progress);
                resultsGrouped             = lipidGroupSearchResultList.GroupBy(x => x.SpectrumSearchResult.HcdSpectrum?.ScanNum ?? (double)x.SpectrumSearchResult.CidSpectrum.ScanNum);
            }

            // Group results of same scan together

            // Grab the result(s) with the best score
            foreach (var group in resultsGrouped)
            {
                var groupOrdered = group.OrderByDescending(x => x.Score).ToList();

                for (var i = 0; i < numResultsPerScanToInclude && i < groupOrdered.Count; i++)
                {
                    var resultToAdd = groupOrdered[i];
                    LipidGroupSearchResultList.Add(resultToAdd);
                }
            }
            OnPropertyChanged("LipidGroupSearchResultList");
            progress.Report(0);
        }
Пример #8
0
        public void TestSingleTarget()
        {
            // Testing PC(16:0/18:1) +H
            const string            commonName        = "PC(16:0/18:1)";
            const string            empiricalFormula  = "C42H83NO8P";
            const LipidClass        lipidClass        = LipidClass.PC;
            const FragmentationMode fragmentationMode = FragmentationMode.Positive;
            var acylChainList = new List <AcylChain> {
                new AcylChain("16:0"), new AcylChain("18:1")
            };

            var lipidTarget = LipidUtil.CreateLipidTarget(commonName, empiricalFormula, lipidClass, fragmentationMode, acylChainList);

            var rawFileLocation  = @"../../../testFiles/XGA121_lipid_Skin_1.raw";
            var informedWorkflow = new InformedWorkflow(rawFileLocation);
            var resultList       = informedWorkflow.RunInformedWorkflow(lipidTarget, 30, 500);

            foreach (var result in resultList.OrderByDescending(x => x.GetNumMatchingMsMsPeaks()))
            {
                Console.WriteLine(result.Xic.GetApexScanNum() + " - " + result.HcdSpectrum.ScanNum + " - " + result.CidSpectrum.ScanNum + " - " + result.GetNumMatchingMsMsPeaks());
            }
        }
Пример #9
0
        public void TestSingleConfidentTarget()
        {
            // Testing PE(18:3/20:5) +H
            const string            commonName        = "PE(18:3/20:5)";
            const string            empiricalFormula  = "C43H71NO8P";
            const LipidClass        lipidClass        = LipidClass.PE;
            const FragmentationMode fragmentationMode = FragmentationMode.Positive;
            var acylChainList = new List <AcylChain> {
                new AcylChain("18:3"), new AcylChain("20:5")
            };

            var lipidTarget = LipidUtil.CreateLipidTarget(commonName, empiricalFormula, lipidClass, fragmentationMode, acylChainList);

            var rawFileLocation  = @"../../../testFiles/Daphnia_gut_TLE_POS_Gimli_21Jan14_13-07-01.raw";
            var informedWorkflow = new InformedWorkflow(rawFileLocation);
            var resultList       = informedWorkflow.RunInformedWorkflow(lipidTarget, 30, 500);

            foreach (var result in resultList.OrderByDescending(x => x.GetNumMatchingMsMsPeaks()))
            {
                Console.WriteLine(result.Xic.GetApexScanNum() + " - " + result.HcdSpectrum.ScanNum + " - " + result.CidSpectrum.ScanNum + " - " + result.GetNumMatchingMsMsPeaks());
            }
        }
Пример #10
0
 public int CompareTo(ScoreModelUnit other)
 {
     if (!LipidClass.Equals(other.LipidClass))
     {
         return(LipidClass.CompareTo(other.LipidClass));
     }
     if (!LipidType.Equals(other.LipidType))
     {
         return(LipidType.CompareTo(other.LipidType));
     }
     if (!FragmentDescription.Equals(other.FragmentDescription))
     {
         return(String.Compare(FragmentDescription, other.FragmentDescription, StringComparison.Ordinal));
     }
     if (!FragmentationMode.Equals(other.FragmentationMode))
     {
         return(FragmentationMode.CompareTo(other.FragmentationMode));
     }
     if (!FragmentationType.Equals(other.FragmentationType))
     {
         return(FragmentationType.CompareTo(other.FragmentationType));
     }
     return(IntensityMax.CompareTo(other.IntensityMax));
 }
Пример #11
0
        public int CompareTo(SpecificFragment other)
        {
            if (!LipidClass.Equals(other.LipidClass))
            {
                return(LipidClass.CompareTo(other.LipidClass));
            }

            if (!LipidType.Equals(other.LipidType))
            {
                return(LipidType.CompareTo(other.LipidType));
            }

            if (!FragmentDescription.Equals(other.FragmentDescription))
            {
                return(String.Compare(FragmentDescription, other.FragmentDescription, StringComparison.Ordinal));
            }

            if (!FragmentationMode.Equals(other.FragmentationMode))
            {
                return(FragmentationMode.CompareTo(other.FragmentationMode));
            }

            return(FragmentationType.CompareTo(other.FragmentationType));
        }
Пример #12
0
        public void OnBuildLibrary(IList <string> filesList, double hcdError, double cidError, FragmentationMode fragmentationMode, int numResultsPerScanToInclude)
        {
            foreach (var file in filesList)
            {
                using (var reader = new StreamReader(new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                {
                    if (reader.EndOfStream)
                    {
                        continue;
                    }

                    var headerLine = reader.ReadLine();
                    if (string.IsNullOrWhiteSpace(headerLine))
                    {
                        // Empty header line
                        continue;
                    }
                    var header = headerLine.Split('\t').ToList();

                    var index = header.IndexOf("Raw Data File");
                    if (index == -1)
                    {
                        continue;
                    }

                    if (reader.EndOfStream)
                    {
                        continue;
                    }

                    try
                    {
                        var dataLine = reader.ReadLine();
                        if (string.IsNullOrWhiteSpace(dataLine))
                        {
                            // Empty data line
                            continue;
                        }

                        var rawFileName = dataLine.Split('\t')[index];
                        LibraryBuilder.AddDmsDataset(rawFileName);
                        UpdateRawFileLocation(rawFileName);
                        OnProcessAllTarget(hcdError, cidError, fragmentationMode, numResultsPerScanToInclude);
                        LoadLipidIdentifications(file);
                        OnExportGlobalResults(file.Replace(".tsv", ".msp"));

                        //Delete the raw files we copied from DMS to save space
                        LcMsRun.Close();
                        LcMsRun = null;
                        OnPropertyChanged("LcMsRun");
                        GC.Collect();

                        //File.Delete(rawFileName);
                        var pbfFilePath = Path.ChangeExtension(rawFileName, ".pbf");
                        if (string.IsNullOrWhiteSpace(pbfFilePath))
                        {
                            continue;
                        }

                        var pbfFile = new FileInfo(pbfFilePath);
                        if (pbfFile.Exists)
                        {
                            pbfFile.Delete();
                        }
                    }
                    catch (Exception)
                    {
                        // Ignore the error
                    }
                }
            }
        }