private void Normalize()
 {
     foreach (var groupParameter in GroupParameter.GetAllFragmentGroupParameters(_maxCharge))
     {
         if (!IsotopeIntensityCorrProbDictionary.ContainsKey(groupParameter))
         {
             IsotopeIntensityCorrProbDictionary[groupParameter] = new Dictionary <IonType, Dictionary <int, double> >();
         }
         var si = IsotopeIntensityCorrProbDictionary[groupParameter];
         foreach (var ionType in _ionTypes[groupParameter])
         {
             if (!si.ContainsKey(ionType))
             {
                 si[ionType] = new Dictionary <int, double>();
             }
             var ssi = si[ionType];
             var sum = 0.0;
             foreach (var score in SubScoreFactory.GetAllCorrIntScore())
             {
                 if (!ssi.ContainsKey(score))
                 {
                     ssi[score] = 1.0;
                 }
                 sum = sum + ssi[score];
             }
             var keys = new List <int>(ssi.Keys);
             foreach (var score in keys)
             {
                 ssi[score] = Math.Max(double.MinValue, ssi[score] / sum);
             }
         }
     }
 }
Пример #2
0
 private void GetIonTypes()
 {
     foreach (var groupParameter in GroupParameter.GetAllFragmentGroupParameters(_maxCharge))
     {
         IonTypes[groupParameter] = new List <IonType>();
         if (!_ionFrequencyFunction.ContainsKey(groupParameter))
         {
             continue;
         }
         var subIonFrequencyFunction = _ionFrequencyFunction[groupParameter];
         var subIonTypes             = IonTypes[groupParameter];
         var offsets = new List <double>(subIonFrequencyFunction.Values);
         offsets.Sort();//ascending
         foreach (var ionType in subIonFrequencyFunction.Keys)
         {
             if (offsets.Count <= NumberPerGroup || subIonFrequencyFunction[ionType] < offsets[offsets.Count - NumberPerGroup])
             {
                 continue;
             }
             if (subIonTypes.Count < NumberPerGroup)
             {
                 subIonTypes.Add(ionType);
             }
         }
     }
 }
        private void Normalize()
        {
            foreach (var groupParameter in GroupParameter.GetAllFragmentGroupParameters(_maxCharge))
            {
                if (!RatioProbDictionary.ContainsKey(groupParameter))
                {
                    RatioProbDictionary[groupParameter] = new Dictionary <Tuple <IonType, IonType>, Dictionary <int, double> >();
                }
                if (!_allNumberDictionary.ContainsKey(groupParameter))
                {
                    _allNumberDictionary[groupParameter] = 1.0;
                }
                if (!NoIonProbDictionary.ContainsKey(groupParameter))
                {
                    NoIonProbDictionary[groupParameter] = 1.0;
                }

                NoIonProbDictionary[groupParameter] = NoIonProbDictionary[groupParameter] /
                                                      Math.Max(_allNumberDictionary[groupParameter], 1.0);

                var sr = RatioProbDictionary[groupParameter];

                foreach (var ionType in _ionTypes[groupParameter])
                {
                    foreach (var ionType2 in _ionTypes[groupParameter])
                    {
                        var sum      = 0.0;
                        var ionTypes = new Tuple <IonType, IonType> (ionType, ionType2);
                        if (!sr.ContainsKey(ionTypes))
                        {
                            sr[ionTypes] = new Dictionary <int, double>();
                        }
                        var ssr = sr[ionTypes];
                        foreach (var ratio in FeatureEdge.GetAllRatioIndices())
                        {
                            if (!ssr.ContainsKey(ratio))
                            {
                                ssr[ratio] = 1.0;
                            }
                            sum = sum + ssr[ratio];
                        }
                        var keys = new List <int> (ssr.Keys);
                        foreach (var ratio in keys)
                        {
                            ssr[ratio] = Math.Max(Double.MinValue, ssr[ratio] / sum);
                        }
                    }
                }
            }
        }