コード例 #1
0
        public void CompareAveragingWithMSstats()
        {
            var srmDocument       = LoadRatPlasmaDocument();
            var documentContainer = new MemoryDocumentContainer();

            documentContainer.SetDocument(documentContainer.Document, srmDocument);
            GroupComparisonModel model = new GroupComparisonModel(documentContainer, null);

            model.GroupComparisonDef = GroupComparisonDef.EMPTY.ChangeControlAnnotation("Condition")
                                       .ChangeControlValue("Healthy")
                                       .ChangeIdentityAnnotation("BioReplicate")
                                       .ChangeSummarizationMethod(SummarizationMethod.AVERAGING)
                                       .ChangePerProtein(false);
            var expectedValues = MsStatsTestUtil.ReadExpectedResults(typeof(MSstatsAveragingTest),
                                                                     "RatPlasmaTestingResult.csv");
            var groupComparer = new GroupComparer(model.GroupComparisonDef, srmDocument, new QrFactorizationCache());

            foreach (var protein in srmDocument.PeptideGroups)
            {
                foreach (var peptide in protein.Peptides)
                {
                    var result         = groupComparer.CalculateFoldChange(new GroupComparisonSelector(protein, peptide, IsotopeLabelType.light, null, new GroupIdentifier("Diseased")), null);
                    var expectedResult = expectedValues[peptide.Peptide.Sequence];
                    Assert.AreEqual(expectedResult.EstimatedValue, result.LinearFitResult.EstimatedValue,
                                    (expectedResult.StandardError + result.LinearFitResult.StandardError) * 2, peptide.Peptide.Sequence);
                }
            }
        }
コード例 #2
0
ファイル: SkylineDataSchema.cs プロジェクト: joey10086/pwiz
        public static SkylineDataSchema MemoryDataSchema(SrmDocument document, DataSchemaLocalizer localizer)
        {
            var documentContainer = new MemoryDocumentContainer();

            documentContainer.SetDocument(document, documentContainer.Document);
            return(new SkylineDataSchema(documentContainer, localizer));
        }
コード例 #3
0
        public void TestAllColumnToolTipsAreLocalized()
        {
            var documentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(documentContainer.SetDocument(new SrmDocument(SrmSettingsList.GetDefault()), documentContainer.Document));
            SkylineDataSchema skylineDataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var missingCaptions = new HashSet <ColumnCaption>();

            foreach (var columnDescriptor in
                     EnumerateAllColumnDescriptors(skylineDataSchema, STARTING_TYPES))
            {
                var invariantDescription = skylineDataSchema.GetColumnDescription(columnDescriptor);
                if (string.IsNullOrEmpty(invariantDescription))
                {
                    var invariantCaption = skylineDataSchema.GetColumnCaption(columnDescriptor) as ColumnCaption;
                    if (invariantCaption != null)
                    {
                        missingCaptions.Add(invariantCaption);
                    }
                }
            }
            if (missingCaptions.Count == 0)
            {
                return;
            }
            StringWriter message = new StringWriter();

            WriteResXFile(message, missingCaptions);
            Assert.Fail("Missing localized tooltips for column captions: {0}", message.ToString().Replace("<data", "\r\n<data"));
        }
