Exemplo n.º 1
0
 public Schema(ISessionFactory sessionFactory, DataSettings dataSettings)
 {
     _sessionFactory     = sessionFactory;
     _annotationDefNames = new HashSet <string>();
     if (dataSettings != null)
     {
         foreach (var annotationDef in dataSettings.AnnotationDefs)
         {
             _annotationDefNames.Add(AnnotationDef.GetKey(annotationDef.Name));
         }
     }
 }
Exemplo n.º 2
0
        private void ZipTestAnnotations()
        {
            var sampleId = new AnnotationDef("SampleID", // Not L10N
                                             AnnotationDef.AnnotationTargetSet.Singleton(
                                                 AnnotationDef.AnnotationTarget.replicate),
                                             AnnotationDef.AnnotationType.text,
                                             new List <string>());

            var isConc = new AnnotationDef("IS Conc", // Not L10N
                                           AnnotationDef.AnnotationTargetSet.Singleton(
                                               AnnotationDef.AnnotationTarget.replicate),
                                           AnnotationDef.AnnotationType.text,
                                           new List <string>());

            var analyteConcentration = new AnnotationDef("Analyte Concentration", // Not L10N
                                                         AnnotationDef.AnnotationTargetSet.Singleton(
                                                             AnnotationDef.AnnotationTarget.replicate),
                                                         AnnotationDef.AnnotationType.text,
                                                         new List <string>());

            var sampleIdTransition = new AnnotationDef("SampleID", // Not L10N
                                                       AnnotationDef.AnnotationTargetSet.Singleton(
                                                           AnnotationDef.AnnotationTarget.transition),
                                                       AnnotationDef.AnnotationType.text,
                                                       new List <string>());

            // Test proper loading of annotations
            string testAnnotationsPath = TestFilesDir.GetTestPath("TestAnnotations.zip"); // Not L10N

            RunDlg <ConfigureToolsDlg>(() => SkylineWindow.ShowConfigureToolsDlg(), dlg =>
            {
                dlg.RemoveAllTools();
                dlg.InstallZipTool(testAnnotationsPath);
                WaitForConditionUI(3 * 1000, () => dlg.ToolList.Count == 4);

                ToolDescription t0 = dlg.ToolList[0];
                ToolDescription t1 = dlg.ToolList[1];
                ToolDescription t2 = dlg.ToolList[2];
                ToolDescription t3 = dlg.ToolList[3];

                AssertEx.AreEqualDeep(t0.Annotations, new List <AnnotationDef>());
                AssertEx.AreEqualDeep(t1.Annotations,
                                      new List <AnnotationDef>
                {
                    sampleId,
                    isConc,
                    analyteConcentration
                });
                AssertEx.AreEqualDeep(t2.Annotations, new List <AnnotationDef> {
                    sampleId
                });
                AssertEx.AreEqualDeep(t3.Annotations, new List <AnnotationDef>());
                Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(sampleId));
                Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(isConc));
                Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(analyteConcentration));

                dlg.OkDialog();
            });

            // Test conflicting annotations
            var    configureToolsDlg       = ShowDialog <ConfigureToolsDlg>(SkylineWindow.ShowConfigureToolsDlg);
            string conflictAnnotationsPath = TestFilesDir.GetTestPath("ConflictAnnotations.zip"); // Not L10N

            RunDlg <MultiButtonMsgDlg>(() => configureToolsDlg.InstallZipTool(conflictAnnotationsPath),
                                       messageDlg => messageDlg.Btn1Click()); // keep existing annotations
            WaitForConditionUI(3 * 1000, () => configureToolsDlg.ToolList.Count == 5);
            Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(sampleId));
            RunDlg <MultiButtonMsgDlg>(() => configureToolsDlg.InstallZipTool(conflictAnnotationsPath),
                                       dlg => dlg.Btn0Click());
            {
                var messageDlg = WaitForOpenForm <MultiButtonMsgDlg>();
                OkDialog(messageDlg, messageDlg.Btn0Click);
            }
            // overwrite existing annotations
            Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(sampleIdTransition));

            OkDialog(configureToolsDlg, configureToolsDlg.OkDialog);
            RunUI(() => SkylineWindow.PopulateToolsMenu());

            // Test running the tool with an unchecked annotation
            RunDlg <MessageDlg>(() => SkylineWindow.RunTool(4), dlg =>
            {
                Assert.AreEqual(TextUtil.LineSeparate(Resources.ToolDescription_VerifyAnnotations_This_tool_requires_the_use_of_the_following_annotations_which_are_not_enabled_for_this_document,
                                                      string.Empty,
                                                      TextUtil.LineSeparate(new Collection <string> {
                    sampleId.GetKey()
                }),
                                                      string.Empty,
                                                      Resources.ToolDescription_VerifyAnnotations_Please_enable_these_annotations_and_fill_in_the_appropriate_data_in_order_to_use_the_tool_), dlg.Message);
                dlg.OkDialog();
            });

            // Test running the tool with a missing annotation
            Settings.Default.AnnotationDefList = new AnnotationDefList();
            WaitForCondition(3 * 1000, () => Settings.Default.AnnotationDefList.Count == 0);
            RunDlg <MessageDlg>(() => SkylineWindow.RunTool(4), dlg =>
            {
                Assert.AreEqual(TextUtil.LineSeparate(Resources.ToolDescription_VerifyAnnotations_This_tool_requires_the_use_of_the_following_annotations_which_are_missing_or_improperly_formatted,
                                                      string.Empty,
                                                      TextUtil.LineSeparate(new Collection <string> {
                    sampleId.GetKey()
                }),
                                                      string.Empty,
                                                      Resources.ToolDescription_VerifyAnnotations_Please_re_install_the_tool_and_try_again_), dlg.Message);
                dlg.OkDialog();
            });

            // Clean-up
            RunDlg <ConfigureToolsDlg>(() => SkylineWindow.ShowConfigureToolsDlg(), dlg =>
            {
                dlg.RemoveAllTools();
                dlg.OkDialog();
            });
        }
