Beispiel #1
0
        public override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);
            ControlAnnotation             = reader.GetAttribute(ATTR.control_annotation);
            ControlValue                  = reader.GetAttribute(ATTR.control_value);
            CaseValue                     = reader.GetAttribute(ATTR.case_value);
            IdentityAnnotation            = reader.GetAttribute(ATTR.identity_annotation);
            AverageTechnicalReplicates    = reader.GetBoolAttribute(ATTR.avg_tech_replicates, true);
            NormalizationMethod           = NormalizationMethod.FromName(reader.GetAttribute(ATTR.normalization_method));
            IncludeInteractionTransitions = reader.GetBoolAttribute(ATTR.include_interaction_transitions, false);
            SummarizationMethod           = SummarizationMethod.FromName(reader.GetAttribute(ATTR.summarization_method));
            ConfidenceLevelTimes100       = reader.GetDoubleAttribute(ATTR.confidence_level, 95);
            PerProtein                    = reader.GetBoolAttribute(ATTR.per_protein, false);
            UseZeroForMissingPeaks        = reader.GetBoolAttribute(ATTR.use_zero_for_missing_peaks, false);
            QValueCutoff                  = reader.GetNullableDoubleAttribute(ATTR.q_value_cutoff);

            var colorRows = new List <MatchRgbHexColor>();

            reader.Read();
            while (reader.IsStartElement(MatchRgbHexColor.XML_ROOT))
            {
                var row = new MatchRgbHexColor();
                row.ReadXml(reader);
                colorRows.Add(row);
            }

            if (colorRows.Any())
            {
                reader.Read();
            }

            ColorRows = ImmutableList <MatchRgbHexColor> .ValueOf(colorRows);
        }
 private bool Equals(NormalizationMethod other)
 {
     if (null == IsotopeLabelTypeName)
     {
         return(ReferenceEquals(this, other));
     }
     return(Equals(IsotopeLabelTypeName, other.IsotopeLabelTypeName));
 }
Beispiel #3
0
            public static bool Matches(NormalizationMethod normalizationMethod, IsotopeLabelType isotopeLabelType)
            {
                if (isotopeLabelType == null)
                {
                    return(false);
                }
                RatioToLabel ratioToLabel = normalizationMethod as RatioToLabel;

                return(ratioToLabel != null && Equals(ratioToLabel.Name, isotopeLabelType.Name));
            }
Beispiel #4
0
 private bool Equals(NormalizationMethod other)
 {
     if (null == other)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Name.Equals(other.Name));
 }
Beispiel #5
0
 public override void ReadXml(XmlReader reader)
 {
     base.ReadXml(reader);
     ControlAnnotation             = reader.GetAttribute(ATTR.control_annotation);
     ControlValue                  = reader.GetAttribute(ATTR.control_value);
     CaseValue                     = reader.GetAttribute(ATTR.case_value);
     IdentityAnnotation            = reader.GetAttribute(ATTR.identity_annotation);
     AverageTechnicalReplicates    = reader.GetBoolAttribute(ATTR.avg_tech_replicates, true);
     SumTransitions                = reader.GetBoolAttribute(ATTR.sum_transitions, true);
     NormalizationMethod           = NormalizationMethod.FromName(reader.GetAttribute(ATTR.normalization_method));
     IncludeInteractionTransitions = reader.GetBoolAttribute(ATTR.include_interaction_transitions, false);
     SummarizationMethod           = SummarizationMethod.FromName(reader.GetAttribute(ATTR.summarization_method));
     ConfidenceLevelTimes100       = reader.GetDoubleAttribute(ATTR.confidence_level, 95);
     PerProtein                    = reader.GetBoolAttribute(ATTR.per_protein, false);
     reader.Read();
 }
