예제 #1
0
        public UMCTreeViewModel(UMCLight feature, UMCCollectionTreeViewModel parent)
        {
            m_feature = feature;
            m_parent  = parent;

            var information = SingletonDataProviders.GetDatasetInformation(m_feature.GroupId);

            if (information != null)
            {
                Name = information.DatasetName;
            }
            else
            {
                Name = string.Format("Dataset {0}", m_feature.GroupId);
            }

            AddStatistic("Id", m_feature.Id);
            AddStatistic("Dataset Id", m_feature.GroupId);
            AddStatistic("Mass", m_feature.MassMonoisotopicAligned, "N2");
            AddStatistic("NET", m_feature.Net, "N2");
            if (m_feature.DriftTime > 0)
            {
                AddStatistic("Drift Time", m_feature.DriftTime, "N2");
            }
            AddStatistic("Charge", m_feature.ChargeState);
        }
예제 #2
0
        public PeptideTreeViewModel(Peptide peptide, TreeItemViewModel parent)
        {
            m_parent  = parent;
            m_peptide = peptide;

            var information = SingletonDataProviders.GetDatasetInformation(m_peptide.GroupId);

            if (information != null)
            {
                Name = information.DatasetName;
            }
            else
            {
                Name = string.Format("Dataset {0}", m_peptide.GroupId);
            }

            AddStatistic("Id", m_peptide.Id);
            AddStatistic("Dataset Id", m_peptide.GroupId);

            AddStatistic("Precursor m/z", m_peptide.Spectrum.PrecursorMz);
            if (m_peptide.Spectrum.ParentFeature != null)
            {
                AddStatistic("Charge", m_peptide.Spectrum.ParentFeature.ChargeState);
            }
            else
            {
                AddStatistic("Charge", m_peptide.Spectrum.PrecursorChargeState);
            }

            AddString("Sequence", peptide.Sequence);
            AddStatistic("Score", peptide.Score);
            AddStatistic("Scan", peptide.Scan);
        }
예제 #3
0
        /// <summary>
        ///     Loads the MS/MS spectrum from file.
        /// </summary>
        /// <param name="spectrum"></param>
        public static List <XYData> LoadSpectrum(MSSpectra spectrum)
        {
            var peaks = new List <XYData>();
            var info  = SingletonDataProviders.GetDatasetInformation(spectrum.GroupId);

            if (info != null && info.RawFile != null && info.RawFile.Path != null)
            {
                peaks = ParentSpectraFinder.GetDaughterSpectrum(info.RawFile.Path, spectrum.Scan);
            }
            return(peaks);
        }
예제 #4
0
        public MsMsTreeViewModel(MSSpectra feature, TreeItemViewModel parent)
        {
            m_feature = feature;
            m_parent  = parent;


            var information = SingletonDataProviders.GetDatasetInformation(m_feature.GroupId);


            AddStatistic("Id", m_feature.Id);
            AddStatistic("Dataset Id", m_feature.GroupId);
            AddStatistic("Precursor m/z", m_feature.PrecursorMz);
            if (feature.ParentFeature != null)
            {
                AddStatistic("Charge", m_feature.ParentFeature.ChargeState);
            }
            else
            {
                AddStatistic("Charge", m_feature.PrecursorChargeState);
            }
            AddStatistic("Scan", m_feature.Scan);


            Peptides = new ObservableCollection <Peptide>();

            Peptide maxPeptide = null;

            foreach (var p in m_feature.Peptides)
            {
                Peptides.Add(p);
                if (maxPeptide == null)
                {
                    maxPeptide = p;
                }
                else if (p.Score < maxPeptide.Score)
                {
                    maxPeptide = p;
                }
            }

            if (maxPeptide != null)
            {
                Name = maxPeptide.Sequence;
                AddStatistic("Score", maxPeptide.Score);
                AddStatistic("Scan", maxPeptide.Scan);
            }
            else
            {
                Name = string.Format("Unknown - Scan: {0} m/z: {1:.00} ", m_feature.Scan, m_feature.PrecursorMz);
            }
        }
예제 #5
0
        public PeptideViewModel(Peptide peptide)
        {
            m_peptide = peptide;

            var info = SingletonDataProviders.GetDatasetInformation(peptide.GroupId);

            if (info != null)
            {
                m_dataset = new DatasetInformationViewModel(info);
            }


            MatchedProteins = new ObservableCollection <ProteinViewModel>();
            LoadProteinData(peptide);
        }
