Exemplo n.º 1
0
        /// <summary>
        ///     Loads a current workspace.
        /// </summary>
        private void LoadWorkspace(string path)
        {
            if (path == null)
            {
                return;
            }

            if (File.Exists(path))
            {
                ApplicationStatusMediator.SetStatus("Loading workspace");
                var reader = new MultiAlignWorkspaceReader();
                try
                {
                    CurrentWorkspace = reader.Read(path);
                }
                catch
                {
                    ApplicationStatusMediator.SetStatus(string.Format("Could not load the default workspace: {0}"));
                }
            }
            else
            {
                CurrentWorkspace = new MultiAlignWorkspace();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Adds the  folder containing dataset specific elements
        /// </summary>
        public void AddFolderDelegate()
        {
            var supportedTypes = DatasetLoader.SupportedFileTypes;
            var extensions     = new List <string>();

            supportedTypes.ForEach(x => extensions.Add("*" + x.Extension));

            var option = ShouldSearchSubDirectories;

            if (DataFolderPath == null)
            {
                ApplicationStatusMediator.SetStatus("The directory specified does not exist.");
                return;
            }

            if (!Directory.Exists(DataFolderPath))
            {
                ApplicationStatusMediator.SetStatus("The directory specified does not exist.");
                return;
            }

            var datasetLoader = new DatasetLoader();
            var files         = datasetLoader.GetValidDatasets(DataFolderPath,
                                                               extensions,
                                                               option);

            AddDatasets(files);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Shows the new analysis setup
        /// </summary>
        private void ShowNewAnalysisSetup()
        {
            string message;
            var    canStart = StateModerator.CanPerformNewAnalysis(out message);

            Status = message;
            if (!canStart)
            {
                return;
            }

            ApplicationStatusMediator.SetStatus("Creating new analysis.");

            StateModerator.CurrentViewState     = ViewState.SetupAnalysisView;
            StateModerator.CurrentAnalysisState = AnalysisState.Setup;

            var config = new AnalysisConfig
            {
                Analysis     = new MultiAlignAnalysis(),
                AnalysisPath = MainDataDirectory,
                AnalysisName = MainDataName
            };

            config.Analysis.AnalysisType = AnalysisType.Full;
            config.Analysis.Options.AlignmentOptions.IsAlignmentBaselineAMasstagDB = false;

            AnalysisSetupViewModel = new AnalysisSetupViewModel(config);
            AnalysisSetupViewModel.AnalysisQuit  += AnalysisSetupViewModel_AnalysisQuit;
            AnalysisSetupViewModel.AnalysisStart += AnalysisSetupViewModel_AnalysisStart;
            AnalysisSetupViewModel.CurrentStep    = AnalysisSetupStep.DatasetSelection;
        }
Exemplo n.º 4
0
 private void OnStatus(string message)
 {
     ThreadSafeDispatcher.Invoke(() =>
     {
         ApplicationStatusMediator.SetStatus(message);
         Status = message;
     });
 }
Exemplo n.º 5
0
        /// <summary>
        ///     Adds datasets from a single file
        /// </summary>
        private void AddSingleFileDelegate()
        {
            var fileExists = File.Exists(SingleFilePath);

            if (fileExists)
            {
                var datasetLoader = new DatasetLoader();
                AddDatasets(datasetLoader.GetValidDatasets(new List <string> {
                    SingleFilePath
                }));
            }
            else
            {
                ApplicationStatusMediator.SetStatus("The input file does not exist.");
            }
        }
Exemplo n.º 6
0
        public void MoveNext()
        {
            // Validate the move
            var errorMessage = "";
            var isValid      = MultiAlignAnalysisValidator.IsStepValid(AnalysisConfiguration, CurrentStep, ref errorMessage);

            // Then display the error if exists...
            if (!isValid)
            {
                ApplicationStatusMediator.SetStatus(errorMessage);
                return;
            }
            ApplicationStatusMediator.SetStatus(errorMessage);

            // Then move the UI.
            switch (CurrentStep)
            {
            case AnalysisSetupStep.DatasetSelection:
                CurrentStep = AnalysisSetupStep.OptionsSelection;
                break;

            case AnalysisSetupStep.OptionsSelection:
                BaselineSelectionViewModel.UpdateDatasets();
                CurrentStep = AnalysisSetupStep.BaselineSelection;
                break;

            case AnalysisSetupStep.BaselineSelection:
                CurrentStep = AnalysisSetupStep.Naming;
                break;

            case AnalysisSetupStep.Naming:
                CurrentStep = AnalysisSetupStep.Started;
                if (AnalysisStart != null)
                {
                    AnalysisConfiguration.ParameterFile = AnalysisConfiguration.AnalysisName + ".xml";
                    AnalysisStart(this, null);
                }
                break;

            case AnalysisSetupStep.Started:
                break;

            default:
                break;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Adds a MultiAlign file
        /// </summary>
        private void AddInputFileDelegate()
        {
            var fileExists = File.Exists(InputFilePath);

            if (fileExists)
            {
                // Read input files
                try
                {
                    var datasetLoader = new DatasetLoader();
                    var info          = MultiAlignFileInputReader.ReadInputFile(InputFilePath);
                    AddDatasets(datasetLoader.GetValidDatasets(info.Files, false));
                }
                catch
                {
                    ApplicationStatusMediator.SetStatus("Could not read the input file.  Check the file format.");
                }
            }
            else
            {
                ApplicationStatusMediator.SetStatus("The input file does not exist.");
            }
        }
Exemplo n.º 8
0
        private void AnalysisEnded(string reason, bool isCancelled, bool isComplete)
        {
            Action workAction = delegate
            {
                IsAnalysisRunning = false;
                ApplicationStatusMediator.SetStatus(reason);

                Controller.AnalysisComplete  -= Controller_AnalysisComplete;
                Controller.AnalysisError     -= Controller_AnalysisError;
                Controller.AnalysisCancelled -= Controller_AnalysisCancelled;

                if (isComplete)
                {
                    if (AnalysisComplete != null)
                    {
                        AnalysisComplete(this, new AnalysisStatusArgs(m_configuration));
                    }
                    return;
                }
                if (!isCancelled)
                {
                    if (AnalysisComplete != null)
                    {
                        AnalysisComplete(this, new AnalysisStatusArgs(m_configuration));
                    }
                }
                else
                {
                    if (AnalysisCancelled != null)
                    {
                        AnalysisCancelled(this, new AnalysisStatusArgs(m_configuration));
                    }
                }
            };

            ThreadSafeDispatcher.Invoke(workAction);
        }
Exemplo n.º 9
0
        public MainViewModel()
        {
            // Create the state moderation (between views)
            BuildStateModerator();

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


            // 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.");
        }