Пример #1
0
        public ProcessedRowData ComputeAvgTurnover(RawRowData rowData)
        {
            var result = new ProcessedRowData(rowData)
            {
                RejectReason = IsAcceptable(rowData),
            };

            result.InitialPrecursorPool = HalfLifeSettings.InitialPrecursorPool;
            if (rowData.MsDataFile.PrecursorPool.HasValue)
            {
                result.CurrentPrecursorPool = 100 * rowData.MsDataFile.PrecursorPool.Value.DoubleValue;
            }
            if (!result.CurrentPrecursorPool.HasValue)
            {
                switch (HalfLifeSettings.PrecursorPoolCalculation)
                {
                case PrecursorPoolCalculation.Fixed:
                    result.CurrentPrecursorPool = HalfLifeSettings.CurrentPrecursorPool;
                    break;

                case PrecursorPoolCalculation.MedianPerSample:
                    double precursorPool;
                    if (_precursorPools.TryGetValue(rowData.MsDataFile.Id, out precursorPool))
                    {
                        result.CurrentPrecursorPool = precursorPool;
                    }
                    break;

                case PrecursorPoolCalculation.Individual:
                    result.CurrentPrecursorPool = rowData.IndPrecursorEnrichment * 100;
                    break;
                }
            }
            switch (HalfLifeSettings.NewlySynthesizedTracerQuantity)
            {
            case TracerQuantity.LabeledAminoAcid:
                result.RawValue = rowData.TracerPercent / 100;
                break;

            case TracerQuantity.UnlabeledPeptide:
                if (rowData.Peaks.Count > 0)
                {
                    result.RawValue = rowData.Peaks[0].Area / rowData.AreaUnderCurve;
                }
                break;
            }
            if (!result.CurrentPrecursorPool.HasValue)
            {
                if (rowData.TracerPercent == result.InitialPrecursorPool)
                {
                    // In an experiment with no labeling, we don't want to reject this item.
                    // Even if we don't know the CurrentPrecursorPool, we do know that the turnover is 0
                    result.Turnover = 0;
                }
                else
                {
                    result.RejectReason = RejectReason.NoPrecursorPool;
                    return(result);
                }
            }
            else
            {
                switch (HalfLifeSettings.NewlySynthesizedTracerQuantity)
                {
                case TracerQuantity.PartialLabelDistribution:
                {
                    var    turnoverCalculator = GetTurnoverCalculator(rowData.Peptide.Sequence);
                    double?turnover;
                    double?turnoverScore;

                    turnoverCalculator.ComputeTurnover(result.CurrentPrecursorPool.Value, turnoverCalculator.ToTracerFormulaDict(rowData.PeakAreas), out turnover, out turnoverScore);
                    result.Turnover      = turnover;
                    result.TurnoverScore = turnoverScore;
                }
                break;

                case TracerQuantity.LabeledAminoAcid:
                    result.Turnover = (100 * result.RawValue - result.InitialPrecursorPool) /
                                      (result.CurrentPrecursorPool - result.InitialPrecursorPool);
                    break;

                case TracerQuantity.UnlabeledPeptide:
                {
                    var turnoverCalculator = GetTurnoverCalculator(rowData.Peptide.Sequence);
                    var initialRawValue    = turnoverCalculator.ExpectedUnlabeledFraction(result.InitialPrecursorPool);
                    var finalRawValue      = turnoverCalculator.ExpectedUnlabeledFraction(result.CurrentPrecursorPool.Value);
                    result.Turnover = (result.RawValue - initialRawValue) / (finalRawValue - initialRawValue);
                }
                break;
                }
                if (null == result.RejectReason && ValidationStatus.accept != result.RawRowData.ValidationStatus)
                {
                    if (0 < MinTurnoverScore && result.TurnoverScore < MinTurnoverScore)
                    {
                        result.RejectReason = RejectReason.LowTurnoverScore;
                    }
                }
            }
            if (null == result.RejectReason && !result.Turnover.HasValue)
            {
                result.RejectReason = RejectReason.ValueOutOfRange;
            }
            return(result);
        }