Exemplo n.º 3
0
        private void ZipTestAnnotations()
        {
            var sampleId = new AnnotationDef("SampleID", // Not L10N
                                             AnnotationDef.AnnotationTargetSet.Singleton(
                                                 AnnotationDef.AnnotationTarget.replicate),
                                              AnnotationDef.AnnotationType.text,
                                             new List<string>());

            var isConc = new AnnotationDef("IS Conc", // Not L10N
                                           AnnotationDef.AnnotationTargetSet.Singleton(
                                               AnnotationDef.AnnotationTarget.replicate),
                                           AnnotationDef.AnnotationType.text,
                                           new List<string>());

            var analyteConcentration = new AnnotationDef("Analyte Concentration", // Not L10N
                                                         AnnotationDef.AnnotationTargetSet.Singleton(
                                                             AnnotationDef.AnnotationTarget.replicate),
                                                         AnnotationDef.AnnotationType.text,
                                                         new List<string>());

            var sampleIdTransition = new AnnotationDef("SampleID", // Not L10N
                                                       AnnotationDef.AnnotationTargetSet.Singleton(
                                                           AnnotationDef.AnnotationTarget.transition),
                                                       AnnotationDef.AnnotationType.text,
                                                       new List<string>());

            // Test proper loading of annotations
            string testAnnotationsPath = TestFilesDir.GetTestPath("TestAnnotations.zip"); // Not L10N
            RunDlg<ConfigureToolsDlg>(() => SkylineWindow.ShowConfigureToolsDlg(), dlg =>
            {
                dlg.RemoveAllTools();
                dlg.InstallZipTool(testAnnotationsPath);
                WaitForConditionUI(3 * 1000, () => dlg.ToolList.Count == 4);

                ToolDescription t0 = dlg.ToolList[0];
                ToolDescription t1 = dlg.ToolList[1];
                ToolDescription t2 = dlg.ToolList[2];
                ToolDescription t3 = dlg.ToolList[3];

                AssertEx.AreEqualDeep(t0.Annotations, new List<AnnotationDef>());
                AssertEx.AreEqualDeep(t1.Annotations,
                                      new List<AnnotationDef>
                                              {
                                                  sampleId,
                                                  isConc,
                                                  analyteConcentration
                                              });
                AssertEx.AreEqualDeep(t2.Annotations, new List<AnnotationDef> { sampleId });
                AssertEx.AreEqualDeep(t3.Annotations, new List<AnnotationDef>());
                Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(sampleId));
                Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(isConc));
                Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(analyteConcentration));

                dlg.OkDialog();
            });

            // Test conflicting annotations
            var configureToolsDlg = ShowDialog<ConfigureToolsDlg>(SkylineWindow.ShowConfigureToolsDlg);
            string conflictAnnotationsPath = TestFilesDir.GetTestPath("ConflictAnnotations.zip"); // Not L10N
            RunDlg<MultiButtonMsgDlg>(() => configureToolsDlg.InstallZipTool(conflictAnnotationsPath),
                                      messageDlg => messageDlg.Btn1Click()); // keep existing annotations
            WaitForConditionUI(3 * 1000, () => configureToolsDlg.ToolList.Count == 5);
            Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(sampleId));
            RunDlg<MultiButtonMsgDlg>(() => configureToolsDlg.InstallZipTool(conflictAnnotationsPath),
                                      dlg => dlg.Btn0Click());
            {
                var messageDlg = WaitForOpenForm<MultiButtonMsgDlg>();
                OkDialog(messageDlg, messageDlg.Btn0Click);
            }
            // overwrite existing annotations
            Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(sampleIdTransition));

            OkDialog(configureToolsDlg, configureToolsDlg.OkDialog);
            RunUI(() => SkylineWindow.PopulateToolsMenu());

            // Test running the tool with an unchecked annotation
            RunDlg<MessageDlg>(() => SkylineWindow.RunTool(4), dlg =>
                {
                    Assert.AreEqual(TextUtil.LineSeparate(Resources.ToolDescription_VerifyAnnotations_This_tool_requires_the_use_of_the_following_annotations_which_are_not_enabled_for_this_document,
                                                                 string.Empty,
                                                                 TextUtil.LineSeparate(new Collection<string> {sampleId.GetKey()}),
                                                                 string.Empty,
                                                                 Resources.ToolDescription_VerifyAnnotations_Please_enable_these_annotations_and_fill_in_the_appropriate_data_in_order_to_use_the_tool_), dlg.Message);
                    dlg.OkDialog();
                });

            // Test running the tool with a missing annotation
            Settings.Default.AnnotationDefList = new AnnotationDefList();
            WaitForCondition(3*1000, () => Settings.Default.AnnotationDefList.Count == 0);
            RunDlg<MessageDlg>(() => SkylineWindow.RunTool(4), dlg =>
            {
                Assert.AreEqual(TextUtil.LineSeparate(Resources.ToolDescription_VerifyAnnotations_This_tool_requires_the_use_of_the_following_annotations_which_are_missing_or_improperly_formatted,
                                                              string.Empty,
                                                              TextUtil.LineSeparate(new Collection<string> { sampleId.GetKey() }),
                                                              string.Empty,
                                                              Resources.ToolDescription_VerifyAnnotations_Please_re_install_the_tool_and_try_again_), dlg.Message);
                dlg.OkDialog();
            });

            // Clean-up
            RunDlg<ConfigureToolsDlg>(() => SkylineWindow.ShowConfigureToolsDlg(), dlg =>
            {
                dlg.RemoveAllTools();
                dlg.OkDialog();
            });
        }