コード例 #4
0
        /// <summary>
        ///  A helper function that generates the report with reportTitle from the SrmDocument.
        ///  Throws an error if the reportSpec no longer exists in Settings.Default.
        /// </summary>
        /// <param name="doc">Document to create the report from.</param>
        /// <param name="reportTitle">Title of the reportSpec to make a report from.</param>
        /// <param name="toolTitle">Title of tool for exception error message.</param>
        /// <param name="progressMonitor">Progress monitor.</param>
        /// <param name="writer">TextWriter that the report should be written to.</param>
        /// <returns> Returns a string representation of the ReportTitle report, or throws an error that the reportSpec no longer exist. </returns>
        public static void GetReport(SrmDocument doc, string reportTitle, string toolTitle, IProgressMonitor progressMonitor, TextWriter writer)
        {
            var container = new MemoryDocumentContainer();

            container.SetDocument(doc, container.Document);
            var      dataSchema  = new SkylineDataSchema(container, DataSchemaLocalizer.INVARIANT);
            var      viewContext = new DocumentGridViewContext(dataSchema);
            ViewInfo viewInfo    = viewContext.GetViewInfo(PersistedViews.ExternalToolsGroup.Id.ViewName(reportTitle));

            if (null == viewInfo)
            {
                throw new ToolExecutionException(
                          string.Format(
                              Resources.ToolDescriptionHelpers_GetReport_Error_0_requires_a_report_titled_1_which_no_longer_exists__Please_select_a_new_report_or_import_the_report_format,
                              toolTitle, reportTitle));
            }
            IProgressStatus status =
                new ProgressStatus(string.Format(Resources.ReportSpec_ReportToCsvString_Exporting__0__report,
                                                 reportTitle));

            progressMonitor.UpdateProgress(status);
            if (!viewContext.Export(CancellationToken.None, progressMonitor, ref status, viewInfo, writer,
                                    viewContext.GetCsvWriter()))
            {
                throw new OperationCanceledException();
            }
        }
コード例 #5
0
        public SkylineDataSchema Clone()
        {
            var container = new MemoryDocumentContainer();

            container.SetDocument(Document, container.Document);
            return(new SkylineDataSchema(container, DataSchemaLocalizer));
        }
コード例 #6
0
        public void TestCheckForUnusedColumnCaptions()
        {
            var documentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(documentContainer.SetDocument(new SrmDocument(SrmSettingsList.GetDefault()), documentContainer.Document));
            SkylineDataSchema dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);
            var columnCaptions           = new HashSet <string>();

            foreach (
                var resourceManager in SkylineDataSchema.GetLocalizedSchemaLocalizer().ColumnCaptionResourceManagers)
            {
                var resourceSet = resourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, true);
                var enumerator  = resourceSet.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    string key = enumerator.Key as string;
                    if (null != key)
                    {
                        columnCaptions.Add(key);
                    }
                }
            }
            foreach (var columnDescriptor in EnumerateAllColumnDescriptors(dataSchema, STARTING_TYPES)
                     )
            {
                var invariantCaption = dataSchema.GetColumnCaption(columnDescriptor);
                columnCaptions.Remove(invariantCaption.InvariantCaption);
            }
            var unusedCaptions = columnCaptions.ToArray();

            Assert.AreEqual(0, unusedCaptions.Length, "Unused entries found in ColumnCaptions.resx: {0}", string.Join(",", unusedCaptions));
        }
コード例 #7
0
        public void TestGenerateResxFile()
        {
            var documentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(documentContainer.SetDocument(new SrmDocument(SrmSettingsList.GetDefault()), documentContainer.Document));
            GenerateResXFile(new StringWriter() /* Console.Out */, new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT), STARTING_TYPES);
        }
コード例 #8
0
        public CheckReportCompatibility(SrmDocument document)
        {
            IDocumentContainer documentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(documentContainer.SetDocument(document, null));
            _dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);
        }
コード例 #9
0
        /// <summary>
        ///  A helper function that generates the report with reportTitle from the SrmDocument.
        ///  Throws an error if the reportSpec no longer exists in Settings.Default.
        /// </summary>
        /// <param name="doc">Document to create the report from.</param>
        /// <param name="reportTitle">Title of the reportSpec to make a report from.</param>
        /// <param name="toolTitle">Title of tool for exception error message.</param>
        /// <param name="progressMonitor">Progress monitor.</param>
        /// <returns> Returns a string representation of the ReportTitle report, or throws an error that the reportSpec no longer exist. </returns>
        public static string GetReport(SrmDocument doc, string reportTitle, string toolTitle, IProgressMonitor progressMonitor)
        {
            var container = new MemoryDocumentContainer();

            container.SetDocument(doc, container.Document);
            var      dataSchema  = new SkylineDataSchema(container, DataSchemaLocalizer.INVARIANT);
            var      viewContext = new DocumentGridViewContext(dataSchema);
            ViewInfo viewInfo    = viewContext.GetViewInfo(PersistedViews.ExternalToolsGroup.Id.ViewName(reportTitle));

            if (null == viewInfo)
            {
                throw new ToolExecutionException(
                          string.Format(
                              Resources.ToolDescriptionHelpers_GetReport_Error_0_requires_a_report_titled_1_which_no_longer_exists__Please_select_a_new_report_or_import_the_report_format,
                              toolTitle, reportTitle));
            }
            var status =
                new ProgressStatus(string.Format(Resources.ReportSpec_ReportToCsvString_Exporting__0__report,
                                                 reportTitle));
            var writer = new StringWriter();

            if (viewContext.Export(progressMonitor, ref status, viewInfo, writer,
                                   new DsvWriter(CultureInfo.InvariantCulture, TextUtil.SEPARATOR_CSV)))
            {
                return(writer.ToString());
            }
            return(null);
        }
