Beispiel #1
0
 private void UpdateProject()
 {
     try
     {
         this.Analysis.DataProviders.DatabaseLock.EnterWriteLock();
         this.Analysis.DataProviders.DatasetCache.UpdateAll(this.Datasets.Select(d => d.Dataset).ToList());
         this.Analysis.DataProviders.OptionsDao.AddAll(OptionsTransformer.PropertiesToList(this.Analysis.Options));
     }
     finally
     {
         this.Analysis.DataProviders.DatabaseLock.ExitWriteLock();
     }
 }
Beispiel #2
0
        private void PersistProject()
        {
            if (this.Analysis.DataProviders == null)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(this.projectDirectory))
            {
                this.projectDirectory = Path.GetDirectoryName(this.ProjectPath) + Path.DirectorySeparatorChar;
            }
            // Get the relative paths set up.
            foreach (var dataset in this.Datasets.Select(d => d.Dataset))
            {
                foreach (var file in dataset.InputFiles)
                {
                    file.RelativePath = PathUtils.MakeRelativePath(this.projectDirectory, file.Path);
                }
            }

            // Persist
            try
            {
                this.Analysis.DataProviders.DatabaseLock.EnterWriteLock();
                this.Analysis.DataProviders.DatasetCache.AddAll(this.Datasets.Select(d => d.Dataset).ToList());
                this.Analysis.DataProviders.DatasetCache.DeleteAll(this.deletedDatasets);
                // TODO: remove features and such from the database as well.
                this.deletedDatasets.Clear();
                this.Analysis.DataProviders.OptionsDao.AddAll(
                    OptionsTransformer.PropertiesToList(this.Analysis.Options));
            }
            finally
            {
                this.Analysis.DataProviders.DatabaseLock.ExitWriteLock();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Load a project
        /// </summary>
        /// <param name="isNewProject">If the project is a new one</param>
        /// <param name="datasets">Datasets to add to the project, if it is a new project.</param>
        /// <returns></returns>
        private async Task LoadRogueProject(bool isNewProject, List <DatasetInformation> datasets = null)
        {
            Directory.SetCurrentDirectory(this.outputDirectory);
            this.Analysis = new MultiAlignAnalysis
            {
                DataProviders = this.SetupDataProviders(this.ProjectPath, isNewProject),
            };

            var fileName = Path.GetFileNameWithoutExtension(this.projectPath);

            this.Analysis.AnalysisName = fileName;
            this.WindowTitle           = string.Format("MultiAlign Rogue ({0})", fileName);

            this.deletedDatasets.Clear();
            var dbOptions = this.Analysis.DataProviders.OptionsDao.FindAll();

            this.Analysis.Options = OptionsTransformer.ListToProperties(dbOptions);

            if (datasets != null)
            {
                this.analysis.MetaData.Datasets.AddRange(datasets);
            }

            //Prevent updates of ViewModels (that we will recreate anyway) while loading datasets
            this.clusterViewFactory              = null;
            this.DataLoadingSettingsViewModel    = null;
            this.FeatureFindingSettingsViewModel = null;
            this.AlignmentSettingsViewModel      = null;
            this.StacSettingsViewModel           = null;

            var dbDatasets = this.Analysis.DataProviders.DatasetCache.FindAll();

            // Resolve the relative paths
            if (!string.IsNullOrWhiteSpace(this.projectDirectory))
            {
                foreach (var dataset in dbDatasets)
                {
                    foreach (var file in dataset.InputFiles)
                    {
                        if (!string.IsNullOrWhiteSpace(file.RelativePath))
                        {
                            var combined = Path.Combine(this.projectDirectory, file.RelativePath);
                            var cleaned  = Path.GetFullPath(combined);
                            if (File.Exists(cleaned))
                            {
                                file.Path = cleaned;
                            }
                        }
                        // TODO: show warning if file cannot be found.
                        // TODO: OR disable redo of step that needs specified file, if file is only needed for e.g. feature finding
                    }
                }
            }
            this.Analysis.MetaData.Datasets.AddRange(dbDatasets);

            this.Analysis.MetaData.BaselineDataset = this.Analysis.MetaData.Datasets.FirstOrDefault(ds => ds.IsBaseline);

            this.analysisConfig.AnalysisPath = this.ProjectPath;
            await this.UpdateDatasets();

            this.clusterViewFactory = new ClusterViewFactory(this.Analysis.DataProviders);

            this.DataLoadingSettingsViewModel            = new DataLoadingSettingsViewModel(this.Analysis);
            this.FeatureFindingSettingsViewModel         = new FeatureFindingSettingsViewModel(this.Analysis, this.Datasets);
            this.AlignmentSettingsViewModel              = new AlignmentSettingsViewModel(this.Analysis, this.Datasets);
            this.StacSettingsViewModel                   = new StacSettingsViewModel(this.Analysis, this.Datasets);
            DatabaseSelectionViewModel.Instance.Analysis = this.Analysis;
            if (this.Analysis.Options.AlignmentOptions.InputDatabase != null)
            {
                await DatabaseSelectionViewModel.Instance.LoadMassTagDatabase(this.Analysis.Options.AlignmentOptions.InputDatabase);
            }

            this.ClusterSettingsViewModel = new ClusterSettingsViewModel(this.Analysis, this.Datasets, this.clusterViewFactory);
        }