コード例 #1
0
ファイル: TestHelper.cs プロジェクト: pol/MassSpecStudio
        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
ファイル: ExperimentBase.cs プロジェクト: pol/MassSpecStudio
 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));
     }
 }
コード例 #5
0
        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
ファイル: DocumentManager.cs プロジェクト: pol/MassSpecStudio
 public void CloseProject()
 {
     _projectFile = null;
     Experiments.Clear();
     Save.RaiseCanExecuteChanged();
 }
コード例 #12
0
ファイル: DocumentManager.cs プロジェクト: pol/MassSpecStudio
        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
ファイル: DocumentManager.cs プロジェクト: pol/MassSpecStudio
        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);
 }
コード例 #17
0
 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
ファイル: Experiment.cs プロジェクト: pol/MassSpecStudio
 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
ファイル: Experiment.cs プロジェクト: pol/MassSpecStudio
        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;
 }