Example #1
0
        public DeuterationResult(Peptide peptide, ProteinState proteinState, Labeling labeling, IList<RunResult> replicateResults)
        {
            _peptide = peptide;
            _proteinState = proteinState;
            _labeling = labeling;
            _replicateResults = replicateResults;

            DeuterationValues = new List<double>();
            DeuterationDistributedDeuterationValues = new List<double>();
            CentroidMassValues = new List<double>();

            NValue = 0;
            foreach (RunResult replicate in _replicateResults)
            {
                if (replicate != null)
                {
                    this.TheoreticalCentroidMass = replicate.TheoreticalAverageMass;

                    if (replicate.IsUsedInCalculations)
                    {
                        DeuterationValues.Add(replicate.AmountDeut);
                        DeuterationDistributedDeuterationValues.Add(replicate.AmountDeutFromDeutDist);
                        CentroidMassValues.Add(replicate.AverageMass);
                        NValue++;
                    }
                }
            }
        }
        private static DeuterationResult GenerateDeuterationResult(Peptide peptide, ProteinState proteinState, Labeling labeling, Experiment experiment, Result result)
        {
            List<RunResult> replicates = new List<RunResult>();

            foreach (Run run in experiment.GetRunsByProteinState(proteinState))
            {
                if (run.Labeling == labeling)
                {
                    RunResult runResult = experiment.GetRunResult(result, run, peptide);
                    if (runResult != null)
                    {
                        replicates.Add(runResult);
                    }
                }
            }

            DeuterationResult deuterationResult = new DeuterationResult(peptide, proteinState, labeling, replicates);
            deuterationResult.AmountDeut = Math.Round(MathUtility.GetAverage(deuterationResult.DeuterationValues), 5);
            deuterationResult.AmountDeuterationStandardDeviation = Math.Round(MathUtility.GetStandardDeviation(deuterationResult.DeuterationValues), 5);
            deuterationResult.AmountDeuterationFromDeuterationDistribution = Math.Round(MathUtility.GetAverage(deuterationResult.DeuterationDistributedDeuterationValues), 5);
            deuterationResult.AmountDeuterationFromDeuterationDistributionStandardDeviation = Math.Round(MathUtility.GetStandardDeviation(deuterationResult.DeuterationDistributedDeuterationValues), 5);
            deuterationResult.CentroidMass = Math.Round(MathUtility.GetAverage(deuterationResult.CentroidMassValues), 5);
            deuterationResult.CentroidMassStandardDeviation = Math.Round(MathUtility.GetStandardDeviation(deuterationResult.CentroidMassValues), 5);
            if (replicates.Count > 0)
            {
                deuterationResult.TheoreticalCentroidMass = Math.Round(replicates.Average(item => item.TheoreticalAverageMass), 5);
            }

            return deuterationResult;
        }
 private void AssertPeptide(Peptide peptide)
 {
     Assert.AreEqual(849.47, peptide.MonoIsotopicMass);
     Assert.AreEqual(1, peptide.ChargeState);
     Assert.AreEqual(5, peptide.PeaksInCalculation);
     Assert.AreEqual(0, peptide.MsThreshold);
     Assert.AreEqual(2, peptide.DeuteriumDistributionRightPadding);
     Assert.AreEqual(1, peptide.DeuteriumDistributionThreshold);
 }
Example #4
0
        public RunResult(FragmentIon fragmentIon, Run run)
            : this()
        {
            this.fragmentIon = fragmentIon;
            this.peptide = fragmentIon.Peptide;
            this.run = run;

            this.ActualPeaksInCalculation = fragmentIon.PeaksInCalculation;
            this.ActualDeutDistThreshold = fragmentIon.DeutDistThreshold;
            this.ActualDeutDistRightPadding = fragmentIon.DeutDistRightPadding;

            this.IsResultBasedOnFragment = true;
        }
