Esempio n. 1
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));
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public ListGridForm(IDocumentContainer documentContainer, string listName)
        {
            var skylineDataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());

            ListViewContext                   = ListViewContext.CreateListViewContext(skylineDataSchema, listName);
            BindingListSource.QueryLock       = ListViewContext.SkylineDataSchema.QueryLock;
            BindingListSource.ListChanged    += BindingListSourceOnListChanged;
            ListViewContext.BoundDataGridView = DataGridView;
            DataboundGridControl.BindingListSource.SetViewContext(ListViewContext);
            DataboundGridControl.BindingListSource.NewRowHandler = ListViewContext;
            Text = TabText = TextUtil.SpaceSeparate(Text + ':', listName);
        }
Esempio n. 4
0
        public void EditReportList()
        {
            var dataSchema  = new SkylineDataSchema(DocumentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var viewContext = new DocumentGridViewContext(dataSchema)
            {
                EnablePreview = true
            };

            using (var manageViewsForm = new ManageViewsForm(viewContext))
            {
                manageViewsForm.ShowDialog(this);
            }
        }
Esempio n. 5
0
        public static AuditLogForm MakeAuditLogForm(SkylineWindow skylineWindow)
        {
            var dataSchema = new SkylineDataSchema(skylineWindow, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var viewInfos  = new[]
            {
                CreateAuditLogViewInfo(dataSchema, AuditLogStrings.AuditLogForm_MakeAuditLogForm_Undo_Redo, @"TimeStamp", @"UndoRedoMessage"),
                CreateAuditLogViewInfo(dataSchema, AuditLogStrings.AuditLogForm_MakeAuditLogForm_Summary, @"TimeStamp", @"SummaryMessage"),
                CreateAuditLogViewInfo(dataSchema, AuditLogStrings.AuditLogForm_MakeAuditLogForm_All_Info, @"TimeStamp", @"Details!*.AllInfoMessage")
            };

            var rowSource     = new AuditLogRowSource(dataSchema);
            var rowSourceInfo = new RowSourceInfo(typeof(AuditLogRow), rowSource, viewInfos);
            var viewContext   = new SkylineViewContext(dataSchema, new[] { rowSourceInfo });

            return(new AuditLogForm(viewContext, viewInfos[2].Name));
        }
Esempio n. 6
0
        public void NewReport()
        {
            var dataSchema  = new SkylineDataSchema(DocumentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var viewContext = new DocumentGridViewContext(dataSchema)
            {
                EnablePreview = true
            };
            var newView = viewContext.NewView(this, PersistedViews.MainGroup);

            if (newView != null)
            {
                chooseViewsControl.SelectView(newView.Name);
                chooseViewsControl.CheckedViews = chooseViewsControl.CheckedViews
                                                  .Append(PersistedViews.MainGroup.Id.ViewName(newView.Name));
            }
        }
Esempio n. 7
0
 public void AddRef()
 {
     if (Interlocked.Increment(ref _referenceCount) == 1)
     {
         _skylineDataSchema = new SkylineDataSchema(GroupComparisonModel.DocumentContainer,
                                                    SkylineDataSchema.GetLocalizedSchemaLocalizer());
         var viewInfo = new ViewInfo(_skylineDataSchema, typeof(FoldChangeRow), GetDefaultViewSpec(new FoldChangeRow[0]))
                        .ChangeViewGroup(ViewGroup.BUILT_IN);
         var rowSourceInfo = new RowSourceInfo(typeof(FoldChangeRow), new StaticRowSource(new FoldChangeRow[0]), new[] { viewInfo });
         ViewContext        = new GroupComparisonViewContext(_skylineDataSchema, new[] { rowSourceInfo });
         _container         = new Container();
         _bindingListSource = new BindingListSource(_container);
         _bindingListSource.SetViewContext(ViewContext, viewInfo);
         GroupComparisonModel.ModelChanged += GroupComparisonModelOnModelChanged;
         GroupComparisonModelOnModelChanged(GroupComparisonModel, new EventArgs());
     }
 }
Esempio n. 8
0
        public MetadataRuleEditor(IDocumentContainer documentContainer)
        {
            InitializeComponent();
            _dataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var rootColumn  = ColumnDescriptor.RootColumn(_dataSchema, typeof(ResultFile));
            var viewContext =
                new SkylineViewContext(rootColumn, new StaticRowSource(new ExtractedMetadataResultRow[0]));

            _metadataExtractor = new MetadataExtractor(_dataSchema, typeof(ResultFile));
            bindingListSource1.SetViewContext(viewContext);
            var sources = _metadataExtractor.GetSourceColumns().ToArray();

            comboSourceText.Items.AddRange(sources);
            comboMetadataTarget.Items.AddRange(_metadataExtractor.GetTargetColumns().ToArray());
            SelectItem(comboSourceText, PropertyPath.Root.Property(nameof(ResultFile.FileName)));
            FormatCultureInfo = CultureInfo.InvariantCulture;
        }
Esempio n. 9
0
        public MetadataRuleSetEditor(IDocumentContainer documentContainer, MetadataRuleSet metadataRuleSet, IEnumerable <MetadataRuleSet> existing)
        {
            InitializeComponent();
            DocumentContainer = documentContainer;
            metadataRuleSet   = metadataRuleSet ?? new MetadataRuleSet(typeof(ResultFile));
            _originalName     = metadataRuleSet.Name;
            _dataSchema       = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var rootColumn         = ColumnDescriptor.RootColumn(_dataSchema, typeof(ExtractedMetadataResultRow));
            var viewInfo           = new ViewInfo(rootColumn, GetDefaultViewSpec());
            var skylineViewContext = new MetadataResultViewContext(rootColumn, new StaticRowSource(new MetadataStepResult[0]));

            bindingListSourceResults.SetViewContext(skylineViewContext, viewInfo);
            _metadataExtractor            = new MetadataExtractor(_dataSchema, typeof(ResultFile));
            _ruleRowList                  = new List <RuleRow>();
            bindingSourceRules.DataSource = new BindingList <RuleRow>(_ruleRowList);
            MetadataRuleSet               = metadataRuleSet;
            _existing = ImmutableList.ValueOfOrEmpty(existing);
        }
Esempio n. 10
0
        public LiveResultsGrid(SkylineWindow skylineWindow)
        {
            InitializeComponent();
            SkylineWindow = skylineWindow;
            _dataSchema   = new SkylineDataSchema(skylineWindow, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            BindingListSource.QueryLock       = _dataSchema.QueryLock;
            BindingListSource.ListChanged    += bindingListSource_ListChanged;
            BindingListSource.CurrentChanged += bindingListSource_CurrentChanged;
            DataGridView.DataBindingComplete += boundDataGridView_DataBindingComplete;
            var contextMenuStrip = databoundGridControl.contextMenuStrip;

            contextMenuStrip.Items.Insert(0, new ToolStripSeparator());
            for (int i = contextMenuResultsGrid.Items.Count - 1; i >= 0; i--)
            {
                contextMenuStrip.Items.Insert(0, contextMenuResultsGrid.Items[i]);
            }
            contextMenuStrip.Opening += contextMenu_Opening;
        }
 private DataSchemaLocalizer GetDataSchemaLocalizer()
 {
     return(InvariantLanguage
         ? DataSchemaLocalizer.INVARIANT
         : SkylineDataSchema.GetLocalizedSchemaLocalizer());
 }
Esempio n. 12
0
 public PcaPlot()
 {
     InitializeComponent();
     Localizer = SkylineDataSchema.GetLocalizedSchemaLocalizer();
 }
Esempio n. 13
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);
                }
            }
        }
