public DatasetInformationViewModel(DatasetInformation information)
        {
            m_information = information;
            var data = information.PlotData;
            PlotData = new ObservableCollection<PlotViewModel>();

            RequestRemovalCommand = new BaseCommand(
                () =>
                    {
                        if (RemovalRequested != null)
                        {
                            RemovalRequested(this, EventArgs.Empty);
                        }
                    }, s => !this.DoingWork);

            if (data != null)
            {
                PlotData.Add(new PlotViewModel(data.Alignment,
                    "Alignment",
                    new PictureDisplayCommand(data.Alignment, "Alignment" + information.DatasetName)));
                PlotData.Add(new PlotViewModel(data.Features,
                    "Features",
                    new FeatureDisplayCommand(information)));

                PlotData.Add(new PlotViewModel(data.MassErrorHistogram, "Mass Error Histogram"));
                PlotData.Add(new PlotViewModel(data.NetErrorHistogram, "NET Error Histogram"));
                PlotData.Add(new PlotViewModel(data.MassScanResidual, "Mass vs Scan Residuals"));
                PlotData.Add(new PlotViewModel(data.MassMzResidual, "Mass vs m/z Residuals"));
                PlotData.Add(new PlotViewModel(data.NetResiduals, "NET Residuals"));
            }

            ModifyDatasetCommand = new ShowDatasetDetailCommand();
        }
        public UmcClusterSpectraViewModel()
        {
            Spectra = new ObservableCollection<MsSpectraViewModel>();
            SortTypes = new ObservableCollection<SpectraSortOptions>();

            CreateSortOptions();

            ExpandIdentifications = new BaseCommand(delegate
            {
                foreach (var spectrum in Spectra)
                {
                    spectrum.IdentificationsExpanded = true;
                }
            }
                );

            CollapseIdentifications = new BaseCommand(delegate
            {
                foreach (var spectrum in Spectra)
                {
                    spectrum.IdentificationsExpanded = false;
                }
            }
                );
        }
        public AnalysisBaselineSelectionViewModel(MultiAlignAnalysis analysis)
        {
            var filter =
                "Mass Tag Database (.db3)|*.db3|Direct Infusion IMS Database (.dims)|*.dims|All Files (*.*)|*.*";
            m_analysis = analysis;

            IsDatabaseDms = false;
            IsDatabaseLocal = false;
            IsBaselineDataset = true;

            SetDatabaseToDms = new BaseCommand(SetDatabaseToDmsDelegate, BaseCommand.AlwaysPass);
            SetDatabaseToLocal = new BaseCommand(SetDatabaseToLocalDelegate, BaseCommand.AlwaysPass);
            SetBaselineToDatabase = new BaseCommand(SetBaselineToDatabaseDelegate, BaseCommand.AlwaysPass);
            SetBaselineToDataset = new BaseCommand(SetBaselineToDatasetDelegate, BaseCommand.AlwaysPass);
            FindLocalDatabase = new BrowseOpenFileCommand(x =>
            {
                DatabaseFilePath = x;
                IsDatabaseLocal = true;
                OnPropertyChanged("RequiresDatabaseSelection");
            }, filter);
            FindDmsDatabase = new BaseCommand(FindDmsDatabaseDelegate, BaseCommand.AlwaysPass);
            ClearDatabase = new BaseCommand(ClearDatabaseDelegate, BaseCommand.AlwaysPass);
            Datasets = new ObservableCollection<DatasetInformationViewModel>();
            UpdateDatasets();

            StacOptionsViewModel = new StacOptionsViewModel(analysis.Options.StacOptions);
            MassTagDatabaseOptionsViewModel =
                new MassTagDatabaseOptionsViewModel(analysis.Options.MassTagDatabaseOptions);
        }