예제 #6
0
        private void SetFeature(UMCLight feature)
        {
            if (feature == null)
            {
                return;
            }

            var info = SingletonDataProviders.GetDatasetInformation(feature.GroupId);

            if (info != null)
            {
                SelectedFeatureName = info.DatasetName;
            }

            var model = new XicViewModel(new List <UMCLight> {
                feature
            }, "XIC");

            model.PointClicked += model_PointClicked;
            XicModel            = model;
            UpdateCharges(feature);
        }
예제 #7
0
        public MsSpectraViewModel(MSSpectra spectrum)
        {
            Peptides = new ObservableCollection <PeptideViewModel>();
            spectrum.Peptides.ForEach(x => Peptides.Add(new PeptideViewModel(x)));

            var info = SingletonDataProviders.GetDatasetInformation(spectrum.GroupId);

            if (info != null)
            {
                Dataset = new DatasetInformationViewModel(info);
            }

            Spectrum = spectrum;
            SelectedSpectrumPlotModel = new MsMsSpectraViewModel(spectrum, "");

            if (spectrum.ParentFeature != null)
            {
                var msFeature = spectrum.ParentFeature;
                var umc       = msFeature.GetParentFeature();
                if (umc != null)
                {
                    var newList = new List <UMCLight> {
                        umc
                    };

                    var xic = new XicViewModel(newList, "xic")
                    {
                        Model =
                        {
                            IsLegendVisible = false,
                            TitleFontSize   = 0
                        }
                    };

                    SelectedSpectrumXic = xic;
                }
            }
        }
예제 #8
0
        public async Task UpdateDatasets()
        {
            this.Datasets.Clear();
            var i = 0;

            foreach (var info in this.Analysis.MetaData.Datasets)
            {
                info.DatasetId = i++;
                SingletonDataProviders.AddDataset(info);
                var viewmodel = new DatasetInformationViewModel(info);
                viewmodel.RemovalRequested += (s, e) =>
                {
                    var vm = s as DatasetInformationViewModel;
                    if (vm != null)
                    {
                        var result =
                            MessageBox.Show(
                                string.Format("Are you sure that you'd like to remove {0}", vm.Dataset.DatasetName),
                                "Remove Dataset?",
                                MessageBoxButton.YesNo);
                        if (result == MessageBoxResult.Yes)
                        {
                            this.Datasets.Remove(vm);
                            this.Analysis.MetaData.Datasets.Remove(vm.Dataset);
                            this.deletedDatasets.Add(vm.Dataset);
                        }
                    }
                };

                viewmodel.StateChanged += (s, e) => this.UpdateProject();
                this.Datasets.Add(viewmodel);
            }

            await this.LoadRawData(this.Datasets);

            this.RaisePropertyChanged("analysisConfig");
        }
예제 #9
0
        private void LoadSpectrum(MSFeatureLight msFeature)
        {
            var info = SingletonDataProviders.GetDatasetInformation(msFeature.GroupId);

            if (info == null || info.RawFile.Path == null || info.RawFile.Path == null)
            {
                return;
            }


            var mz      = msFeature.Mz;
            var charge  = msFeature.ChargeState;
            var spacing = 1.0 / Convert.ToDouble(charge);
            var lowMz   = mz - spacing * 3;
            var highMz  = mz + spacing * (NumberOfIsotopes + 1);

            var spectrum = ParentSpectraFinder.GetParentSpectrum(info.RawFile.Path,
                                                                 msFeature.Scan,
                                                                 lowMz,
                                                                 highMz);

            if (spectrum == null)
            {
                return;
            }

            var name = string.Format("Scan {0} Charge {1} Dataset {2}",
                                     msFeature.Scan,
                                     msFeature.ChargeState,
                                     msFeature.GroupId
                                     );

            var msFeatureSpectra = new MsFeatureSpectraViewModel(msFeature, spectrum, name);

            msFeatureSpectra.SetXExtrema(lowMz, highMz);
            ParentSpectrumViewModel = msFeatureSpectra;
        }
