Example #1
0
 protected FeatureNode(IsotopomerFeatures isotopomerFeatures, IonType ionType, Feature precursorFeature, GroupParameter groupParameter)
 {
     _isotopomerFeatures = isotopomerFeatures;
     FragmentIonClassBase = ionType;
     PrecursorFeature = precursorFeature;
     GroupParameter = groupParameter;
     GetCorrelations();
 }
Example #2
0
 static public double GetImsCorrelation(Feature l, Feature r)
 {
     if (l == null || r == null) return -1;
     var intersection = Rectangle.Intersect(l.GetBoundary(), r.GetBoundary());
     var lims = GetTruncatedIms(l, intersection);
     var rims = GetTruncatedIms(r, intersection);
     return SimpleMath.GetCorrelation(lims, rims);
 }
Example #3
0
 static public double GetLcCorrelation(Feature l, Feature r)
 {
     if (l == null || r == null) return -1;
     var intersection = Rectangle.Intersect(l.GetBoundary(), r.GetBoundary());
     var llc = GetTruncatedLc(l, intersection);
     var rlc = GetTruncatedLc(r, intersection);
     return SimpleMath.GetCorrelation(llc, rlc);
 }
Example #4
0
 public double GetCutScore(char nTermAA, char cTermAA, Composition cutComposition, Feature precursorFeature)
 {
     UpdatePrecursorFeatureNode(precursorFeature);
     var parameter = new GroupParameter(cutComposition, nTermAA, cTermAA, _precursorIon);
     _graph = new FragmentFeatureGraph(_imsData, PrecursorFeatureNode, precursorFeature, _precursorIon,
                                          cutComposition, parameter, _scoringParams);
     SupportingIonTypes = _graph.supportingIonTypes;
     return _graph.Score;
 }
Example #5
0
 static private double[] GetTruncatedIms(Feature feature, Rectangle intersection)
 {
     var sp = intersection.Top - feature.ScanImsStart;
     var ep = sp + intersection.Height;
     var ims = new double[intersection.Height];
     for (var i = sp; i < ep; i++)
         ims[i-sp] = feature.ImsApexPeakProfile[i];
     return ims;
 }
Example #6
0
 static private double[] GetTruncatedLc(Feature feature, Rectangle intersection)
 {
     var sp = intersection.Left - feature.ScanLcStart;
     var ep = sp + intersection.Width;
     var lc = new double[intersection.Width];
     for (var i = sp; i < ep; i++)
         lc[i-sp] = feature.LcApexPeakProfile[i];
     return lc;
 }
Example #7
0
 private void UpdatePrecursorFeatureNode(Feature precursorFeature)
 {
     if (_previousPrecursorFeature != null && _previousPrecursorFeature == precursorFeature) return;
     var parameter = new GroupParameter(_precursorIon);
     PrecursorFeatureNode =
         new PrecursorFeatureNode(
             IsotopomerFeatures.GetPrecursorIsotopomerFeatures(_imsData, _precursorIon, precursorFeature),
             parameter, _scoringParams);
     _previousPrecursorFeature = precursorFeature;
 }
Example #8
0
 static public double GetIsotopeCorrelation(Feature[] f, double[] i)
 {
     var j = new double[f.Length];
     var max = 0.1f;
     for (var k = 0; k < j.Length; k++)
     {
         if(f[k]!=null) max = Math.Max(max,(float) f[k].IntensityMax);
     }
     for (var k = 0; k < j.Length;k++ )
     {
         j[k] = f[k] == null? 0.1 : f[k].IntensityMax/max;
     }
     return SimpleMath.GetCorrelation(j, i);
 }
Example #9
0
 private void GetCorrelations()
 {
     var i = new double[_isotopomerFeatures.Count];
     var f = new Feature[_isotopomerFeatures.Count];
     LcCorrelation = ImsCorrelation = .0;
     for (var k = 0; k < _isotopomerFeatures.Count; k++)
     {
         i[k] = _isotopomerFeatures.TheoreticalIsotopomerEnvelope[k];
         
         var lcCorrelation = StatisticsTools.GetLcCorrelation(PrecursorFeature, _isotopomerFeatures[k]);
         var imsCorrelation = StatisticsTools.GetImsCorrelation(PrecursorFeature, _isotopomerFeatures[k]);
         
         if (lcCorrelation >= 0.25 && imsCorrelation >= 0.25) //TODO take the good numbers!!
         {
             f[k] = _isotopomerFeatures[k];
         }
         if (k != _isotopomerFeatures.MaxIntensityIndex) continue;
         LcCorrelation = lcCorrelation;
         ImsCorrelation = imsCorrelation;
        // Console.WriteLine((FragmentIonClassBase == null? "p" : FragmentIonClassBase.Name) + "** " + k + " " + (f[k] == null));
         Feature = f[k]; // if lc correlation score and ims correlation score are too low, Feature = null;
     }
     IsotopeCorrelation = StatisticsTools.GetIsotopeCorrelation(f, i);
 }
