Пример #1
0
        public static ProjectBase CreateTestProject()
        {
            DeleteProjectDirectory();

            Mock<IEventAggregator> mockEventAggregator = new Mock<IEventAggregator>();
            Mock<IServiceLocator> mockServiceLocator = new Mock<IServiceLocator>();
            mockServiceLocator.Setup(mock => mock.GetAllInstances<IDataProvider>()).Returns(new List<IDataProvider>() { new ProteoWizardDataProvider(mockEventAggregator.Object) });
            ProjectBase project = new ProjectBase("temp", @"c:\");
            HydraExperimentType hydraExperimentType = new HydraExperimentType(mockServiceLocator.Object);
            Experiment experiment = hydraExperimentType.CreateExperiment(project, "testExperiment") as Experiment;
            ProteinState proteinState1 = new ProteinState(experiment);
            ProteinState proteinState2 = new ProteinState(experiment);
            Labeling labeling1 = new Labeling(experiment);
            Labeling labeling2 = new Labeling(experiment);

            CreateRun(Properties.Settings.Default.mzXMLTestFile1, proteinState1, labeling1, experiment, mockEventAggregator);
            CreateRun(Properties.Settings.Default.mzXMLTestFile2, proteinState1, labeling1, experiment, mockEventAggregator);
            CreateRun(Properties.Settings.Default.mzXMLTestFile2, proteinState1, labeling2, experiment, mockEventAggregator);
            CreateRun(Properties.Settings.Default.mzXMLTestFile2, proteinState2, labeling1, experiment, mockEventAggregator);

            experiment.Peptides.PeptideCollection.Add(CreatePeptide("SAMPLE", 1));
            experiment.Peptides.PeptideCollection.Add(CreatePeptide("SAMPLES", 20));

            experiment.Save();
            project.Experiments.Add(experiment);
            return project;
        }
Пример #2
0
 public ExperimentBase(string name, ProjectBase project, IExperimentType experimentTypeObject)
 {
     Name = name;
     ExperimentTypeObject = experimentTypeObject;
     ExperimentType = experimentTypeObject.ExperimentType;
     this.project = project;
 }
Пример #3
0
 public void TestInitialize()
 {
     mockServiceLocator = new Mock<IServiceLocator>();
     project = TestHelper.CreateTestProject();
     experiment = project.Experiments.First() as Experiment;
     viewModel = new PeptidesViewModel(project.Experiments.First() as Experiment, mockServiceLocator.Object);
     Assert.AreEqual(2, viewModel.Children.Count);
 }
Пример #4
0
 public static void ConvertExperimentReferencesToExperiments(ProjectBase project, IServiceLocator serviceLocator)
 {
     project.Experiments.Clear();
     IEnumerable<IExperimentType> experimentTypes = serviceLocator.GetAllInstances<IExperimentType>();
     foreach (MassSpecStudio.Core.Domain.ProjectBase.ExperimentReference experimentReference in project.ExperimentReferences)
     {
         IExperimentType experimentType = experimentTypes.Where(item => item.ExperimentType == experimentReference.ExperimentType).FirstOrDefault();
         project.Experiments.Add(new Experiment(experimentReference.Name, project, experimentType));
     }
 }
        public void TestInitialize()
        {
            project = TestHelper.CreateTestProject();
            mockRegionManager = new Mock<IRegionManager>();
            eventAggregator = new EventAggregator();

            viewModel = new ProjectExplorerViewModel(mockRegionManager.Object, eventAggregator);
            projectViewModel = new ProjectViewModel(project);
            viewModel.Project.Add(projectViewModel);
        }
Пример #6
0
        public void OnLoadProject()
        {
            TestHelper.MockRegionManagerDisplay(Regions.LeftRegion.ToString(), typeof(ProjectExplorerView), mockServiceLocator, mockRegion, mockRegionManager);

            ProjectBase project = new ProjectBase("temp", @"c:\");
            project.Experiments.Add(new Experiment("testExperiment", project, new HydraExperimentType(mockServiceLocator.Object)));

            eventAggregator.GetEvent<LoadProjectDataEvent>().Subscribe(OnLoadProjectDataEvent);
            eventAggregator.GetEvent<LoadProjectEvent>().Publish(project);

            Assert.AreEqual(project, ((ProjectViewModel)DocumentCache.ProjectViewModel).Data as ProjectBase);
            Assert.AreEqual(project.Experiments.First(), DocumentCache.Experiment);
            Assert.IsTrue(loadProjectDataEventFired);
        }
Пример #7
0
 public ExperimentBase Open(string path, ProjectBase parentProject)
 {
     Experiment experiment = Experiment.Open(path, parentProject, ServiceLocator);
     foreach (Run run in experiment.Runs)
     {
         run.FullPath = Path.Combine(experiment.Directory, run.FileName);
         IDataProvider dataProvider = ServiceLocator.GetAllInstances<IDataProvider>().Where(item => item.TypeId == experiment.DataProviderType).FirstOrDefault();
         if (dataProvider == null)
         {
             throw new Exception("The data provider was not found for one or more runs in this experiment.");
         }
         run.SetDataProvider(dataProvider);
     }
     return experiment;
 }
Пример #8
0
        private void OnCreateProject(ProjectBase project)
        {
            CreateProjectHelper.ConvertExperimentReferencesToExperiments(project, _serviceLocator);

            Experiment experiment = project.Experiments.First() as Experiment;

            WizardShell wizard = new WizardShell(_regionManager, CreateProjectHelper.CreateController(experiment, _regionManager, _serviceLocator));
            wizard.ShowDialog();

            if (wizard.Finished)
            {
                ProgressDialog dialog = new ProgressDialog("Creating experiment");

                dialog.RunWorkerThread(project, DoCreateProjectAndExperimentWork);

                _documentManager.Open(project.Location);
            }
        }
Пример #9
0
        public void ClassInitialize()
        {
            mockServiceLocator = new Mock<IServiceLocator>();
            mockEventAggregator = new Mock<IEventAggregator>();
            hydraExperimentType = new HydraExperimentType(mockServiceLocator.Object);
            project = new ProjectBase("temp", @"C:\");

            try
            {
                if (Directory.Exists(TestExperimentDirectory))
                {
                    Directory.Delete(TestExperimentDirectory, true);
                }
            }
            catch
            {
                // Do Nothing
            }
        }
Пример #10
0
        public void TestInitialize()
        {
            eventAggregator = new EventAggregator();
            mockServiceLocator = new Mock<IServiceLocator>();
            mockServiceLocator.Setup(mock => mock.GetAllInstances<IExperimentType>()).Returns(new List<IExperimentType>() { new HydraExperimentType(mockServiceLocator.Object) });
            worker = new BackgroundWorker();
            worker.WorkerReportsProgress = true;
            project = new ProjectBase("temp", @"c:\");
            project.ExperimentReferences.Add(new MassSpecStudio.Core.Domain.ProjectBase.ExperimentReference(TestExperimentName, @"c:\temp\" + TestExperimentName + @"\" + TestExperimentName + ".mssexp", new HydraExperimentType(mockServiceLocator.Object).ExperimentType));

            helper = new CreateProjectHelper(worker, project);

            if (Directory.Exists(TestExperimentDirectory))
            {
                Directory.Delete(TestExperimentDirectory, true);
            }
        }
Пример #11
0
 public void CloseProject()
 {
     _projectFile = null;
     Experiments.Clear();
     Save.RaiseCanExecuteChanged();
 }
Пример #12
0
        public void Open(string path)
        {
            _projectFile = ProjectBase.Open(path);
            _eventAggregator.GetEvent<ProjectOpeningEvent>().Publish(null);

            _projectFile.Experiments.Clear();
            Experiments.Clear();
            foreach (MassSpecStudio.Core.Domain.ProjectBase.ExperimentReference experimentFile in _projectFile.ExperimentReferences)
            {
                ExperimentBase experiment = OpenExperiment(experimentFile, _projectFile);
                Experiments.Add(experiment);
                _projectFile.Experiments.Add(experiment);
            }

            _eventAggregator.GetEvent<LoadProjectEvent>().Publish(_projectFile);
            SaveRecentProjectList(path);
            Save.RaiseCanExecuteChanged();
        }
Пример #13
0
 private void OnLoadProject(ProjectBase project)
 {
     _regionManager.Display(Regions.LeftRegion.ToString(), typeof(Views.ProjectExplorerView), _serviceLocator);
     DocumentCache.ProjectViewModel = new ProjectViewModel(project);
     DocumentCache.Experiment = project.Experiments.First() as Experiment;
     _eventAggregator.GetEvent<LoadProjectDataEvent>().Publish(DocumentCache.ProjectViewModel);
 }
Пример #14
0
        private ExperimentBase OpenExperiment(MassSpecStudio.Core.Domain.ProjectBase.ExperimentReference experimentFile, ProjectBase project)
        {
            IExperimentType experimentType = _experimentTypes.Where(data => data.ExperimentType == experimentFile.ExperimentType).First();

            ExperimentBase experiment = experimentType.Open(Path.Combine(project.Directory, experimentFile.Location), project);
            experiment.ExperimentTypeObject = experimentType;
            return experiment;
        }
Пример #15
0
        public bool CreateProject()
        {
            if (IsCreateProjectValid())
            {
                Properties.Settings.Default.LastSelectedExperimentType = _selectedExperimentType.Name;
                AddToRecentLocationsList();
                Properties.Settings.Default.Save();

                ProjectBase project = new ProjectBase(ProjectName, Location);
                project.ExperimentReferences.Add(new ProjectBase.ExperimentReference(ExperimentName, DirectoryHelper.GetRelativePath(Path.Combine(Location, ProjectName, ExperimentName, ExperimentName + ".mssexp"), project.Directory), _selectedExperimentType.ExperimentType));

                _eventAggregator.GetEvent<CreateProjectEvent>().Publish(project);
                return true;
            }
            return false;
        }
Пример #16
0
 private void OnCreateProject(ProjectBase project)
 {
     createProjectFired = true;
     Assert.AreEqual("createTestProject", project.Name);
     Assert.AreEqual(@"C:\temp\createTestProject\createTestProject.mssproj", project.Location);
     Assert.AreEqual(1, project.ExperimentReferences.Count);
     Assert.AreEqual("testExperiment", project.ExperimentReferences[0].Name);
     Assert.AreEqual(@"testExperiment\testExperiment.mssexp", project.ExperimentReferences[0].Location);
 }
 public void TestInitialize()
 {
     project = TestHelper.CreateTestProject();
     viewModel = new ExperimentViewModel(project.Experiments.First() as Experiment);
     importPeptidesViewModel = new ImportPeptidesViewModel(viewModel);
 }
Пример #18
0
 public MassSpecStudio.Core.Domain.ExperimentBase CreateExperiment(ProjectBase project, string experimentName)
 {
     CreateExperimentDirectoryStructure(Path.Combine(project.Directory, experimentName));
     return CreateExperimentFile(project, experimentName);
 }
Пример #19
0
 public Experiment(string name, ProjectBase project, IExperimentType experimentType)
     : base(name, project, experimentType)
 {
     _peptideFileLocation = @"Data\Peptides.xml";
     _peptides = new Peptides(Path.Combine(Path.GetDirectoryName(Location), PeptidesFileLocation));
 }
Пример #20
0
        public static Experiment Open(string path, ProjectBase parentProject, IServiceLocator serviceLocator)
        {
            DataContractSerializer serializer = new DataContractSerializer(typeof(Experiment));
            using (XmlReader stream = XmlReader.Create(path))
            {
                Experiment experiment = serializer.ReadObject(stream, true) as Experiment;
                experiment.Project = parentProject;
                if (parentProject == null)
                {
                    string directory = Path.GetDirectoryName(path);
                    experiment.Peptides = Peptides.Open(Path.Combine(directory, experiment.PeptidesFileLocation));
                }
                else
                {
                    experiment.Peptides = Peptides.Open(Path.Combine(experiment.Directory, experiment.PeptidesFileLocation));
                }
                if (parentProject != null)
                {
                    experiment.Results = Result.OpenDirectory(experiment);
                }
                IDataProvider dataProvider = serviceLocator.GetAllInstances<IDataProvider>().Where(item => item.TypeId == experiment.DataProviderType).FirstOrDefault();
                if (dataProvider == null)
                {
                    throw new Exception("Data provider specified in this experiment was not found.");
                }

                experiment.DataProvider = dataProvider;
                foreach (Run run in experiment.Runs)
                {
                    run.Experiment = experiment;
                }
                return experiment;
            }
        }
Пример #21
0
 public void TestInitialize()
 {
     project = TestHelper.CreateTestProject();
     viewModel = new ProjectViewModel(project);
     samplesViewModel = viewModel.Children.First().Children.First() as SamplesViewModel;
     experiment = (Experiment)project.Experiments.First();
 }
Пример #22
0
        protected ExperimentBase CreateExperimentFile(ProjectBase project, string experimentName)
        {
            string experimentDirectory = Path.Combine(project.Directory, experimentName);
            Experiment experiment = new Experiment(experimentName, project, this);
            experiment.Save();

            return experiment;
        }
Пример #23
0
 public void TestInitialize()
 {
     project = TestHelper.CreateTestProject();
     viewModel = new RunViewModel(((Experiment)project.Experiments.First()).Runs.First());
 }
Пример #24
0
 public CreateProjectHelper(BackgroundWorker worker, ProjectBase project)
 {
     this.worker = worker;
     this.project = project;
 }