private int GetCorrelationScore(Tuple <List <MSMSSpectrumPeak>, double[]> isotopomerTuple)
        {
            var observed     = isotopomerTuple.Item1;
            var theoretical  = isotopomerTuple.Item2;
            var maxIndex     = 0;
            var maxAbundance = double.NegativeInfinity;

            for (var i = 0; i < theoretical.Length; i++)
            {
                if (!(maxAbundance < theoretical[i]))
                {
                    continue;
                }
                maxAbundance = theoretical[i];
                maxIndex     = i;
            }
            var c1 = new double[theoretical.Length + FeatureNode.OffsetFromMonoIsotope];
            var c2 = new double[theoretical.Length + FeatureNode.OffsetFromMonoIsotope];

            for (var i = 0; i < c1.Length; i++)
            {
                var i1 = maxIndex + i;
                var i2 = -FeatureNode.OffsetFromMonoIsotope + maxIndex + i;
                c1[i] = observed[Math.Min(i1, observed.Count - 1)].Intensity;
                c2[i] = i2 < 0 ? 0 : theoretical[Math.Min(i2, theoretical.Length - 1)];
            }
            //    Console.WriteLine(c1.Length);
            return(SubScoreFactory.CorrToIntForIsotopeScore(SimpleMath.GetCorrelation(c1, c2)));
        }
 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);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public FeatureEdge(FeatureNode l, FeatureNode r, SubScoreFactory scoringParams)
 {
     LNode = l;
     RNode = r;
     var ri = r.Feature == null ? 0.0 : r.Feature.IntensityMax;
     var li = l.Feature == null ? 0.0 : l.Feature.IntensityMax;
     _scoringParams = scoringParams;
     
     if (LNode is PrecursorFeatureNode) // TODO fix later when no summed intensity is used
         _ratio = GetRatioIndex(ri, ri);
     else
         _ratio = GetRatioIndex(li, ri);
     
     Weight = GetWeight();
 }
Ejemplo n.º 4
0
        public FeatureEdge(FeatureNode l, FeatureNode r, SubScoreFactory scoringParams)
        {
            LNode = l;
            RNode = r;
            var ri = r.Feature == null ? 0.0 : r.Feature.IntensityMax;
            var li = l.Feature == null ? 0.0 : l.Feature.IntensityMax;

            _scoringParams = scoringParams;

            if (LNode is PrecursorFeatureNode) // TODO fix later when no summed intensity is used
            {
                _ratio = GetRatioIndex(ri, ri);
            }
            else
            {
                _ratio = GetRatioIndex(li, ri);
            }

            Weight = GetWeight();
        }
Ejemplo n.º 5
0
 public PrecursorFeatureNode(IsotopomerFeatures isotopomerFeatures, GroupParameter parameter, SubScoreFactory scoringParams)
     : base(isotopomerFeatures, null, isotopomerFeatures.GetMostAbundantFeature(), parameter)
 {
     _scoringParams = scoringParams;
     Score          = GetScore();
 }
Ejemplo n.º 6
0
 public PrecursorFeatureNode(IsotopomerFeatures isotopomerFeatures, GroupParameter parameter, SubScoreFactory scoringParams)
     : base(isotopomerFeatures, null, isotopomerFeatures.GetMostAbundantFeature(), parameter)
 {
     _scoringParams = scoringParams;
     Score = GetScore();
 }