コード例 #10
0
        private MemoryDocumentContainer CreateMemoryDocumentContainer(SrmDocument document)
        {
            MemoryDocumentContainer memoryDocumentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(memoryDocumentContainer.SetDocument(document, memoryDocumentContainer.Document));
            return(memoryDocumentContainer);
        }
コード例 #11
0
        public void TestAllColumnCaptionsAreLocalized()
        {
            var documentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(documentContainer.SetDocument(new SrmDocument(SrmSettingsList.GetDefault()), documentContainer.Document));
            SkylineDataSchema skylineDataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var missingCaptions = new HashSet <ColumnCaption>();

            foreach (var columnDescriptor in
                     EnumerateAllColumnDescriptors(skylineDataSchema, STARTING_TYPES))
            {
                var invariantCaption = skylineDataSchema.GetColumnCaption(columnDescriptor);
                if (!skylineDataSchema.DataSchemaLocalizer.HasEntry(invariantCaption))
                {
                    missingCaptions.Add(invariantCaption);
                }
            }
            if (missingCaptions.Count == 0)
            {
                return;
            }
            StringWriter message = new StringWriter();

            WriteResXFile(message, missingCaptions);
            Assert.Fail("Missing localized column captions {0}", message);
        }
コード例 #12
0
        public void TestProteinAbundance()
        {
            var srmDocument       = LoadRatPlasmaDocument();
            var documentContainer = new MemoryDocumentContainer();

            documentContainer.SetDocument(srmDocument, documentContainer.Document);
            var skylineDataSchema      = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);
            GroupComparisonModel model = new GroupComparisonModel(documentContainer, null);

            model.GroupComparisonDef = GroupComparisonDef.EMPTY.ChangeControlAnnotation("Condition")
                                       .ChangeControlValue("Healthy")
                                       .ChangeSummarizationMethod(SummarizationMethod.AVERAGING)
                                       .ChangePerProtein(true);
            var groupComparer = new GroupComparer(model.GroupComparisonDef, srmDocument, new QrFactorizationCache());

            foreach (var moleculeGroup in srmDocument.MoleculeGroups)
            {
                if (moleculeGroup.Molecules.Any(mol => null != mol.GlobalStandardType))
                {
                    continue;
                }
                var foldChangeResult = groupComparer.CalculateFoldChange(new GroupComparisonSelector(moleculeGroup, null, IsotopeLabelType.light, null, new GroupIdentifier("Diseased")), null);
                var xValues          = new List <double>();
                var yValues          = new List <double>();
                var protein          = new Protein(skylineDataSchema, new IdentityPath(moleculeGroup.PeptideGroup));
                foreach (var proteinResult in protein.Results.Values)
                {
                    var abundance = proteinResult.Abundance;
                    if (!abundance.HasValue)
                    {
                        continue;
                    }

                    var condition = proteinResult.Replicate.ChromatogramSet.Annotations.GetAnnotation("Condition");
                    if (condition == "Healthy")
                    {
                        xValues.Add(0);
                    }
                    else if (condition == "Diseased")
                    {
                        xValues.Add(1);
                    }
                    yValues.Add(Math.Log(abundance.Value));
                }
                Assert.AreEqual(xValues.Count, foldChangeResult.ReplicateCount);

                if (!xValues.Any())
                {
                    continue;
                }
                var yStatistics        = new Statistics(yValues);
                var xStatistics        = new Statistics(xValues);
                var slope              = yStatistics.Slope(xStatistics);
                var actualFoldChange   = Math.Exp(slope);
                var expectedFoldChange = Math.Pow(2.0, foldChangeResult.LinearFitResult.EstimatedValue);

                AssertEx.AreEqual(expectedFoldChange, actualFoldChange, .01);
            }
        }