Example #5
0
        public RunResult(Peptide peptide, Run run)
            : this()
        {
            this.peptide = peptide;
            this.run = run;

            this.ActualPeaksInCalculation = peptide.PeaksInCalculation;
            this.ActualDeutDistThreshold = peptide.DeuteriumDistributionThreshold;
            this.ActualDeutDistRightPadding = peptide.DeuteriumDistributionRightPadding;

            this.ActualXicAdjustment = peptide.XicAdjustment;
            this.ActualXicSelectionWidth = peptide.XicSelectionWidth;

            ActualPeaksInCalculation = peptide.PeaksInCalculation;
        }
        private void AssertPeptide(
			Peptide peptide,
			int amideHydrogenTotal,
			double aminoAcidStart,
			double aminoAcidStop, 
			int aminoAcidTotal,
			int chargeState,
			int deuteriumDistributionRightPadding,
			double deuteriumDistributionThreshold,
			int id, 
			double monoIsotopicMass,
			double msThreshold,
			string notes,
			int peaksInCalculation, 
			int period, 
			string proteinSource,
			double rt, 
			double rtVariance,
			string sequence, 
			double xicAdjustment,
			double xicMass1,
			double xicMass2, 
			XicPeakPickerOption xicPeakPickerOption,
			double xicSelectionWidth)
        {
            Assert.AreEqual(amideHydrogenTotal, peptide.AmideHydrogenTotal);
            Assert.AreEqual(aminoAcidStart, peptide.AminoAcidStart);
            Assert.AreEqual(aminoAcidStop, peptide.AminoAcidStop);
            Assert.AreEqual(aminoAcidTotal, peptide.AminoAcidTotal);
            Assert.AreEqual(chargeState, peptide.ChargeState);
            Assert.AreEqual(deuteriumDistributionRightPadding, peptide.DeuteriumDistributionRightPadding);
            Assert.AreEqual(deuteriumDistributionThreshold, peptide.DeuteriumDistributionThreshold);
            Assert.AreEqual(id, peptide.Id);
            Assert.AreEqual(monoIsotopicMass, peptide.MonoIsotopicMass);
            Assert.AreEqual(msThreshold, peptide.MsThreshold);
            Assert.AreEqual(notes, peptide.Notes);
            Assert.AreEqual(peaksInCalculation, peptide.PeaksInCalculation);
            Assert.AreEqual(period, peptide.Period);
            Assert.AreEqual(proteinSource, peptide.ProteinSource);
            Assert.AreEqual(rt, peptide.RT);
            Assert.AreEqual(rtVariance, peptide.RtVariance);
            Assert.AreEqual(sequence, peptide.Sequence);
            Assert.AreEqual(xicAdjustment, peptide.XicAdjustment);
            Assert.AreEqual(xicMass1, peptide.XicMass1);
            Assert.AreEqual(xicMass2, peptide.XicMass2);
            Assert.AreEqual(xicPeakPickerOption, peptide.XicPeakPickerOption);
            Assert.AreEqual(xicSelectionWidth, peptide.XicSelectionWidth);
        }
