import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
+import java.awt.Color;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
+import org.testng.Assert;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import jalview.datamodel.AlignedCodonFrame;
{
JvOptionPane.setInteractiveMode(false);
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+
+ 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[] {});
+
+ AlignmentAnnotation[] anns1 = new AlignmentAnnotation[] { ann1, 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 };
}
@Test(groups = { "Functional" })
&& al.getAlignmentAnnotation().length == 2);
}
+
+ @Test(
+ groups = "Functional",
+ dataProvider = "SecondaryStructureAnnotations")
+ public void testSecondaryStructurePresentAndSources(
+ AlignmentAnnotation[] annotations, boolean expectedSSPresent,
+ ArrayList<String> 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<String> ssSources1 = new ArrayList<>(
+ Arrays.asList("3D Structures"));
+ List<String> ssSources2 = new ArrayList<>(Arrays.asList("JPred"));
+ List<String> ssSources3 = new ArrayList<>(
+ Arrays.asList("3D Structures", "JPred"));
+ List<String> 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<SequenceI, List<AlignmentAnnotation>> annotations,
+ boolean expectedPresence)
+ {
+ boolean actualPresence = AlignmentUtils
+ .isSSAnnotationPresent(annotations);
+ Assert.assertEquals(actualPresence, expectedPresence);
+ }
+
+ @DataProvider(name = "SSAnnotationPresence")
+ public static Object[][] provideSSAnnotationPresence()
+ {
+ Map<SequenceI, List<AlignmentAnnotation>> annotations1 = new HashMap<>();
+ SequenceI seq1 = new Sequence("Seq1", "ASD---ASD---ASD", 37, 45);
+ List<AlignmentAnnotation> annotationsList1 = new ArrayList<>();
+ annotationsList1.add(new AlignmentAnnotation("Secondary Structure",
+ "Secondary Structure", new Annotation[] {}));
+ annotations1.put(seq1, annotationsList1); // Annotation present secondary
+ // structure for seq1
+
+ Map<SequenceI, List<AlignmentAnnotation>> annotations2 = new HashMap<>();
+ SequenceI seq2 = new Sequence("Seq2", "ASD---ASD------", 37, 42);
+ List<AlignmentAnnotation> 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<SequenceI, List<AlignmentAnnotation>> annotations3 = new HashMap<>();
+ // Empty annotation map
+
+ Map<SequenceI, List<AlignmentAnnotation>> annotations4 = new HashMap<>();
+ SequenceI seq4 = new Sequence("Seq4", "ASD---ASD---AS-", 37, 44);
+ List<AlignmentAnnotation> 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<String> actualSSSource = AlignmentUtils
+ .extractSSSourceInAlignmentAnnotation(annotations);
+ Assert.assertEquals(actualSSSource, expectedSSSource);
+ }
+
+ @DataProvider(name = "SSSourceFromAnnotationDescription")
+ public static Object[][] provideSSSourceFromAnnotationDescription()
+ {
+ Map<SequenceI, List<AlignmentAnnotation>> annotations1 = new HashMap<>();
+ SequenceI seq1 = new Sequence("Seq1", "ASD---ASD---ASD", 37, 45);
+ List<AlignmentAnnotation> annotationsList1 = new ArrayList<>();
+ annotationsList1.add(new AlignmentAnnotation("jnetpred", "JPred Output",
+ new Annotation[] {}));
+ annotations1.put(seq1, annotationsList1); // Annotation present from JPred
+ // for seq1
+
+ Map<SequenceI, List<AlignmentAnnotation>> annotations2 = new HashMap<>();
+ SequenceI seq2 = new Sequence("Seq2", "ASD---ASD------", 37, 42);
+ List<AlignmentAnnotation> 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<SequenceI, List<AlignmentAnnotation>> annotations3 = new HashMap<>();
+ // Empty annotation map
+
+ Map<SequenceI, List<AlignmentAnnotation>> annotations4 = new HashMap<>();
+ SequenceI seq4 = new Sequence("Seq4", "ASD---ASD---AS-", 37, 44);
+ List<AlignmentAnnotation> 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<SequenceI, List<AlignmentAnnotation>> annotations5 = new HashMap<>();
+ SequenceI seq5 = new Sequence("Seq5", "ASD---ASD---AS-", 37, 44);
+ List<AlignmentAnnotation> 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" } };
+ }
+
}