コード例 #13
0
        private SkylineDataSchema GetDataSchema()
        {
            var document  = new SrmDocument(SrmSettingsList.GetDefault());
            var container = new MemoryDocumentContainer();

            Assert.IsTrue(container.SetDocument(document, container.Document));
            return(new SkylineDataSchema(container, DataSchemaLocalizer.INVARIANT));
        }
コード例 #14
0
            public static BrowsingDataSchema GetBrowsingDataSchema()
            {
                var memoryDocumentContainer = new MemoryDocumentContainer();
                var document = new SrmDocument(SrmSettingsList.GetDefault());

                memoryDocumentContainer.SetDocument(document, memoryDocumentContainer.Document);
                return(new BrowsingDataSchema(memoryDocumentContainer, GetLocalizedSchemaLocalizer()));
            }
コード例 #15
0
        private static SkylineDataSchema GetSkylineDataSchema(SrmDocument srmDocument, DataSchemaLocalizer dataSchemaLocalizer)
        {
            var memoryDocumentContainer = new MemoryDocumentContainer();

            memoryDocumentContainer.SetDocument(srmDocument,
                                                memoryDocumentContainer.Document);
            return(new SkylineDataSchema(memoryDocumentContainer, dataSchemaLocalizer));
        }
コード例 #16
0
        public IEnumerable <SkylineDataSchema> EnumerateDataSchemas()
        {
            var documentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(documentContainer.SetDocument(new SrmDocument(SrmSettingsList.GetDefault()), documentContainer.Document));
            var dataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());

            yield return(dataSchema);
        }
コード例 #17
0
 /// <summary>
 /// Creates a DocumentGridViewContext that can be used for exporting reports, importing report definitions, etc.
 /// </summary>
 public static DocumentGridViewContext CreateDocumentGridViewContext(SrmDocument document, DataSchemaLocalizer dataSchemaLocalizer)
 {
     if (document == null)
     {
         document = new SrmDocument(SrmSettingsList.GetDefault());
     }
     var memoryDocumentContainer = new MemoryDocumentContainer();
     memoryDocumentContainer.SetDocument(document, memoryDocumentContainer.Document);
     return new DocumentGridViewContext(new SkylineDataSchema(memoryDocumentContainer, dataSchemaLocalizer));
 }
コード例 #18
0
        /// <summary>
        /// Creates a DocumentGridViewContext that can be used for exporting reports, importing report definitions, etc.
        /// </summary>
        public static DocumentGridViewContext CreateDocumentGridViewContext(SrmDocument document, DataSchemaLocalizer dataSchemaLocalizer)
        {
            if (document == null)
            {
                document = new SrmDocument(SrmSettingsList.GetDefault());
            }
            var memoryDocumentContainer = new MemoryDocumentContainer();

            memoryDocumentContainer.SetDocument(document, memoryDocumentContainer.Document);
            return(new DocumentGridViewContext(new SkylineDataSchema(memoryDocumentContainer, dataSchemaLocalizer)));
        }
コード例 #19
0
        public static void ReportToCsv(ReportSpec reportSpec, SrmDocument doc, string fileName, CultureInfo cultureInfo)
        {
            var documentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(documentContainer.SetDocument(doc, documentContainer.Document));
            var skylineDataSchema = new SkylineDataSchema(documentContainer, new DataSchemaLocalizer(cultureInfo, cultureInfo));
            var viewSpec          = ReportSharing.ConvertAll(new[] { new ReportOrViewSpec(reportSpec) }, doc).First();
            var viewContext       = new DocumentGridViewContext(skylineDataSchema);

            using (var writer = new StreamWriter(fileName))
            {
                IProgressStatus status = new ProgressStatus();
                viewContext.Export(CancellationToken.None, new SilentProgressMonitor(), ref status,
                                   viewContext.GetViewInfo(ViewGroup.BUILT_IN, viewSpec), writer, viewContext.GetCsvWriter());
            }
        }