Example #7
0
        public ChromatographicPeak Execute(IList<ChromatographicPeak> peakList, Peptide peptide)
        {
            _output.Publish("     XIC Peak Picking Started (XICPeakPickerOption=" + XicPeakPickerOption + ")");

            // this next section might be better suited as a task called 'save Chromatogram xy data'
            double rtVariation = peptide.RtVariance;
            double rtTarget = peptide.RT;

            if (_xicPeakPickerOption == Hydra.Core.XicPeakPickerOption.MostIntenseWithinEntireXic)
            {
                ChromatographicPeak largestPeak = FindLargestPeak(peakList);
                if (largestPeak == null)
                {
                    _output.Publish("     No peaks present within the chromatographic peak list, so no peak could be selected.");
                    return null;
                }
                _output.Publish("     Largest Peak Found: RT=" + largestPeak.Rt + ", PeakHeight=" + largestPeak.PeakHeight + ", PeakWidth=" + largestPeak.PeakWidth + ")");
                return largestPeak;
            }
            else if (_xicPeakPickerOption == Hydra.Core.XicPeakPickerOption.MostIntenseWithinRtVariation || _xicPeakPickerOption == Hydra.Core.XicPeakPickerOption.ClosestToRTWithinRTVariation)
            {
                List<ChromatographicPeak> chromPeaksWithinRtVariation = GetPeaksWithinRtVariation(peakList, rtTarget - rtVariation, rtTarget + rtVariation);
                if (chromPeaksWithinRtVariation.Count == 0)
                {
                    _output.Publish("     No peaks found within RT windows (" + (rtTarget - rtVariation) + " - " + (rtTarget + rtVariation) + ")");
                    return null;
                }

                if (_xicPeakPickerOption == Hydra.Core.XicPeakPickerOption.MostIntenseWithinRtVariation)
                {
                    ChromatographicPeak largestPeak = FindLargestPeak(chromPeaksWithinRtVariation);
                    _output.Publish("     Most Intense Peak Found: RT=" + largestPeak.Rt + ", PeakHeight=" + largestPeak.PeakHeight + ", PeakWidth=" + largestPeak.PeakWidth + ")");
                    return largestPeak;
                }
                else if (_xicPeakPickerOption == Hydra.Core.XicPeakPickerOption.ClosestToRTWithinRTVariation)
                {
                    ChromatographicPeak closestPeak = GetPeakClosestToRT(chromPeaksWithinRtVariation, rtTarget);
                    _output.Publish("     Closest RT Peak Found: RT=" + closestPeak.Rt + ", PeakHeight=" + closestPeak.PeakHeight + ", PeakWidth=" + closestPeak.PeakWidth + ")");
                    return closestPeak;
                }
            }
            return null;
        }
Example #8
0
 public static Peptide CreatePeptide(string sequence, int seed)
 {
     Peptide peptide = new Peptide(sequence);
     peptide.AminoAcidStart = seed++;
     peptide.AminoAcidStop = seed++;
     peptide.MonoIsotopicMass = seed++;
     peptide.ChargeState = seed++;
     peptide.Notes = (seed++).ToString();
     peptide.Period = seed++;
     peptide.XicPeakPickerOption = XicPeakPickerOption.MostIntenseWithinEntireXic;
     peptide.RT = seed++;
     peptide.RtVariance = seed++;
     peptide.XicAdjustment = seed++;
     peptide.XicSelectionWidth = seed++;
     peptide.PeaksInCalculation = seed++;
     peptide.DeuteriumDistributionThreshold = seed++;
     peptide.DeuteriumDistributionRightPadding = seed++;
     return peptide;
 }
 private Peptide CreatePeptide()
 {
     Peptide peptide = new Peptide("SAMPLER");
     peptide.MonoIsotopicMass = 500;
     peptide.ChargeState = 1;
     return peptide;
 }
Example #10
0
 public void TestInitialize()
 {
     peptide = new Peptide("SAMPLE");
 }
        private void OnPeptideSelected(Peptide peptide)
        {
            if (peptide != null)
            {
                CurrentRunResults.Clear();
                var runResults = (from data in allRunResults
                                  where data.Peptide.MonoIsotopicMass == peptide.MonoIsotopicMass && data.Peptide.RT == peptide.RT
                                  select data).ToList();

                foreach (ValidationWrapper runResult in runResults)
                {
                    CurrentRunResults.Add(runResult);
                }

                if (CurrentRunResults.Count > 0)
                {
                    if (selectedRun == null)
                    {
                        SelectedRunResult = CurrentRunResults.First();
                    }
                    else
                    {
                        SelectedRunResult = CurrentRunResults.FirstOrDefault(item => item.RunResult.Run.FileName == selectedRun.FileName);
                    }
                }
            }
        }
Example #12
0
        public void GetIsotopicProfileUsingRunResult()
        {
            Peptide peptide = new Peptide("SAMPLER");
            peptide.ChargeState = 2;
            RunResult runResult = new RunResult(peptide, null);
            peptideUtility.GetIsotopicProfile(runResult, true, 20, true, true);

            Assert.AreEqual(402.711655, runResult.TheoreticalIsotopicPeakList[0].MZ);
            Assert.AreEqual(100, runResult.TheoreticalIsotopicPeakList[0].Intensity);
            Assert.AreEqual(403.211655, runResult.TheoreticalIsotopicPeakList[1].MZ);
            Assert.AreEqual(41.490242039325295, runResult.TheoreticalIsotopicPeakList[1].Intensity);
            Assert.AreEqual(20, runResult.TheoreticalIsotopicPeakList.Count);
        }
