Example #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;
        }
Example #2
0
        public DeuterationResult(Peptide peptide, ProteinState proteinState, Labeling labeling, IList<RunResult> replicateResults)
        {
            _peptide = peptide;
            _proteinState = proteinState;
            _labeling = labeling;
            _replicateResults = replicateResults;

            DeuterationValues = new List<double>();
            DeuterationDistributedDeuterationValues = new List<double>();
            CentroidMassValues = new List<double>();

            NValue = 0;
            foreach (RunResult replicate in _replicateResults)
            {
                if (replicate != null)
                {
                    this.TheoreticalCentroidMass = replicate.TheoreticalAverageMass;

                    if (replicate.IsUsedInCalculations)
                    {
                        DeuterationValues.Add(replicate.AmountDeut);
                        DeuterationDistributedDeuterationValues.Add(replicate.AmountDeutFromDeutDist);
                        CentroidMassValues.Add(replicate.AverageMass);
                        NValue++;
                    }
                }
            }
        }
        private static DeuterationResult GenerateDeuterationResult(Peptide peptide, ProteinState proteinState, Labeling labeling, Experiment experiment, Result result)
        {
            List<RunResult> replicates = new List<RunResult>();

            foreach (Run run in experiment.GetRunsByProteinState(proteinState))
            {
                if (run.Labeling == labeling)
                {
                    RunResult runResult = experiment.GetRunResult(result, run, peptide);
                    if (runResult != null)
                    {
                        replicates.Add(runResult);
                    }
                }
            }

            DeuterationResult deuterationResult = new DeuterationResult(peptide, proteinState, labeling, replicates);
            deuterationResult.AmountDeut = Math.Round(MathUtility.GetAverage(deuterationResult.DeuterationValues), 5);
            deuterationResult.AmountDeuterationStandardDeviation = Math.Round(MathUtility.GetStandardDeviation(deuterationResult.DeuterationValues), 5);
            deuterationResult.AmountDeuterationFromDeuterationDistribution = Math.Round(MathUtility.GetAverage(deuterationResult.DeuterationDistributedDeuterationValues), 5);
            deuterationResult.AmountDeuterationFromDeuterationDistributionStandardDeviation = Math.Round(MathUtility.GetStandardDeviation(deuterationResult.DeuterationDistributedDeuterationValues), 5);
            deuterationResult.CentroidMass = Math.Round(MathUtility.GetAverage(deuterationResult.CentroidMassValues), 5);
            deuterationResult.CentroidMassStandardDeviation = Math.Round(MathUtility.GetStandardDeviation(deuterationResult.CentroidMassValues), 5);
            if (replicates.Count > 0)
            {
                deuterationResult.TheoreticalCentroidMass = Math.Round(replicates.Average(item => item.TheoreticalAverageMass), 5);
            }

            return deuterationResult;
        }
Example #4
0
 public Run(string filename, string fullPath, ProteinState proteinState, Labeling labeling, Experiment experiment, IDataProvider dataProvider)
     : base(filename, fullPath, dataProvider)
 {
     ProteinState = proteinState;
     Labeling = labeling;
     Experiment = experiment;
     experiment.Runs.Add(this);
 }
Example #5
0
        public void NotEqualOperator()
        {
            ProteinState proteinState2 = new ProteinState(experiment);

            Assert.IsTrue(proteinState != proteinState2);
            proteinState2.Name = "Protein state 1";
            Assert.IsFalse(proteinState != proteinState2);
        }
Example #6
0
        public void Equals()
        {
            ProteinState proteinState2 = new ProteinState(experiment);

            Assert.IsFalse(proteinState.Equals(proteinState2));
            proteinState2.Name = "Protein state 1";
            Assert.IsTrue(proteinState.Equals(proteinState2));
        }
        public ProteinStateDeuterationResult(IList<RunResult> replicates, ProteinState proteinState)
            : this()
        {
            _replicateResults = replicates;
            _proteinState = proteinState;

            foreach (RunResult rr in this.ReplicateResults)
            {
                if (rr != null)
                {
                    this.TheoreticalCentroidMass = rr.TheoreticalAverageMass;

                    if (rr.IsUsedInCalculations)
                    {
                        DeuterationValues.Add(rr.AmountDeut);
                        DeuterationDistributedDeuterationValues.Add(rr.AmountDeutFromDeutDist);
                        CentroidMassValues.Add(rr.AverageMass);
                    }
                }
            }

            this.NValue = DeuterationValues.Count;
        }
Example #8
0
 private static Hydra.Core.Domain.Run CreateRun(string filename, ProteinState proteinState, Labeling labeling, Experiment experiment, Mock<IEventAggregator> mockEventAggregator)
 {
     string runFileName = Path.GetFileName(filename);
     File.Copy(filename, Path.Combine(TestExperimentDirectory, "Data", runFileName), true);
     Hydra.Core.Domain.Run run = new Hydra.Core.Domain.Run(
         @"Data\" + runFileName,
         Path.Combine(TestExperimentDirectory, "Data", runFileName),
         proteinState,
         labeling,
         experiment,
         new ProteoWizardDataProvider(mockEventAggregator.Object));
     return run;
 }
        private Experiment CreateTestExperiment()
        {
            Experiment experiment = hydraExperimentType.CreateExperiment(project, TestExperimentName) as Experiment;
            ProteinState proteinState = new ProteinState(experiment);
            Labeling labeling = new Labeling(experiment);

            string runFileName = Path.GetFileName(Properties.Settings.Default.mzXMLTestFile1);
            File.Copy(Properties.Settings.Default.mzXMLTestFile1, Path.Combine(TestExperimentDirectory, "Data", runFileName), true);
            Run run = new Run(
                @"Data\" + runFileName,
                Path.Combine(TestExperimentDirectory, "Data", runFileName),
                proteinState,
                labeling,
                experiment,
                new ProteoWizardDataProvider(mockEventAggregator.Object));
            experiment.Save();
            return experiment as Experiment;
        }
Example #10
0
 public IList<Run> GetRunsByProteinState(ProteinState proteinState)
 {
     return (from data in Runs
             where data.ProteinState == proteinState
             select data).ToList();
 }
Example #11
0
 public void TestInitialize()
 {
     mockServiceLocator = new Mock<IServiceLocator>();
     experiment = TestHelper.GetTestExperiment(mockServiceLocator);
     proteinState = new ProteinState(experiment);
 }
Example #12
0
 public void GetNextName()
 {
     Assert.AreEqual("Protein state 1", proteinState.Name);
     ProteinState proteinState2 = new ProteinState(experiment);
     Assert.AreEqual("Protein state 2", proteinState2.Name);
 }
Example #13
0
        public void Save()
        {
            OpenExperiment();
            Assert.AreEqual(2, experiment.ProteinStates.Count);

            ProteinState proteinState = new ProteinState(experiment);
            experiment.Save();

            OpenExperiment();
            Assert.AreEqual(3, experiment.ProteinStates.Count);
            experiment.ProteinStates.Remove(experiment.ProteinStates[2]);
            experiment.Save();
        }