コード例 #20
0
        public void TestGenerateMsStatsInput()
        {
            SrmDocument testDocument            = OpenTestDocument();
            var         memoryDocumentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(memoryDocumentContainer.SetDocument(testDocument, memoryDocumentContainer.Document));
            SkylineDataSchema skylineDataSchema = new SkylineDataSchema(memoryDocumentContainer, DataSchemaLocalizer.INVARIANT);
            var             view           = ReportSharing.DeserializeReportList(OpenTestFile("MSstats_report.skyr")).First().ViewSpec;
            var             viewContext    = new DocumentGridViewContext(skylineDataSchema);
            StringWriter    stringWriter   = new StringWriter();
            IProgressStatus progressStatus = new ProgressStatus();

            viewContext.Export(new SilentProgressMonitor(), ref progressStatus,
                               viewContext.GetViewInfo(ViewGroup.BUILT_IN, view), stringWriter,
                               viewContext.GetCsvWriter());
            string expectedReport = new StreamReader(OpenTestFile("BrudererSubset_MSstatsInput.csv")).ReadToEnd();

            AssertEx.NoDiff(expectedReport, stringWriter.ToString());
        }
コード例 #21
0
ファイル: ExportLiveReportDlg.cs プロジェクト: zrolfs/pwiz
        private SkylineViewContext GetViewContext(bool clone)
        {
            SkylineDataSchema dataSchema;

            if (clone)
            {
                var documentContainer = new MemoryDocumentContainer();
                documentContainer.SetDocument(_documentUiContainer.DocumentUI, documentContainer.Document);
                dataSchema = new SkylineDataSchema(documentContainer, GetDataSchemaLocalizer());
            }
            else
            {
                dataSchema = new SkylineDataSchema(_documentUiContainer, GetDataSchemaLocalizer());
            }
            return(new DocumentGridViewContext(dataSchema)
            {
                EnablePreview = true
            });
        }
コード例 #22
0
        public void TestPivotResultsThenIsotopeLabel()
        {
            var           assembly           = typeof(LiveReportPivotTest).Assembly;
            XmlSerializer documentSerializer = new XmlSerializer(typeof(SrmDocument));
            // ReSharper disable once AssignNullToNotNullAttribute
            var document = (SrmDocument)documentSerializer.Deserialize(
                assembly.GetManifestResourceStream(typeof(ReportSpecConverterTest), "silac_1_to_4.sky"));
            XmlSerializer reportSerializer = new XmlSerializer(typeof(ReportOrViewSpecList));
            // ReSharper disable once AssignNullToNotNullAttribute
            var views = (ReportOrViewSpecList)reportSerializer.Deserialize(
                assembly.GetManifestResourceStream(typeof(ReportSpecConverterTest), "LiveReportPivots.skyr"));
            var view = views.First(reportSpec => reportSpec.Name == "ResultSummaryPivotResultsThenLabelType").ViewSpec;
            var bindingListSource = new BindingListSource();
            var documentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(documentContainer.SetDocument(document, null));
            var dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);

            bindingListSource.SetViewContext(new DocumentGridViewContext(dataSchema), new ViewInfo(dataSchema, typeof(Precursor), view));
            var expectedColumnNames = new[] {
                "PeptideSequence",
                "Chromatograms Replicate",
                "Chromatograms PeptideRetentionTime",
                "light IsotopeLabelType",
                "light MeanTotalArea",
                "light Chromatograms TotalArea",
                "heavy IsotopeLabelType",
                "heavy MeanTotalArea",
                "heavy Chromatograms TotalArea",
            };
            var actualColumnNames =
                bindingListSource.GetItemProperties(null)
                .Cast <PropertyDescriptor>()
                .Select(pd => pd.DisplayName)
                .ToArray();

            CollectionAssert.AreEqual(expectedColumnNames, actualColumnNames);
        }
コード例 #23
0
 public SkylineDataSchema Clone()
 {
     var container = new MemoryDocumentContainer();
     container.SetDocument(Document, container.Document);
     return new SkylineDataSchema(container, DataSchemaLocalizer);
 }