예제 #10
0
        public ClusterExportViewModel(IEnumerable <UMCClusterLightMatched> allClusters,
                                      ObservableCollection <UMCClusterTreeViewModel> filteredClusters)
        {
            m_allClusters      = allClusters;
            m_filteredClusters = filteredClusters;
            m_datasets         = SingletonDataProviders.GetAllInformation();
            Exporters          = new ObservableCollection <IFeatureClusterWriter>();
            var filters = "";

            m_writerExtensionMap = new Dictionary <string, IFeatureClusterWriter>();
            foreach (var exporter in UmcClusterExporterFactory.Create())
            {
                exporter.ShouldLoadClusterData = true;

                if (filters.Length > 1)
                {
                    filters += "| ";
                }
                filters += string.Format(" {0}  (*{1}) | *{1}", exporter.Name,
                                         exporter.Extension
                                         );

                m_writerExtensionMap.Add(exporter.Extension, exporter);

                Exporters.Add(exporter);
            }
            filters += string.Format("|  All Files (*.*) | (*.*)");


            BrowseSave = new BrowseSaveFileCommand((string x) => { OutputPath = x; },
                                                   BaseCommand.AlwaysPass, filters);

            // Action for saving all clusters
            Action saveAction = delegate
            {
                SelectedExporter.Path = OutputPath;
                var clusters = new List <UMCClusterLight>();
                if (IsFilteredClusters)
                {
                    foreach (var x in m_filteredClusters)
                    {
                        clusters.Add(x.Cluster.Cluster);
                    }
                }
                else
                {
                    foreach (var x in m_allClusters)
                    {
                        clusters.Add(x.Cluster);
                    }
                }

                try
                {
                    SelectedExporter.WriteClusters(clusters, m_datasets.ToList());
                    Status = "The file was saved: " + SelectedExporter.Path;
                }
                catch (Exception ex)
                {
                    Status = "Could not save the file: " + ex.Message;
                }
            };


            SaveData = new BaseCommand(saveAction, CanSave);
        }
예제 #11
0
        /// <summary>
        /// Builds XIC plot based on selected charge state chromatograms.
        /// </summary>
        private void BuildPlot()
        {
            this.XicPlotModel.Series.Clear();

            double minX = double.PositiveInfinity;
            double maxX = 0;
            double minY = double.PositiveInfinity;
            double maxY = 0;

            var chargeHash = new HashSet <int>();

            MSFeatureLight maxFeature = null;

            int i = 0;

            foreach (var feature in this.Features)
            {
                var xics = this.GetXic(feature.UMCLight);
                foreach (var xic in xics)
                {
                    if (xic.Count == 0)
                    {
                        continue;
                    }

                    if (!chargeHash.Contains(xic[0].ChargeState))
                    {
                        chargeHash.Add(xic[0].ChargeState);
                    }


                    // Get dataset info for mapping scan # -> retention time
                    var dsInfo = SingletonDataProviders.GetDatasetInformation(feature.UMCLight.GroupId);

                    foreach (var msfeature in xic)
                    {
                        minX = Math.Min(minX, msfeature.Net);
                        maxX = Math.Max(maxX, msfeature.Net);
                        minY = Math.Min(minY, msfeature.Abundance);
                        maxY = Math.Max(maxY, msfeature.Abundance);
                    }

                    var maxA = xic.Max(msf => msf.Abundance);
                    var maxL = xic.FirstOrDefault(msf => msf.Abundance.Equals(maxA));
                    if (maxFeature == null || (maxL != null && maxL.Abundance >= maxFeature.Abundance))
                    {
                        maxFeature = maxL;
                    }

                    var color  = this.Colors[i++ % this.Colors.Count];
                    var series = new LineSeries
                    {
                        ItemsSource           = xic,
                        Mapping               = dataPoint => new DataPoint(((MSFeatureLight)dataPoint).Net, ((MSFeatureLight)dataPoint).Abundance),
                        Title                 = string.Format("{0}({1}+) ID({2})", dsInfo.DatasetName, xic[0].ChargeState, feature.UMCLight.Id),
                        Color                 = color,
                        MarkerType            = MarkerType.Circle,
                        MarkerSize            = 3,
                        MarkerFill            = OxyColors.White,
                        MarkerStroke          = color,
                        MarkerStrokeThickness = 0.5,
                        TrackerFormatString   = "{0}" + Environment.NewLine +
                                                "{1}: {2:0.###} (Scan: {Scan:0})" + Environment.NewLine +
                                                "{3}: {4:0.###E0}" + Environment.NewLine
                    };

                    this.XicPlotModel.Series.Add(series);
                }
            }

            this.SelectedMsFeature = maxFeature;
            this.SetMsFeatureAnnotation();

            this.ChargeStates.Clear();
            foreach (var chargeState in chargeHash)
            {
                this.ChargeStates.Add(new ChargeStateViewModel(chargeState));
            }

            minX = Math.Max(0, minX - (0.01 * minX));
            maxX = maxX + (0.01 * maxX);
            maxY = maxY + (0.05 * maxY);

            this.xaxis.Minimum = minX;
            this.xaxis.Maximum = maxX;
            this.yaxis.Minimum = minY;
            this.yaxis.Maximum = maxY;

            this.xaxis.Zoom(minX, maxX);
            this.yaxis.Zoom(minY, maxY);

            this.XicPlotModel.InvalidatePlot(true);
        }