示例#4
0
        public MainViewModel()
        {
            // Create the state moderation (between views)
            BuildStateModerator();

            MainDataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            MainDataName = "analysis";

            // Titles and Status
            var version = ApplicationUtility.GetEntryAssemblyData();
            Title = version;

            // Command Setup
            ShowAnalysisCommand = new BaseCommand(ShowAnalysis, BaseCommand.AlwaysPass);
            ShowStartCommand = new BaseCommand(ShowStart, BaseCommand.AlwaysPass);

            // View Models

            var workSpacePath = ApplicationUtility.GetApplicationDataFolderPath("MultiAlign");
            workSpacePath = Path.Combine(workSpacePath, Settings.Default.WorkspaceFile);
            GettingStartedViewModel = new GettingStartedViewModel(workSpacePath, StateModerator);

            GettingStartedViewModel.NewAnalysisStarted += GettingStartedViewModel_NewAnalysisStarted;
            GettingStartedViewModel.ExistingAnalysisSelected += GettingStartedViewModel_ExistingAnalysisSelected;

            AnalysisRunningViewModel = new AnalysisRunningViewModel();
            AnalysisRunningViewModel.AnalysisCancelled += AnalysisRunningViewModel_AnalysisCancelled;
            AnalysisRunningViewModel.AnalysisComplete += AnalysisRunningViewModel_AnalysisComplete;

            LoadingAnalysisViewModel = new AnalysisLoadingViewModel();
            LoadingAnalysisViewModel.AnalysisLoaded += LoadingAnalysisViewModel_AnalysisLoaded;

            ApplicationStatusMediator.SetStatus("Ready.");
        }
        public DatasetResolveCollectionViewModel(IEnumerable<DatasetResolveMatchViewModel> matches)
        {
            Datasets = new ObservableCollection<DatasetResolveMatchViewModel>(matches);

            CheckAllCommand = new BaseCommand(CheckAll, BaseCommand.AlwaysPass);
            UncheckAllCommand = new BaseCommand(UncheckAll, BaseCommand.AlwaysPass);
        }
        public AnalysisDatasetSelectionViewModel(MultiAlignAnalysis analysis)
        {
            m_inputFileFilter = "Input Files (*.txt)| *.txt| All Files (*.*)|*.*";
            m_featureFileFilter = DatasetFilterFactory.BuildFileFilters(InputFileType.Features);
            m_openFileDialog = new OpenFileDialog {Filter = m_inputFileFilter};
            m_analysis = analysis;
            ShouldSearchSubDirectories = SearchOption.TopDirectoryOnly;

            // Create The Dataset View Model for Binding
            Datasets = new ObservableCollection<DatasetInformationViewModel>();
            foreach (var information in analysis.MetaData.Datasets)
            {
                var info = new DatasetInformationViewModel(information);
                info.Selected += info_Selected;
                Datasets.Add(info);
            }

            // Route the events here...
            AddFolderCommand = new BaseCommand(AddFolderDelegate, BaseCommand.AlwaysPass);
            AddInputFileCommand = new BaseCommand(AddInputFileDelegate, BaseCommand.AlwaysPass);
            AddSingleFileCommand = new BaseCommand(AddSingleFileDelegate, BaseCommand.AlwaysPass);

            BrowseSingleFileCommand = new BaseCommand(BrowseSingleFile, BaseCommand.AlwaysPass);
            BrowseInputFileCommand = new BaseCommand(BrowseInput, BaseCommand.AlwaysPass);
            BrowseDataFolderCommand = new BrowseFolderCommand(x => { DataFolderPath = x; });

            RemoveSelectedCommand = new BaseCommand(RemoveSelected, BaseCommand.AlwaysPass);
            SelectAllCommand = new BaseCommand(SelectAllDelegate, BaseCommand.AlwaysPass);
            SelectNoneCommand = new BaseCommand(SelectNoneDelegate, BaseCommand.AlwaysPass);

            SelectedDatasets = new ObservableCollection<DatasetInformationViewModel>();
        }
 public AnalysisRunningViewModel()
 {
     Messages = new ObservableCollection<StatusEventArgs>();
     GalleryImages = new ObservableCollection<UserControl>();
     Reporter = new AnalysisReportGenerator();
     AnalysisNodes = new ObservableCollection<AnalysisGraphNodeViewModel>();
     CancelAnalysis = new BaseCommand(CancelAnalysisDelegate, BaseCommand.AlwaysPass);
     RouteMessages();
 }
        public UmcClusterCollectionTreeViewModel(List<UMCClusterLightMatched> clusters, UMCClusterTreeViewModel parent)
        {
            m_clusters = clusters;
            m_filteredClusters = new ObservableCollection<UMCClusterTreeViewModel>(
                (from cluster in clusters
                    select new UMCClusterTreeViewModel(cluster)).ToList());

            m_exportCommand = new BaseCommand(ShowFilterWindow);
            m_filterViewModel = new UMCClusterFilterViewModel(Clusters);
            FilterCommand = new BaseCommand(FilterWindow, BaseCommand.AlwaysPass);

            RegisterEvents();
        }
        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);
        }
        public AnalysisOptionsViewModel(MultiAlignAnalysisOptions options)
        {
            m_options = options;
            ClusteringAlgorithms = new ObservableCollection<LcmsFeatureClusteringAlgorithmType>();
            AlignmentAlgorithms = new ObservableCollection<FeatureAlignmentType>();
            FeatureFindingAlgorithms = new ObservableCollection<FeatureFinderType>();

            UpdateOptions();

            InstrumentPresets = new ObservableCollection<InstrumentPresetViewModel>();
            ExperimentPresets = new ObservableCollection<ExperimentPresetViewModel>();
            TimeOptions = new ObservableCollection<string>();

            var presets = new Dictionary<string, bool>();
            foreach (var preset in ExperimentPresetFactory.Create())
            {
                ExperimentPresets.Add(preset);

                if (!presets.ContainsKey(preset.InstrumentPreset.Name))
                {
                    presets.Add(preset.InstrumentPreset.Name, false);
                    InstrumentPresets.Add(preset.InstrumentPreset);
                }
            }

            foreach (var preset in InstrumentPresetFactory.Create())
            {
                if (!presets.ContainsKey(preset.Name))
                {
                    InstrumentPresets.Add(preset);
                }
            }
            TimeOptions.Add("Minutes");
            TimeOptions.Add("Scans");

            SelectedPreset = InstrumentPresets[0];
            SelectedExperimentPreset = ExperimentPresets[0];
            TreatAsTimeOrScan = TimeOptions[0];

            m_saveDialog = new SaveFileDialog();
            m_dialog = new OpenFileDialog
            {
                Filter = Resources.MultiAlignParameterFileFilter
            };
            m_saveDialog.Filter = Resources.MultiAlignParameterFileFilter;

            ShowAdvancedWindowCommand = new BaseCommand(ShowAdvancedWindow);
            SaveOptionsCommand = new BaseCommand(SaveCurrentParameters);
            LoadExistingCommand = new BaseCommand(LoadExistingParameters);

            Enum.GetValues(typeof (LcmsFeatureClusteringAlgorithmType))
                .Cast<LcmsFeatureClusteringAlgorithmType>()
                .ToList()
                .ForEach(x => ClusteringAlgorithms.Add(x));
            Enum.GetValues(typeof (FeatureAlignmentType))
                .Cast<FeatureAlignmentType>()
                .ToList()
                .ForEach(x => AlignmentAlgorithms.Add(x));
            Enum.GetValues(typeof (FeatureFinderType))
                .Cast<FeatureFinderType>()
                .ToList()
                .ForEach(x => FeatureFindingAlgorithms.Add(x));
        }