コード例 #24
0
        protected override void DoTest()
        {
            int seed = (int)DateTime.Now.Ticks;
            // Console.WriteLine("FiguresOfMeritTest: using random seed {0}", seed);
            var random = new Random(seed);

            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("FiguresOfMeritTest.sky")));
            var documentGrid = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));

            RunUI(() =>
            {
                documentGrid.ChooseView("FiguresOfMerit");
            });
            var calibrationForm = ShowDialog <CalibrationForm>(() => SkylineWindow.ShowCalibrationForm());

            Assert.IsNotNull(calibrationForm);
            var results = new List <Tuple <FiguresOfMeritOptions, ModifiedSequence, FiguresOfMerit> >();
            int count   = 0;

            foreach (var options in EnumerateFiguresOfMeritOptions().OrderBy(x => random.Next()).Take(10))
            {
                count++;
                bool doFullTest        = count < 5;
                var  newQuantification = SkylineWindow.Document.Settings.PeptideSettings.Quantification;
                // ReSharper disable once PossibleNullReferenceException
                newQuantification = newQuantification
                                    .ChangeRegressionFit(options.RegressionFit)
                                    .ChangeLodCalculation(options.LodCalculation)
                                    .ChangeMaxLoqCv(options.MaxLoqCv)
                                    .ChangeMaxLoqBias(options.MaxLoqBias);
                if (doFullTest)
                {
                    var peptideSettingsUi = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
                    RunUI(() =>
                    {
                        peptideSettingsUi.QuantRegressionFit = options.RegressionFit;
                        peptideSettingsUi.QuantLodMethod     = options.LodCalculation;
                        peptideSettingsUi.QuantMaxLoqBias    = options.MaxLoqBias;
                        peptideSettingsUi.QuantMaxLoqCv      = options.MaxLoqCv;
                    });
                    OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog);
                    if (!Equals(newQuantification, SkylineWindow.Document.Settings.PeptideSettings.Quantification))
                    {
                        Assert.AreEqual(newQuantification, SkylineWindow.Document.Settings.PeptideSettings.Quantification);
                    }
                }
                else
                {
                    RunUI(() =>
                    {
                        SkylineWindow.ModifyDocument("Test changed settings",
                                                     doc => doc.ChangeSettings(doc.Settings.ChangePeptideSettings(
                                                                                   doc.Settings.PeptideSettings.ChangeAbsoluteQuantification(newQuantification))));
                    });
                }
                WaitForConditionUI(() => documentGrid.IsComplete);
                var colPeptideModifiedSequence = documentGrid.DataGridView.Columns.Cast <DataGridViewColumn>()
                                                 .FirstOrDefault(col => col.HeaderText == ColumnCaptions.PeptideModifiedSequence);
                Assert.IsNotNull(colPeptideModifiedSequence);
                var colFiguresOfMerit = documentGrid.DataGridView.Columns.Cast <DataGridViewColumn>()
                                        .FirstOrDefault(col => col.HeaderText == ColumnCaptions.FiguresOfMerit);
                Assert.IsNotNull(colFiguresOfMerit);
                var docContainer = new MemoryDocumentContainer();
                Assert.IsTrue(docContainer.SetDocument(SkylineWindow.Document, docContainer.Document));
                var dataSchema = new SkylineDataSchema(docContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
                foreach (var group in SkylineWindow.Document.MoleculeGroups)
                {
                    foreach (var peptide in group.Molecules)
                    {
                        var identityPath  = new IdentityPath(group.Id, peptide.Id);
                        var peptideEntity = new Skyline.Model.Databinding.Entities.Peptide(dataSchema, identityPath);
                        VerifyFiguresOfMeritValues(options, peptideEntity);
                        ValidateFiguresOfMerit(options, peptideEntity.FiguresOfMerit);
                        results.Add(Tuple.Create(options, peptideEntity.ModifiedSequence, peptideEntity.FiguresOfMerit));
                        if (doFullTest)
                        {
                            RunUI(() => SkylineWindow.SelectedPath = identityPath);
                            WaitForGraphs();
                        }
                    }
                }
            }
            foreach (var result in results)
            {
                foreach (var resultCompare in results)
                {
                    if (!Equals(result.Item2, resultCompare.Item2))
                    {
                        continue;
                    }
                    var options1 = result.Item1;
                    var options2 = resultCompare.Item1;
                    if (!Equals(options1.RegressionFit, options2.RegressionFit))
                    {
                        continue;
                    }
                    CompareLoq(result.Item1, result.Item3, resultCompare.Item1, resultCompare.Item3);
                }
            }
        }