Esempio n. 14
0
 private string GetLocalizedCaption(string caption)
 {
     return(SkylineDataSchema.GetLocalizedSchemaLocalizer().LookupColumnCaption(new ColumnCaption(caption)));
 }
Esempio n. 15
0
 public DocumentAnnotations(SrmDocument document) : this(SkylineDataSchema.MemoryDataSchema(document, SkylineDataSchema.GetLocalizedSchemaLocalizer()))
 {
 }
Esempio n. 16
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);
        }
Esempio n. 17
0
        public void TestExportWithCurrentLanguage()
        {
            CultureInfo       cultureInfo       = CultureInfo.CurrentUICulture;
            SkylineDataSchema skylineDataSchema =
                new SkylineDataSchema(CreateMemoryDocumentContainer(LoadTestDocument()), SkylineDataSchema.GetLocalizedSchemaLocalizer());
            SkylineViewContext viewContext = new DocumentGridViewContext(skylineDataSchema);

            string testFile  = Path.Combine(TestContext.TestDir, "TestExportWithCurrentLanguage.csv");
            char   separator = TextUtil.GetCsvSeparator(cultureInfo);
            var    dsvWriter = new DsvWriter(cultureInfo, separator);

            viewContext.ExportToFile(null, GetTestReport(skylineDataSchema), testFile, dsvWriter);
            string strExported   = File.ReadAllText(testFile);
            var    actualLines   = strExported.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
            var    expectedLines = ExpectedInvariantReport.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

            var invariantHeaders = expectedLines[0].Split(',');
            var expectedHeaders  =
                invariantHeaders.Select(header => ColumnCaptions.ResourceManager.GetString(header, cultureInfo) ?? header).ToArray();
            var actualHeaders = actualLines[0].Split(separator);

            CollectionAssert.AreEqual(expectedHeaders, actualHeaders);
            // If the language in English, then the exported report will be identical to the invariant report except for the headers
            if (cultureInfo.Name == "en-US")
            {
                CollectionAssert.AreEqual(expectedLines.Skip(1).ToArray(), actualLines.Skip(1).ToArray());
            }
        }