Example #10
0
 public double GetPrecursorScore(Feature precursorFeature)
 {
     UpdatePrecursorFeatureNode(precursorFeature);
     return PrecursorFeatureNode.GetScore();
 }
Example #11
0
        private double GetProductIonScore(ScoringGraphNode node, ImsScorer imsScorer, Feature precursorFeature)
        {
            //Console.Write("Offset: " + node.Offset);
            double cutScore = 0;
            if (node.Index > 1 && node.Index <= _aminoAcidSequence.Length-3)
            {
                var nTermAA = _aminoAcidSequence[node.Index].Residue;
                var cTermAA = _aminoAcidSequence[node.Index + 1].Residue;
                cutScore = imsScorer.GetCutScore(nTermAA, cTermAA, node.Composition, precursorFeature);
                //Console.WriteLine(" " + _aminoAcidSequence[node.Offset].Residue + " " + node.Composition + " " + _aminoAcidSequence[node.Offset + 1].Residue + " " + cutScore);
            }
            //Console.WriteLine();

            if (node.Index > _aminoAcidSequence.Length - 3)
                return 0;
            var nextNodeScore = node.GetNextNodes().DefaultIfEmpty().Max(nextNode => GetProductIonScore(nextNode, imsScorer, precursorFeature));
            return cutScore + nextNodeScore;
        }
Example #12
0
 private double GetProductIonScore(ImsScorer imsScorer, Feature precursorFeature)
 {
     return GetProductIonScore(_rootNode, imsScorer, precursorFeature);
 }
Example #13
0
 public FragmentFeatureNode(IsotopomerFeatures isotopomerFeatures, IonType fragmentIonClassBase, Feature precursorFeature,
     GroupParameter parameter, SubScoreFactory scoringParams)
     : base(isotopomerFeatures, fragmentIonClassBase, precursorFeature, parameter)
 {
     _scoringParams = scoringParams;
 }
Example #14
0
 /// <summary>
 /// Extracts the fragment feature within the boundary of the precursorFeature 
 /// </summary>
 /// <param name="fragmentMz"></param>
 /// <param name="precursorFeature"></param>
 /// <returns>the fragment feature within the boundary of the precursorFeature</returns>
 public Feature GetFramentFeature(double fragmentMz, Feature precursorFeature)
 {
     return GetFeature(fragmentMz, precursorFeature, false);
 }
Example #15
0
 /// <summary>
 /// Gets the precursor feature within the boundary of the precursorFeature
 /// </summary>
 /// <param name="precursorMz">m/z of the precursor</param>
 /// <param name="precursorFeature">precursorFeature defining the retention and drift time boundary</param>
 /// <returns>the precursor feature within the boundary of the precursorFeature</returns>
 public Feature GetPrecursorFeature(double precursorMz, Feature precursorFeature)
 {
     if (precursorMz < MinPrecursorMz || precursorMz > MaxPrecursorMz) return null;
     return GetFeature(precursorMz, precursorFeature, true);
 }
Example #16
0
        private Feature GetFeature(double mz, Feature precursorFeature, bool isPrecursor)
        {
            Feature bestFeature = null;
            const float portionIntersectioinThreshold = 0.1f; // added by Kyowon - testing
            int bestIntersectionArea = 0;
            var precursorBoundary = precursorFeature.GetBoundary();
            
            // TODO: this may not be optimal
            var features = GetFeatures(mz, isPrecursor);
            foreach (var feature in features)
            {
                if (precursorBoundary.Contains(feature.GetHighestPoint()))
                {
                    var boundary = feature.GetBoundary();
                    var intersection = Rectangle.Intersect(precursorBoundary, boundary);
                    var intersectionArea = intersection.Width * intersection.Height;
                    var portionIntersection = (double)intersectionArea / (precursorBoundary.Width * precursorBoundary.Height);
                    if (portionIntersection < portionIntersectioinThreshold)
                        continue;
                    if (intersectionArea > bestIntersectionArea)
                    {
                        bestFeature = feature;
                        bestIntersectionArea = intersectionArea;
                    }
                }
            }

            return bestFeature;
        }