Ejemplo n.º 1
0
        /// <summary>
        /// Build plot for observed/theoretical isotope envelopes.
        /// </summary>
        /// <param name="selectedFeaturePoint">The selected Feature Point.</param>
        private void BuildIsotopePlots(Feature.FeaturePoint selectedFeaturePoint)
        {
            if (selectedFeaturePoint == null || selectedFeaturePoint.Isotopes.Length == 0)
            {
                return;
            }

            this.IsotopicEnvelope.BuildPlot(
                selectedFeaturePoint.Isotopes,
                selectedFeaturePoint.Mass,
                selectedFeaturePoint.Charge);
            this.IsotopicEnvelopeExpanded = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Read a line from the feature file containing a single feature.
        /// </summary>
        /// <param name="line">The line from the feature file.</param>
        /// <param name="delimeter">The delimiter used in feature file.</param>
        /// <param name="headers">The headers of the feature file columns.</param>
        /// <returns>Parsed feature.</returns>
        private static Feature ReadFeature(string line, char delimeter, IReadOnlyDictionary <string, int> headers)
        {
            var expectedHeaders = new List <string>
            {
                "MonoMass",
                "Abundance",
                "LikelihoodRatio",
                "Envelope",
                "MinCharge",
                "MaxCharge",
                ////"SummedCorr",
                "MinScan",
                "MaxScan"
            };

            string likelihoodVarHeader = "LikelihoodRatio";

            foreach (var header in expectedHeaders.Where(header => !headers.ContainsKey(header)))
            {
                if (header == "LikelihoodRatio" && headers.ContainsKey("Probability"))
                {
                    likelihoodVarHeader = "Probability";
                }
                else
                {
                    throw new KeyNotFoundException(string.Format("Missing expected column header \"{0}\" in feature file.", header));
                }
            }

            var parts     = line.Split(delimeter);
            var mass      = Convert.ToDouble(parts[headers["MonoMass"]]);
            var abundance = Convert.ToDouble(parts[headers["Abundance"]]);
            var score     = Convert.ToDouble(parts[headers[likelihoodVarHeader]]);
            var isotopes  = ReadIsotopicEnvelope(parts[headers["Envelope"]]);
            var minCharge = Convert.ToInt32(parts[headers["MinCharge"]]);
            var maxCharge = Convert.ToInt32(parts[headers["MaxCharge"]]);
            int id        = -1;

            if (headers.ContainsKey("FeatureID"))
            {
                id = Convert.ToInt32(parts[headers["FeatureID"]]);
            }

            var summedCorr = headers.ContainsKey("SummedCorr") ? Convert.ToDouble(parts[headers["SummedCorr"]]) : 0.0;

            int         mostAbundantIsotopeIndex = Averagine.GetIsotopomerEnvelope(mass).MostAbundantIsotopeIndex;
            List <Peak> minIsotopicProfile       = Averagine.GetTheoreticalIsotopeProfile(mass, minCharge, 0);
            List <Peak> maxIsotopicProfile       = Averagine.GetTheoreticalIsotopeProfile(mass, maxCharge, 0);

            var minPoint = new Feature.FeaturePoint
            {
                Id          = id,
                Mass        = mass,
                Scan        = Convert.ToInt32(parts[headers["MinScan"]]),
                Mz          = minIsotopicProfile[mostAbundantIsotopeIndex].Mz,
                Charge      = minCharge,
                Abundance   = abundance,
                Score       = score,
                Isotopes    = isotopes,
                Correlation = summedCorr
            };
            var maxPoint = new Feature.FeaturePoint
            {
                Id          = id,
                Mass        = mass,
                Scan        = Convert.ToInt32(parts[headers["MaxScan"]]),
                Mz          = maxIsotopicProfile[mostAbundantIsotopeIndex].Mz,
                Charge      = maxCharge,
                Abundance   = abundance,
                Score       = score,
                Isotopes    = isotopes,
                Correlation = summedCorr,
            };

            return(new Feature(minPoint, maxPoint)
            {
                Id = id
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Event handler for mouse click event to set SelectedDataPoint
        /// </summary>
        /// <param name="sender">The sender PlotView</param>
        /// <param name="args">The event arguments.</param>
        private void FeatureMapMouseDown(object sender, OxyMouseEventArgs args)
        {
            this.selectedFeaturePoint = null;
            this.selectedPrSmPoint    = null;
            var series = this.FeatureMap.GetSeriesFromPoint(args.Position, 10);

            if (series is LineSeries)
            { // Was a feature clicked?
                var result = series.GetNearestPoint(args.Position, false);
                if (result == null)
                {
                    return;
                }

                var featurePoint = result.Item as Feature.FeaturePoint;
                if (featurePoint != null)
                {
                    // See if there is a ms2 point closer than this feature point
                    PrSm closestPrSm = null;
                    if (this.showFoundIdMs2 || this.showFoundUnIdMs2)
                    {
                        var feature = featurePoint.Feature;
                        var prsms   = feature.AssociatedPrSms;
                        var minDist = result.Position.DistanceToSquared(args.Position);
                        foreach (var prsm in prsms)
                        {
                            if ((prsm.Sequence.Count == 0 && !this.showFoundUnIdMs2) ||
                                (prsm.Sequence.Count > 0 && !this.showFoundIdMs2))
                            {
                                continue;
                            }

                            var sp     = this.xaxis.Transform(prsm.RetentionTime, featurePoint.Mass, this.yaxis);
                            var distSq = sp.DistanceToSquared(args.Position);
                            if (closestPrSm == null || distSq < minDist)
                            {
                                closestPrSm = prsm;
                                minDist     = distSq;
                            }
                        }
                    }

                    if (closestPrSm != null)
                    {
                        this.selectedPrSmPoint = closestPrSm;
                    }

                    this.selectedFeaturePoint = featurePoint;
                }
            }
            else if (series is ScatterSeries)
            { // Was a ms2 cross clicked?
                var result = series.GetNearestPoint(args.Position, false);
                if (result == null)
                {
                    return;
                }

                this.selectedPrSmPoint = result.Item as PrSm;
            }
        }