Esempio n. 18
0
 public DocumentGridForm(IDocumentContainer documentContainer)
     : this(new DocumentGridViewContext(new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer())))
 {
 }
Esempio n. 19
0
        protected override void DoTest()
        {
            RunUI(() =>
            {
                SkylineWindow.OpenFile(TestFilesDir.GetTestPath("HeatMapTest.sky"));
                SkylineWindow.ShowDocumentGrid(true);
            });
            TestGroupComparisonClustering();
            var documentGrid = FindOpenForm <DocumentGridForm>();

            Assert.IsNotNull(documentGrid);
            RunUI(() => documentGrid.ChooseView("PeptideResultValues"));
            WaitForCondition(() => documentGrid.IsComplete);
            var heatMap        = ShowDialog <HierarchicalClusterGraph>(() => documentGrid.DataboundGridControl.ShowHeatMap());
            var heatMapResults = heatMap.GraphResults;

            Assert.IsNotNull(heatMap);
            PauseForScreenShot("Normal heat map");
            OkDialog(heatMap, heatMap.Close);

            RunUI(() => documentGrid.BindingListSource.ClusteringSpec = ClusteringSpec.DEFAULT);
            WaitForCondition(() => documentGrid.IsComplete);
            List <string> expectedRowLabels = documentGrid.BindingListSource.OfType <RowItem>().Select(row =>
                                                                                                       documentGrid.BindingListSource.ItemProperties[0].GetValue(row)?.ToString() ?? string.Empty).ToList();
            List <string> actualRowLabels = heatMapResults.RowHeaders.Select(header => header.Caption).ToList();

            CollectionAssert.AreEqual(expectedRowLabels, actualRowLabels);
            List <string> expectedColumnLabels = documentGrid.BindingListSource.ItemProperties.OfType <ColumnPropertyDescriptor>()
                                                 .Where(c => c.PropertyPath.Name == "NormalizedArea").Select(col =>
                                                                                                             col.PivotedColumnId.PivotKeyCaption.GetCaption(SkylineDataSchema.GetLocalizedSchemaLocalizer())).ToList();
            List <string> actualColumnLabels = heatMapResults.ColumnGroups.First().Headers.Select(header => header.Caption).ToList();

            CollectionAssert.AreEqual(expectedColumnLabels, actualColumnLabels);

            RunUI(() => documentGrid.ChooseView("ThreeColumnGroups"));
            WaitForCondition(() => documentGrid.IsComplete);
            heatMap = ShowDialog <HierarchicalClusterGraph>(() => documentGrid.DataboundGridControl.ShowHeatMap());
            PauseForScreenShot("Heat map with three column groups");
            Assert.AreEqual(6, heatMap.GraphResults.ColumnGroups.Count);
            OkDialog(heatMap, heatMap.Close);
        }
Esempio n. 20
0
        public DocumentGridForm(IDocumentContainer documentContainer)
            : this(new DocumentGridViewContext(new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer())))
        {
            var skylineWindow = documentContainer as SkylineWindow;

            if (null != skylineWindow)
            {
                DataGridViewPasteHandler.Attach(skylineWindow, DataGridView);
            }
        }
Esempio n. 21
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"));
        }