Пример #2
0
        public ProcessedRowData ComputeAvgTurnover(RawRowData rowData)
        {
            var result = new ProcessedRowData(rowData)
                             {
                                 RejectReason = IsAcceptable(rowData),
                             };
            result.InitialPrecursorPool = HalfLifeSettings.InitialPrecursorPool;
            if (rowData.MsDataFile.PrecursorPool.HasValue)
            {
                result.CurrentPrecursorPool = 100 * rowData.MsDataFile.PrecursorPool.Value.DoubleValue;
            }
            if (!result.CurrentPrecursorPool.HasValue)
            {
                switch (HalfLifeSettings.PrecursorPoolCalculation)
                {
                    case PrecursorPoolCalculation.Fixed:
                        result.CurrentPrecursorPool = HalfLifeSettings.CurrentPrecursorPool;
                        break;
                    case PrecursorPoolCalculation.MedianPerSample:
                        double precursorPool;
                        if (_precursorPools.TryGetValue(rowData.MsDataFile.Id, out precursorPool))
                        {
                            result.CurrentPrecursorPool = precursorPool;
                        }
                        break;
                    case PrecursorPoolCalculation.Individual:
                        result.CurrentPrecursorPool = rowData.IndPrecursorEnrichment * 100;
                        break;
                }
            }
            switch (HalfLifeSettings.NewlySynthesizedTracerQuantity)
            {
                case TracerQuantity.LabeledAminoAcid:
                    result.RawValue = rowData.TracerPercent/100;
                    break;
                case TracerQuantity.UnlabeledPeptide:
                    if (rowData.Peaks.Count > 0)
                    {
                        result.RawValue = rowData.Peaks[0].Area/rowData.AreaUnderCurve;
                    }
                    break;
            }
            if (!result.CurrentPrecursorPool.HasValue)
            {
                if (rowData.TracerPercent == result.InitialPrecursorPool)
                {
                    // In an experiment with no labeling, we don't want to reject this item.
                    // Even if we don't know the CurrentPrecursorPool, we do know that the turnover is 0
                    result.Turnover = 0;
                }
                else
                {
                    result.RejectReason = RejectReason.NoPrecursorPool;
                    return result;
                }
            }
            else
            {
                switch (HalfLifeSettings.NewlySynthesizedTracerQuantity)
                {
                    case TracerQuantity.PartialLabelDistribution:
                        {
                            var turnoverCalculator = GetTurnoverCalculator(rowData.Peptide.Sequence);
                            double? turnover;
                            double? turnoverScore;

                            turnoverCalculator.ComputeTurnover(result.CurrentPrecursorPool.Value, turnoverCalculator.ToTracerFormulaDict(rowData.PeakAreas), out turnover, out turnoverScore);
                            result.Turnover = turnover;
                            result.TurnoverScore = turnoverScore;
                        }
                        break;
                    case TracerQuantity.LabeledAminoAcid:
                        result.Turnover = (100 * result.RawValue - result.InitialPrecursorPool) /
                                          (result.CurrentPrecursorPool - result.InitialPrecursorPool);
                        break;
                    case TracerQuantity.UnlabeledPeptide:
                        {
                            var turnoverCalculator = GetTurnoverCalculator(rowData.Peptide.Sequence);
                            var initialRawValue = turnoverCalculator.ExpectedUnlabeledFraction(result.InitialPrecursorPool);
                            var finalRawValue = turnoverCalculator.ExpectedUnlabeledFraction(result.CurrentPrecursorPool.Value);
                            result.Turnover = (result.RawValue - initialRawValue) / (finalRawValue - initialRawValue);
                        }
                        break;
                }
                if (null == result.RejectReason && ValidationStatus.accept != result.RawRowData.ValidationStatus)
                {
                    if (0 < MinTurnoverScore && result.TurnoverScore < MinTurnoverScore)
                    {
                        result.RejectReason = RejectReason.LowTurnoverScore;
                    }
                }
            }
            if (null == result.RejectReason && !result.Turnover.HasValue)
            {
                result.RejectReason = RejectReason.ValueOutOfRange;
            }
            return result;
        }