Example #13
0
 public RunResult GetRunResult(Result result, Run run, Peptide peptide)
 {
     return (from data in result.RunResults
             where data.Run.FileName == run.FileName && (data.Peptide.MonoIsotopicMass == peptide.MonoIsotopicMass && data.Peptide.RT == peptide.RT && data.Peptide.ChargeState == peptide.ChargeState)
             select data).FirstOrDefault();
 }
        public void Execute(RunResult result, IXYData msmsSpectrum)
        {
            output.Publish("     MSMS Fragment Analyzer");

            PeptideUtility pu = new PeptideUtility();

            if (result.IsResultBasedOnFragment)
            {
                pu.GetIsotopicProfileForFragmentIon(result, 20);
            }
            else
            {
                result.TheoreticalIsotopicPeakList = pu.GetIsotopicProfile(result.Peptide.Sequence, result.Peptide.ChargeState, true, 20, true, true, string.Empty);
            }

            Peptide peptide = new Peptide(result.FragmentIon.Sequence);
            peptide.MonoIsotopicMass = result.FragmentIon.MZ;
            peptide.ChargeState = result.FragmentIon.ChargeState;
            peptide.PeaksInCalculation = result.FragmentIon.PeaksInCalculation;
            peptide.MsThreshold = result.FragmentIon.MsThreshold;
            peptide.DeuteriumDistributionRightPadding = result.FragmentIon.DeutDistRightPadding;
            peptide.DeuteriumDistributionThreshold = result.FragmentIon.DeutDistThreshold;

            RunResult rr = new RunResult(peptide, result.Run);
            rr.IsResultBasedOnFragment = true;
            rr.FragmentIon = result.FragmentIon;
            rr.TheoreticalIsotopicPeakList = result.TheoreticalIsotopicPeakList;

            try
            {
                output.Publish("     Executing Spectral Peak Detection");
                SpectralPeakDetection mspeakDetector = new SpectralPeakDetection(eventAggregator);
                mspeakDetector.PeakToBackgroundRatio = _peakToBackgroundRatio;
                mspeakDetector.SignalToNoiseThreshold = _signalToNoiseThreshold;
                IList<MSPeak> peakList = mspeakDetector.Execute(msmsSpectrum);

                output.Publish("     Executing Isotopic Profile Finder");
                IsotopicProfileFinder profileFinder = new IsotopicProfileFinder(eventAggregator);
                profileFinder.IntensityThreshold = intensityThreshold;
                profileFinder.MassVariability = massVariability;
                profileFinder.MSPeakSelectionOption = _msPeakSelectionOption;
                profileFinder.PeakNumberMaximum = peakNumberMaximum;
                profileFinder.PeakWidthMaximum = peakWidthMaximum;
                profileFinder.PeakWidthMinimum = peakWidthMinimum;
                profileFinder.Execute(rr, peakList);

                output.Publish("     Executing Label Amount Calculator");
                LabelAmountCalculator labelAmountCalc = new LabelAmountCalculator(eventAggregator);
                labelAmountCalc.PeaksInCalcMode = PeaksInLabelCalculationMode.Manual;
                labelAmountCalc.Mode = Mode.CalculatedMassAndExperimentalIntensity;
                labelAmountCalc.Execute(rr);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            result.IsotopicPeakList = rr.IsotopicPeakList;
            output.Publish("     IsotopicPeakList Count=" + result.IsotopicPeakList.Count);
            result.AverageMass = rr.AverageMass;
            output.Publish("     AverageMass=" + result.AverageMass);
            result.TheoreticalAverageMass = MSUtility.GetAverageMassFromPeakList(result.TheoreticalIsotopicPeakList, result.ActualPeaksInCalculation);  // TODO: this is a bandaid solution
            output.Publish("     TheoreticalAverageMass=" + result.TheoreticalAverageMass);
            result.AmountDeut = rr.AmountDeut;
            output.Publish("     AmountDeut=" + result.AmountDeut);
            result.IsUsedInCalculations = rr.IsUsedInCalculations;
            output.Publish("     IsUsedInCalculations=" + result.IsUsedInCalculations);
            result.AmountDeutFromDeutDist = rr.AmountDeutFromDeutDist;
            output.Publish("     AmountDeutFromDeutDist=" + result.AmountDeutFromDeutDist);
        }
Example #15
0
 public FragmentIon(string sequence, Peptide peptide)
 {
     this._sequence = sequence;
     this._peptide = peptide;
 }
Example #16
0
        public void ExecuteWithMostIntenseWithinEntireXicWithoutAnyPeaks()
        {
            IList<ChromatographicPeak> testPeaks = new List<ChromatographicPeak>();

            Peptide testPeptide = new Peptide("AAA");

            outputEvent.Subscribe(OnPublishMostIntenseWithinEntireXicWithoutPeaks);

            xicPeakPicker.XicPeakPickerOption = XicPeakPickerOption.MostIntenseWithinEntireXic;
            ChromatographicPeak selectedPeak = xicPeakPicker.Execute(testPeaks, testPeptide);

            Assert.IsNull(selectedPeak);
            Assert.AreEqual(true, publishCalled);
            Assert.AreEqual(2, messageCount);
        }
Example #17
0
 private Peptide CreatePeptide(double rt, double rtVariance)
 {
     Peptide testPeptide = new Peptide("AAA");
     testPeptide.RT = rt;
     testPeptide.RtVariance = rtVariance;
     return testPeptide;
 }
Example #18
0
        public void GetIsotopicProfileUsingRunResultWithInvalidSequence()
        {
            Peptide peptide = new Peptide("ZAMPLER");
            peptide.ChargeState = 2;
            RunResult runResult = new RunResult(peptide, null);
            peptideUtility.GetIsotopicProfile(runResult, true, 20, true, true);

            Assert.AreEqual(0, runResult.TheoreticalIsotopicPeakList.Count);
        }
        public IList<Peptide> Read(string filename)
        {
            IList<Peptide> peptides = new List<Peptide>();

            IList<string> tableHeaders = new List<string>();
            StreamReader reader = new StreamReader(filename);

            string searchString0 = @"^[iI][dD]";
            string headerline = reader.ReadLine();

            Regex regex = new Regex(searchString0);
            Match match = regex.Match(headerline);

            if (match.Success)
            {
                tableHeaders = ProcessLine(headerline);
            }

            int lineIndex = 1;
            string line;
            do
            {
                ++lineIndex;
                line = reader.ReadLine();
                IList<string> processedData = ProcessLine(line);
                if (processedData.Count > tableHeaders.Count)
                {
                    throw new Exception("TODO");
                }

                Peptide peptide = new Peptide();

                try
                {
                    peptide.Id = ConvertStringToInteger(processedData[GetIndex(tableHeaders, "ID")], -1);
                }
                catch (Exception)
                {
                    peptide.Id = -1;
                }

                try
                {
                    peptide.ProteinSource = processedData[GetIndex(tableHeaders, "ProteinSource")];
                }
                catch (Exception)
                {
                    peptide.ProteinSource = string.Empty;
                }

                try
                {
                    peptide.AminoAcidStart = ConvertStringToInteger(processedData[GetIndex(tableHeaders, "AminoAcidStart")], -1);
                }
                catch (Exception)
                {
                    peptide.AminoAcidStart = -1;
                }

                try
                {
                    peptide.AminoAcidStop = ConvertStringToInteger(processedData[GetIndex(tableHeaders, "AminoAcidStop")], -1);
                }
                catch (Exception)
                {
                    peptide.AminoAcidStop = -1;
                }

                try
                {
                    peptide.Sequence = processedData[GetIndex(tableHeaders, "Sequence")];
                }
                catch (Exception)
                {
                    peptide.Sequence = string.Empty;
                }

                try
                {
                    peptide.MonoIsotopicMass = ConvertStringToDouble(processedData[GetIndex(tableHeaders, "MonoIsotopicMass")], -1);
                }
                catch (Exception)
                {
                    peptide.MonoIsotopicMass = -1;
                }

                try
                {
                    peptide.ChargeState = ConvertStringToInteger(processedData[GetIndex(tableHeaders, "Z")], 0);
                }
                catch (Exception)
                {
                    peptide.ChargeState = 0;
                }

                try
                {
                    peptide.Period = ConvertStringToInteger(processedData[GetIndex(tableHeaders, "Period")], 0);
                }
                catch (Exception)
                {
                    peptide.Period = 0;
                }

                try
                {
                    peptide.RT = ConvertStringToDouble(processedData[GetIndex(tableHeaders, "RT")], 0);
                }
                catch (Exception)
                {
                    peptide.RT = 0;
                }

                // TODO: reference default rtVar value
                try
                {
                    peptide.RtVariance = ConvertStringToDouble(processedData[GetIndex(tableHeaders, "RTVariance")], 0.75);
                }
                catch (Exception)
                {
                    peptide.RtVariance = 0.75;
                }

                try
                {
                    peptide.XicMass1 = ConvertStringToDouble(processedData[GetIndex(tableHeaders, "XicMass1")], peptide.MonoIsotopicMass);
                }
                catch (Exception)
                {
                    peptide.XicMass1 = peptide.MonoIsotopicMass;
                }

                try
                {
                    peptide.XicMass2 = ConvertStringToDouble(processedData[GetIndex(tableHeaders, "XicMass2")], 0);
                }
                catch (Exception)
                {
                    peptide.XicMass2 = 0;
                }

                try
                {
                    peptide.XicAdjustment = ConvertStringToDouble(processedData[GetIndex(tableHeaders, "XicAdjustment")], 0);
                }
                catch (Exception)
                {
                    peptide.XicAdjustment = 0;
                }

                // TODO: reference Properties
                try
                {
                    peptide.XicSelectionWidth = ConvertStringToDouble(processedData[GetIndex(tableHeaders, "XicSelectionWidth")], 0.2);
                }
                catch (Exception)
                {
                    peptide.XicSelectionWidth = 0.2;
                }

                try
                {
                    peptide.MsThreshold = ConvertStringToDouble(processedData[GetIndex(tableHeaders, "MsThreshold")], 0);
                }
                catch (Exception)
                {
                    peptide.MsThreshold = 0;
                }

                try
                {
                    peptide.PeaksInCalculation = ConvertStringToInteger(processedData[GetIndex(tableHeaders, "PeaksInCalculation")], 2);
                }
                catch (Exception)
                {
                    peptide.PeaksInCalculation = 2;
                }

                try
                {
                    peptide.DeuteriumDistributionThreshold = ConvertStringToInteger(processedData[GetIndex(tableHeaders, "DeutDistThreshold")], 1);
                }
                catch (Exception)
                {
                    peptide.DeuteriumDistributionThreshold = 1;
                }

                try
                {
                    peptide.DeuteriumDistributionRightPadding = ConvertStringToInteger(processedData[GetIndex(tableHeaders, "DeutDistRightPadding")], 2);
                }
                catch (Exception)
                {
                    peptide.DeuteriumDistributionRightPadding = 2;
                }

                try
                {
                    peptide.Notes = processedData[GetIndex(tableHeaders, "Notes")];
                }
                catch (Exception)
                {
                    peptide.Notes = string.Empty;
                }

                peptides.Add(peptide);
            }
            while (reader.Peek() > -1);

            return peptides;
        }
Example #20
0
        private RunResult CreateRunResult(string sequence, FragmentIonType fragmentIonType)
        {
            Peptide peptide = new Peptide(sequence);
            RunResult runResult = new RunResult(new FragmentIon(sequence, peptide), null);
            runResult.FragmentIon.FragmentIonType = fragmentIonType;

            return runResult;
        }