示例#11
0
        public AnalysisViewModel(MultiAlignAnalysis analysis)
        {
            m_showDriftTime = false;

            LoadDatasets(analysis);

            // Create matching clusters and AMT Matches.
            var matches = analysis.DataProviders.MassTagMatches.FindAll();
            var clusters =
                analysis.Clusters.MapMassTagsToClusters(matches, analysis.MassTagDatabase);

            // Cache the clusters so that they can be readily accessible later on.
            // This will help speed up performance, so that we dont have to hit the database
            // when we want to find matching mass tags, and dont have to map clusters to tags multiple times.
            FeatureCacheManager<UMCClusterLightMatched>.SetFeatures(clusters.Item1);
            FeatureCacheManager<MassTagToCluster>.SetFeatures(clusters.Item2);
            SingletonDataProviders.Providers = analysis.DataProviders;

            // Create sub-view models
            MassTags = new ObservableCollection<MassTagToCluster>(clusters.Item2);
            ClusterTree = new UmcClusterCollectionTreeViewModel(clusters.Item1);
            ClusterSpectraViewModel = new UmcClusterSpectraViewModel();
            ClusterIdentificationViewModel = new UMCClusterIdentificationViewModel();
            AnalysisOptionsViewModel = new AnalysisOptionsViewModel(analysis.Options);
            ClusterViewModel = new ClusterDetailViewModel();

            var charges = SingletonDataProviders.Providers.FeatureCache.RetrieveChargeStates();

            GlobalStatisticsViewModel = new GlobalStatisticsViewModel(clusters.Item1, charges);
            HasIdentifications = (MassTags.Count > 0);

            SelectedClusterName = "Cluster Details:";
            LoadClusters(clusters.Item1);
            ApplyViewAsFilter = new BaseCommand(FilterFromView);
        }
示例#12
0
        private void CreateCommands()
        {
            Action removeRecentList = delegate
            {
                RecentAnalyses.Clear();
                SaveWorkSpace();
            };

            ClearRecentList = new BaseCommand(removeRecentList);

            var command = new LoadExistingAnalysisCommand();
            command.ExistingAnalysisSelected += command_ExistingAnalysisSelected;
            LoadExistingAnalysis = command;

            var startNew = new BaseCommand(startNew_StartNewAnalysis, BaseCommand.AlwaysPass);
            StartNewAnalysis = startNew;
        }