From: Renia Correya Date: Tue, 3 Sep 2024 11:14:12 +0000 (+0530) Subject: Correction in tests X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8f444ff1b9acc2753ed34bfdc2e2c46f4aaebe52;p=jalview.git Correction in tests --- diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 863356e..1cf9a80 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -83,29 +83,25 @@ public class AlignmentUtilsTests { JvOptionPane.setInteractiveMode(false); JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); - - AlignmentAnnotation ann1 = new AlignmentAnnotation( - "Secondary Structure", "Secondary Structure", + + AlignmentAnnotation ann1 = new AlignmentAnnotation("Secondary Structure", "Secondary Structure", + new Annotation[] {}); + AlignmentAnnotation ann2 = new AlignmentAnnotation("jnetpred", "jnetpred", new Annotation[] {}); - AlignmentAnnotation ann2 = new AlignmentAnnotation("jnetpred", - "jnetpred", new Annotation[] {}); AlignmentAnnotation ann3 = new AlignmentAnnotation("Temp", "Temp", new Annotation[] {}); AlignmentAnnotation ann4 = new AlignmentAnnotation("Temp", "Temp", new Annotation[] {}); + + AlignmentAnnotation[] anns1 = new AlignmentAnnotation[] {ann1, ann3, ann4}; - AlignmentAnnotation[] anns1 = new AlignmentAnnotation[] { ann1, ann3, - ann4 }; - - AlignmentAnnotation[] anns2 = new AlignmentAnnotation[] { ann2, ann3, - ann4 }; - - AlignmentAnnotation[] anns3 = new AlignmentAnnotation[] { ann3, ann4 }; - + AlignmentAnnotation[] anns2 = new AlignmentAnnotation[] {ann2, ann3, ann4}; + + AlignmentAnnotation[] anns3 = new AlignmentAnnotation[] {ann3, ann4}; + AlignmentAnnotation[] anns4 = new AlignmentAnnotation[0]; - - AlignmentAnnotation[] anns5 = new AlignmentAnnotation[] { ann1, ann2, - ann3, ann4 }; + + AlignmentAnnotation[] anns5 = new AlignmentAnnotation[] {ann1, ann2, ann3, ann4}; } @Test(groups = { "Functional" }) @@ -2785,180 +2781,133 @@ public class AlignmentUtilsTests Assert.assertEquals(expectedSSPresent, AlignmentUtils.isSecondaryStructurePresent(annotations)); } - @Test( - groups = "Functional", - dataProvider = "SecondaryStructureAnnotations") - public void testSecondaryStructurePresentAndSources( - AlignmentAnnotation[] annotations, boolean expectedSSPresent, - ArrayList expectedSSSources) - { - Assert.assertEquals(expectedSSPresent, - AlignmentUtils.isSecondaryStructurePresent(annotations)); - Assert.assertEquals(expectedSSSources, - AlignmentUtils.getSecondaryStructureSources(annotations)); - } - - @DataProvider(name = "SecondaryStructureAnnotations") - public static Object[][] provideSecondaryStructureAnnotations() - { - AlignmentAnnotation ann1 = new AlignmentAnnotation( - "Secondary Structure", "Secondary Structure", - new Annotation[] {}); - AlignmentAnnotation ann2 = new AlignmentAnnotation("jnetpred", - "jnetpred", new Annotation[] {}); - AlignmentAnnotation ann3 = new AlignmentAnnotation("Temp", "Temp", - new Annotation[] {}); - AlignmentAnnotation ann4 = new AlignmentAnnotation("Temp", "Temp", - new Annotation[] {}); - - List ssSources1 = new ArrayList<>( - Arrays.asList("3D Structures")); - List ssSources2 = new ArrayList<>(Arrays.asList("JPred")); - List ssSources3 = new ArrayList<>( - Arrays.asList("3D Structures", "JPred")); - List ssSources4 = new ArrayList<>(); - - return new Object[][] { - { new AlignmentAnnotation[] - { ann1, ann3, ann4 }, true, ssSources1 }, - { new AlignmentAnnotation[] - { ann2, ann3, ann4 }, true, ssSources2 }, - { new AlignmentAnnotation[] - { ann3, ann4 }, false, ssSources4 }, - { new AlignmentAnnotation[] {}, false, ssSources4 }, - { new AlignmentAnnotation[] - { ann1, ann2, ann3, ann4 }, true, ssSources3 } }; - } - - @Test(dataProvider = "SecondaryStructureAnnotationColours") - public void testSecondaryStructureAnnotationColour(char symbol, - Color expectedColor) - { - Color actualColor = AlignmentUtils - .getSecondaryStructureAnnotationColour(symbol); - Assert.assertEquals(actualColor, expectedColor); - } - - @DataProvider(name = "SecondaryStructureAnnotationColours") - public static Object[][] provideSecondaryStructureAnnotationColours() - { - return new Object[][] { { 'C', Color.gray }, { 'E', Color.green }, - { 'H', Color.red }, - { '-', Color.gray } }; - } - - @Test(dataProvider = "SSAnnotationPresence") - public void testIsSSAnnotationPresent( - Map> annotations, - boolean expectedPresence) - { - boolean actualPresence = AlignmentUtils - .isSSAnnotationPresent(annotations); - Assert.assertEquals(actualPresence, expectedPresence); - } - - @DataProvider(name = "SSAnnotationPresence") - public static Object[][] provideSSAnnotationPresence() - { - Map> annotations1 = new HashMap<>(); - SequenceI seq1 = new Sequence("Seq1", "ASD---ASD---ASD", 37, 45); - List annotationsList1 = new ArrayList<>(); - annotationsList1.add(new AlignmentAnnotation("Secondary Structure", - "Secondary Structure", new Annotation[] {})); - annotations1.put(seq1, annotationsList1); // Annotation present secondary - // structure for seq1 - - Map> annotations2 = new HashMap<>(); - SequenceI seq2 = new Sequence("Seq2", "ASD---ASD------", 37, 42); - List annotationsList2 = new ArrayList<>(); - annotationsList2.add(new AlignmentAnnotation("Other Annotation", - "Other Annotation", new Annotation[] {})); - annotations2.put(seq2, annotationsList2); // Annotation not related to any - // of secondary structure for seq2 - - Map> annotations3 = new HashMap<>(); - // Empty annotation map - - Map> annotations4 = new HashMap<>(); - SequenceI seq4 = new Sequence("Seq4", "ASD---ASD---AS-", 37, 44); - List annotationsList4 = new ArrayList<>(); - annotationsList4.add(new AlignmentAnnotation("jnetpred", "jnetpred", - new Annotation[] {})); - annotations4.put(seq4, annotationsList4); // Annotation present from JPred - // for seq4 - - return new Object[][] { { annotations1, true }, // Annotations present - // secondary structure - // present - { annotations2, false }, // No annotations related to any of the - // secondary structure present - { annotations3, false }, // Empty annotation map - { annotations4, true }, // Annotations present from JPred secondary - // structure present - }; - } + @DataProvider(name = "SecondaryStructureAnnotations") + public static Object[][] provideSecondaryStructureAnnotations() { + AlignmentAnnotation ann1 = new AlignmentAnnotation("Secondary Structure", "Secondary Structure", new Annotation[]{}); + AlignmentAnnotation ann2 = new AlignmentAnnotation("jnetpred", "jnetpred", new Annotation[]{}); + AlignmentAnnotation ann3 = new AlignmentAnnotation("Temp", "Temp", new Annotation[]{}); + AlignmentAnnotation ann4 = new AlignmentAnnotation("Temp", "Temp", new Annotation[]{}); + + List ssSources1 = new ArrayList<>(Arrays.asList("3D Structures")); + List ssSources2 = new ArrayList<>(Arrays.asList("JPred")); + List ssSources3 = new ArrayList<>(Arrays.asList("3D Structures", "JPred")); + List ssSources4 = new ArrayList<>(); + + return new Object[][]{ + {new AlignmentAnnotation[]{ann1, ann3, ann4}, true, ssSources1}, + {new AlignmentAnnotation[]{ann2, ann3, ann4}, true, ssSources2}, + {new AlignmentAnnotation[]{ann3, ann4}, false, ssSources4}, + {new AlignmentAnnotation[]{}, false, ssSources4}, + {new AlignmentAnnotation[]{ann1, ann2, ann3, ann4}, true, ssSources3} + }; + } + + @Test(dataProvider = "SecondaryStructureAnnotationColours") + public void testSecondaryStructureAnnotationColour(char symbol, Color expectedColor) { + Color actualColor = AlignmentUtils.getSecondaryStructureAnnotationColour(symbol); + Assert.assertEquals(actualColor, expectedColor); + } - @Test - public void testGetSSSourceFromAnnotationDescription( - AlignmentAnnotation[] annotations, String expectedSSSource) - { - List actualSSSource = AlignmentUtils - .extractSSSourceInAlignmentAnnotation(annotations); - Assert.assertEquals(actualSSSource, expectedSSSource); - } + @DataProvider(name = "SecondaryStructureAnnotationColours") + public static Object[][] provideSecondaryStructureAnnotationColours() { + return new Object[][]{ + {'C', Color.gray}, + {'E', Color.green}, + {'H', Color.red}, + {'-', Color.gray} + }; + } + + @Test(dataProvider = "SSAnnotationPresence") + public void testIsSSAnnotationPresent(Map> annotations, boolean expectedPresence) { + boolean actualPresence = AlignmentUtils.isSSAnnotationPresent(annotations); + Assert.assertEquals(actualPresence, expectedPresence); + } - @DataProvider(name = "SSSourceFromAnnotationDescription") - public static Object[][] provideSSSourceFromAnnotationDescription() - { - Map> annotations1 = new HashMap<>(); - SequenceI seq1 = new Sequence("Seq1", "ASD---ASD---ASD", 37, 45); - List annotationsList1 = new ArrayList<>(); - annotationsList1.add(new AlignmentAnnotation("jnetpred", "JPred Output", - new Annotation[] {})); - annotations1.put(seq1, annotationsList1); // Annotation present from JPred - // for seq1 - - Map> annotations2 = new HashMap<>(); - SequenceI seq2 = new Sequence("Seq2", "ASD---ASD------", 37, 42); - List annotationsList2 = new ArrayList<>(); - annotationsList2.add(new AlignmentAnnotation("Secondary Structure", - "Secondary Structure for af-q43517-f1A", new Annotation[] {})); - annotations2.put(seq2, annotationsList2); // Annotation present secondary - // structure from Alphafold for - // seq2 - - Map> annotations3 = new HashMap<>(); - // Empty annotation map - - Map> annotations4 = new HashMap<>(); - SequenceI seq4 = new Sequence("Seq4", "ASD---ASD---AS-", 37, 44); - List annotationsList4 = new ArrayList<>(); - annotationsList4.add(new AlignmentAnnotation("Secondary Structure", - "Secondary Structure for 4zhpA", new Annotation[] {})); - annotations4.put(seq4, annotationsList4); // Annotation present secondary - // structure from pdb for seq4 - - Map> annotations5 = new HashMap<>(); - SequenceI seq5 = new Sequence("Seq5", "ASD---ASD---AS-", 37, 44); - List annotationsList5 = new ArrayList<>(); - annotationsList5.add(new AlignmentAnnotation("Secondary Structure", - "Secondary Structure for p09911_54-147__3a7wzn.1.p3502557454997462030P", - new Annotation[] {})); - annotations5.put(seq5, annotationsList5); // Annotation present secondary - // structure from Swiss model for - // seq5 - - // JPred Output - JPred - // Secondary Structure for af-q43517-f1A - Alphafold - // Secondary Structure for 4zhpA - Experimental - // Secondary Structure for p09911_54-147__3a7wzn.1.p3502557454997462030P - - // Swiss Model - - return new Object[][] { { annotations1, "JPred" }, - { annotations2, "Alphafold" }, - { annotations3, null }, - { annotations4, "PDB" }, - { annotations5, "Swiss Model" } }; - } + @DataProvider(name = "SSAnnotationPresence") + public static Object[][] provideSSAnnotationPresence() { + Map> annotations1 = new HashMap<>(); + SequenceI seq1 = new Sequence("Seq1", "ASD---ASD---ASD", 37, 45); + List annotationsList1 = new ArrayList<>(); + annotationsList1.add(new AlignmentAnnotation("Secondary Structure", "Secondary Structure", new Annotation[]{})); + annotations1.put(seq1, annotationsList1); // Annotation present secondary structure for seq1 + + Map> annotations2 = new HashMap<>(); + SequenceI seq2 = new Sequence("Seq2", "ASD---ASD------", 37, 42); + List annotationsList2 = new ArrayList<>(); + annotationsList2.add(new AlignmentAnnotation("Other Annotation", "Other Annotation", new Annotation[]{})); + annotations2.put(seq2, annotationsList2); // Annotation not related to any of secondary structure for seq2 + + Map> annotations3 = new HashMap<>(); + // Empty annotation map + + Map> annotations4 = new HashMap<>(); + SequenceI seq4 = new Sequence("Seq4", "ASD---ASD---AS-", 37, 44); + List annotationsList4 = new ArrayList<>(); + annotationsList4.add(new AlignmentAnnotation("jnetpred", "jnetpred", new Annotation[]{})); + annotations4.put(seq4, annotationsList4); // Annotation present from JPred for seq4 + + + return new Object[][]{ + {annotations1, true}, // Annotations present secondary structure present + {annotations2, false}, // No annotations related to any of the secondary structure present + {annotations3, false}, // Empty annotation map + {annotations4, true}, // Annotations present from JPred secondary structure present + }; + } + + @Test + public void testGetSSSourceFromAnnotationDescription(AlignmentAnnotation[] annotations, String expectedSSSource) { + List actualSSSource = AlignmentUtils.extractSSSourceInAlignmentAnnotation(annotations); + Assert.assertEquals(actualSSSource, expectedSSSource); + } + + @DataProvider(name = "SSSourceFromAnnotationDescription") + public static Object[][] provideSSSourceFromAnnotationDescription() { + Map> annotations1 = new HashMap<>(); + SequenceI seq1 = new Sequence("Seq1", "ASD---ASD---ASD", 37, 45); + List annotationsList1 = new ArrayList<>(); + annotationsList1.add(new AlignmentAnnotation("jnetpred", "JPred Output", new Annotation[]{})); + annotations1.put(seq1, annotationsList1); // Annotation present from JPred for seq1 + + Map> annotations2 = new HashMap<>(); + SequenceI seq2 = new Sequence("Seq2", "ASD---ASD------", 37, 42); + List annotationsList2 = new ArrayList<>(); + annotationsList2.add(new AlignmentAnnotation("Secondary Structure", + "Secondary Structure for af-q43517-f1A", new Annotation[]{})); + annotations2.put(seq2, annotationsList2); // Annotation present secondary structure from Alphafold for seq2 + + Map> annotations3 = new HashMap<>(); + // Empty annotation map + + Map> annotations4 = new HashMap<>(); + SequenceI seq4 = new Sequence("Seq4", "ASD---ASD---AS-", 37, 44); + List annotationsList4 = new ArrayList<>(); + annotationsList4.add(new AlignmentAnnotation("Secondary Structure", + "Secondary Structure for 4zhpA", new Annotation[]{})); + annotations4.put(seq4, annotationsList4); // Annotation present secondary structure from pdb for seq4 + + Map> annotations5 = new HashMap<>(); + SequenceI seq5 = new Sequence("Seq5", "ASD---ASD---AS-", 37, 44); + List annotationsList5 = new ArrayList<>(); + annotationsList5.add(new AlignmentAnnotation("Secondary Structure", + "Secondary Structure for p09911_54-147__3a7wzn.1.p3502557454997462030P", + new Annotation[]{})); + annotations5.put(seq5, annotationsList5); // Annotation present secondary structure from Swiss model for seq5 + + + //JPred Output - JPred + //Secondary Structure for af-q43517-f1A - Alphafold + //Secondary Structure for 4zhpA - Experimental + //Secondary Structure for p09911_54-147__3a7wzn.1.p3502557454997462030P - Swiss Model + + return new Object[][]{ + {annotations1, "JPred"}, + {annotations2, "Alphafold"}, + {annotations3, null}, + {annotations4, "PDB"}, + {annotations5, "Swiss Model"} + }; + } }