1 package jalview.datamodel;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertFalse;
5 import static org.junit.Assert.assertTrue;
6 import jalview.io.AppletFormatAdapter;
8 import java.io.IOException;
9 import java.util.Iterator;
11 import org.junit.Before;
12 import org.junit.Test;
15 * Unit tests for Alignment datamodel.
20 public class AlignmentTest
23 private static final String TEST_DATA =
25 "#=GS D.melanogaster.1 AC AY119185.1/838-902\n" +
26 "#=GS D.melanogaster.2 AC AC092237.1/57223-57161\n" +
27 "#=GS D.melanogaster.3 AC AY060611.1/560-627\n" +
28 "D.melanogaster.1 G.AGCC.CU...AUGAUCGA\n" +
29 "#=GR D.melanogaster.1 SS ................((((\n" +
30 "D.melanogaster.2 C.AUUCAACU.UAUGAGGAU\n" +
31 "#=GR D.melanogaster.2 SS ................((((\n" +
32 "D.melanogaster.3 G.UGGCGCU..UAUGACGCA\n" +
33 "#=GR D.melanogaster.3 SS (.(((...(....(((((((\n" +
41 * Read in Stockholm format test data including secondary structure
45 public void setUp() throws IOException
47 al = new jalview.io.FormatAdapter().readFile(TEST_DATA,
48 AppletFormatAdapter.PASTE, "STH");
49 for (int i = 0; i < al.getSequencesArray().length; ++i)
51 al.addAnnotation(al.getSequenceAt(i).getAnnotation()[0]);
52 al.getSequenceAt(i).getAnnotation()[0].setCalcId("CalcIdFor"
53 + al.getSequenceAt(i).getName());
58 * Test method that returns annotations that match on calcId.
61 public void testFindAnnotation_byCalcId()
63 Iterable<AlignmentAnnotation> anns = al
64 .findAnnotation("CalcIdForD.melanogaster.2");
65 Iterator<AlignmentAnnotation> iter = anns.iterator();
66 assertTrue(iter.hasNext());
67 AlignmentAnnotation ann = iter.next();
68 assertEquals("D.melanogaster.2", ann.sequenceRef.getName());
69 assertFalse(iter.hasNext());