コード例 #25
0
        public void TestMapping()
        {
            var settings          = SrmSettingsList.GetDefault();
            var document          = new SrmDocument(settings);
            var documentContainer = new MemoryDocumentContainer();

            documentContainer.SetDocument(document, null);
            using (var database = new Database(settings))
            {
                var dataSchema     = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);
                var sessionFactory = database.SessionFactory;
                foreach (var classMetaData in sessionFactory.GetAllClassMetadata().Values)
                {
                    var tableType = classMetaData.GetMappedClass(EntityMode.Poco);
                    foreach (var propertyName in classMetaData.PropertyNames)
                    {
                        if (propertyName == "Protein" && tableType == typeof(DbProteinResult))
                        {
                            continue;
                        }
                        var queryDef = new QueryDef
                        {
                            Select = new[] { new ReportColumn(tableType, propertyName), }
                        };
                        var reportSpec   = new ReportSpec("test", queryDef);
                        var newTableType = ReportSpecConverter.GetNewTableType(reportSpec);
                        Assert.IsNotNull(newTableType, "No table for type {0}", tableType);
                        var converter = new ReportSpecConverter(dataSchema);
                        var viewInfo  = converter.Convert(reportSpec);
                        Assert.IsNotNull(viewInfo, "Unable to convert property {0} in table {1}", propertyName, tableType);
                        Assert.AreEqual(1, viewInfo.DisplayColumns.Count, "No conversion for property {0} in table {1}", propertyName, tableType);
                        Assert.IsNotNull(viewInfo.DisplayColumns[0].ColumnDescriptor, "Column not found for property {0} in table {1}", propertyName, tableType);
                        var report            = Report.Load(reportSpec);
                        var resultSet         = report.Execute(database);
                        var bindingListSource = new BindingListSource();
                        bindingListSource.SetViewContext(new SkylineViewContext(viewInfo.ParentColumn, Array.CreateInstance(viewInfo.ParentColumn.PropertyType, 0)), viewInfo);
                        var properties  = bindingListSource.GetItemProperties(null);
                        var oldCaptions = resultSet.ColumnInfos.Select(columnInfo => columnInfo.Caption).ToArray();
                        var newCaptions = properties.Cast <PropertyDescriptor>().Select(pd => pd.DisplayName).ToArray();
                        if (oldCaptions.Length != newCaptions.Length)
                        {
                            Console.Out.WriteLine(oldCaptions);
                        }
                        CollectionAssert.AreEqual(oldCaptions, newCaptions, "Caption mismatch on {0} in {1}", propertyName, tableType);
                        for (int i = 0; i < resultSet.ColumnInfos.Count; i++)
                        {
                            var    columnInfo      = resultSet.ColumnInfos[i];
                            var    formatAttribute = (FormatAttribute)properties[i].Attributes[typeof(FormatAttribute)];
                            string message         = string.Format("Format problem on column converted from {0} in {1}",
                                                                   columnInfo.ReportColumn.Column, columnInfo.ReportColumn.Table);
                            if (null == columnInfo.Format)
                            {
                                Assert.IsTrue(null == formatAttribute || null == formatAttribute.Format, message);
                            }
                            else
                            {
                                Assert.IsNotNull(formatAttribute, message);
                                Assert.AreEqual(columnInfo.Format, formatAttribute.Format, message);
                            }
                            if (columnInfo.IsNumeric)
                            {
                                Assert.IsNotNull(formatAttribute, message);
                                Assert.AreEqual(TextUtil.EXCEL_NA, formatAttribute.NullValue, message);
                            }
                            else
                            {
                                Assert.IsTrue(null == formatAttribute || null == formatAttribute.NullValue, message);
                            }
                        }
                    }
                }
            }
        }