Beispiel #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ (ControlAnnotation != null ? ControlAnnotation.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ControlValue != null ? ControlValue.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CaseValue != null ? CaseValue.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IdentityAnnotation != null ? IdentityAnnotation.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ AverageTechnicalReplicates.GetHashCode();
         hashCode = (hashCode * 397) ^ SumTransitions.GetHashCode();
         hashCode = (hashCode * 397) ^ NormalizationMethod.GetHashCode();
         hashCode = (hashCode * 397) ^ IncludeInteractionTransitions.GetHashCode();
         hashCode = (hashCode * 397) ^ SummarizationMethod.GetHashCode();
         hashCode = (hashCode * 397) ^ ConfidenceLevel.GetHashCode();
         hashCode = (hashCode * 397) ^ PerProtein.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #7
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ (ControlAnnotation != null ? ControlAnnotation.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ControlValue != null ? ControlValue.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CaseValue != null ? CaseValue.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IdentityAnnotation != null ? IdentityAnnotation.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ AverageTechnicalReplicates.GetHashCode();
         hashCode = (hashCode * 397) ^ (NormalizationMethod != null ? NormalizationMethod.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ IncludeInteractionTransitions.GetHashCode();
         hashCode = (hashCode * 397) ^ (SummarizationMethod != null ? SummarizationMethod.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ ConfidenceLevelTimes100.GetHashCode();
         hashCode = (hashCode * 397) ^ PerProtein.GetHashCode();
         hashCode = (hashCode * 397) ^ UseZeroForMissingPeaks.GetHashCode();
         hashCode = (hashCode * 397) ^ QValueCutoff.GetHashCode();
         hashCode = (hashCode * 397) ^ (ColorRows != null ? ColorRows.GetHashCode() : 0);
         return(hashCode);
     }
 }
 public static double? SumQuantities(IEnumerable<Quantity> quantities, NormalizationMethod normalizationMethod)
 {
     double numerator = 0;
     double denominator = 0;
     int count = 0;
     foreach (var quantity in quantities)
     {
         numerator += quantity.Intensity;
         denominator += quantity.Denominator;
         count++;
     }
     if (count == 0)
     {
         return null;
     }
     if (!string.IsNullOrEmpty(normalizationMethod.IsotopeLabelTypeName))
     {
         return numerator/denominator;
     }
     return numerator/denominator*count;
 }
Beispiel #9
0
        public static double?SumQuantities(IEnumerable <Quantity> quantities, NormalizationMethod normalizationMethod, bool simpleRatios)
        {
            double numerator   = 0;
            double denominator = 0;
            int    count       = 0;

            foreach (var quantity in quantities)
            {
                numerator   += quantity.Intensity;
                denominator += quantity.Denominator;
                count++;
            }
            if (count == 0)
            {
                return(null);
            }
            if (!simpleRatios && normalizationMethod is NormalizationMethod.RatioToLabel)
            {
                return(numerator / denominator);
            }
            return(numerator / denominator * count);
        }
Beispiel #10
0
        public static double?SumQuantities(IEnumerable <Quantity> quantities, NormalizationMethod normalizationMethod)
        {
            double numerator   = 0;
            double denominator = 0;
            int    count       = 0;

            foreach (var quantity in quantities)
            {
                numerator   += quantity.Intensity;
                denominator += quantity.Denominator;
                count++;
            }
            if (count == 0)
            {
                return(null);
            }
            if (!string.IsNullOrEmpty(normalizationMethod.IsotopeLabelTypeName))
            {
                return(numerator / denominator);
            }
            return(numerator / denominator * count);
        }
Beispiel #11
0
        private Quantity GetTransitionQuantity(
            SrmSettings srmSettings,
            IDictionary <PeptideDocNode.TransitionKey, TransitionChromInfo> peptideStandards,
            NormalizationMethod normalizationMethod,
            int replicateIndex,
            TransitionGroupDocNode transitionGroup, TransitionDocNode transition,
            bool treatMissingAsZero)
        {
            if (null == transition.Results)
            {
                return(null);
            }
            if (replicateIndex >= transition.Results.Count)
            {
                return(null);
            }
            var chromInfos = transition.Results[replicateIndex];

            if (chromInfos.IsEmpty)
            {
                return(null);
            }
            var chromInfo = GetTransitionChromInfo(transition, replicateIndex);

            if (null == chromInfo)
            {
                return(null);
            }
            double?normalizedArea = GetArea(treatMissingAsZero, QValueCutoff, IncludeTruncatedPeaks, transitionGroup, transition, replicateIndex, chromInfo);

            if (!normalizedArea.HasValue)
            {
                return(null);
            }

            double denominator = 1.0;

            if (null != peptideStandards)
            {
                if (QuantificationSettings.SimpleRatios)
                {
                    if (peptideStandards.Count == 0)
                    {
                        return(null);
                    }

                    denominator = peptideStandards.Values.Sum(value => value.Area);
                }
                else
                {
                    TransitionChromInfo chromInfoStandard;
                    if (!peptideStandards.TryGetValue(GetRatioTransitionKey(transitionGroup, transition), out chromInfoStandard))
                    {
                        return(null);
                    }
                    else
                    {
                        denominator = chromInfoStandard.Area;
                    }
                }
            }
            else
            {
                if (chromInfo.IsTruncated.GetValueOrDefault())
                {
                    return(null);
                }
                if (Equals(normalizationMethod, NormalizationMethod.GLOBAL_STANDARDS))
                {
                    var fileInfo = srmSettings.MeasuredResults.Chromatograms[replicateIndex]
                                   .GetFileInfo(chromInfo.FileId);
                    if (fileInfo == null)
                    {
                        return(null);
                    }
                    denominator = srmSettings.CalcGlobalStandardArea(replicateIndex, fileInfo);
                }
                else if (normalizationMethod is NormalizationMethod.RatioToSurrogate)
                {
                    denominator = ((NormalizationMethod.RatioToSurrogate)NormalizationMethod)
                                  .GetStandardArea(srmSettings, replicateIndex, chromInfo.FileId);
                }
                else if (Equals(normalizationMethod, NormalizationMethod.EQUALIZE_MEDIANS))
                {
                    var normalizationData = GetNormalizationData();
                    if (null == normalizationData)
                    {
                        throw new InvalidOperationException(string.Format(@"Normalization method '{0}' is not supported here.", NormalizationMethod));
                    }
                    double?medianAdjustment = normalizationData.GetMedian(chromInfo.FileId, transitionGroup.TransitionGroup.LabelType)
                                              - normalizationData.GetMedianMedian(srmSettings.MeasuredResults.Chromatograms[replicateIndex].SampleType, transitionGroup.TransitionGroup.LabelType);
                    if (!medianAdjustment.HasValue)
                    {
                        return(null);
                    }
                    normalizedArea /= Math.Pow(2.0, medianAdjustment.Value);
                }
                else if (Equals(normalizationMethod, NormalizationMethod.TIC))
                {
                    var factor = srmSettings.GetTicNormalizationDenominator(replicateIndex, chromInfo.FileId);
                    if (!factor.HasValue)
                    {
                        return(null);
                    }
                    denominator = factor.Value;
                }
            }
            return(new Quantity(normalizedArea.Value, denominator));
        }
Beispiel #12
0
 public GroupComparisonDef ChangeNormalizationMethod(NormalizationMethod value)
 {
     return(ChangeProp(ImClone(this), im => im.NormalizationMethod = value));
 }
 private bool Equals(NormalizationMethod other)
 {
     if (null == IsotopeLabelTypeName)
     {
         return ReferenceEquals(this, other);
     }
     return Equals(IsotopeLabelTypeName, other.IsotopeLabelTypeName);
 }
 public GroupComparisonDef ChangeNormalizationMethod(NormalizationMethod value)
 {
     return ChangeProp(ImClone(this), im => im.NormalizationMethod = value);
 }
 public QuantificationSettings ChangeNormalizationMethod(NormalizationMethod normalizationMethod)
 {
     return ChangeProp(ImClone(this), im => im.NormalizationMethod = normalizationMethod);
 }