import jalview.util.MapList;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
// third found.. so
assertFalse(iter.hasNext());
+ // search for annotation on one sequence with a particular label - expect
+ // one
+ SequenceI sqfound;
+ anns = al.findAnnotations(sqfound = al.getSequenceAt(1), null,
+ "Secondary Structure");
+ iter = anns.iterator();
+ assertTrue(iter.hasNext());
+ // expect reference to sequence 1 in the alignment
+ assertTrue(sqfound == iter.next().sequenceRef);
+ assertFalse(iter.hasNext());
+
// null on all parameters == find all annotations
anns = al.findAnnotations(null, null, null);
iter = anns.iterator();
"addSequence broke dataset reference integrity");
}
- @Test(groups = "Functional")
- public void getVisibleStartAndEndIndexTest()
- {
- Sequence seq = new Sequence("testSeq", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
- AlignmentI align = new Alignment(new SequenceI[] { seq });
- ArrayList<int[]> hiddenCols = new ArrayList<int[]>();
-
- int[] startEnd = align.getVisibleStartAndEndIndex(hiddenCols);
- assertEquals(0, startEnd[0]);
- assertEquals(25, startEnd[1]);
-
- hiddenCols.add(new int[] { 0, 0 });
- startEnd = align.getVisibleStartAndEndIndex(hiddenCols);
- assertEquals(1, startEnd[0]);
- assertEquals(25, startEnd[1]);
-
- hiddenCols.add(new int[] { 6, 9 });
- hiddenCols.add(new int[] { 11, 12 });
- startEnd = align.getVisibleStartAndEndIndex(hiddenCols);
- assertEquals(1, startEnd[0]);
- assertEquals(25, startEnd[1]);
-
- hiddenCols.add(new int[] { 24, 25 });
- startEnd = align.getVisibleStartAndEndIndex(hiddenCols);
- System.out.println(startEnd[0] + " : " + startEnd[1]);
- assertEquals(1, startEnd[0]);
- assertEquals(23, startEnd[1]);
- }
-
/**
* Tests that dbrefs with mappings to sequence get updated if the sequence
* acquires a dataset sequence
// todo test coverage for annotations, mappings, groups,
// hidden sequences, properties
}
+
+ /**
+ * test that calcId == null on findOrCreate doesn't raise an NPE, and yields
+ * an annotation with a null calcId
+ *
+ */
+ @Test(groups = "Functional")
+ public void testFindOrCreateForNullCalcId()
+ {
+ SequenceI seq = new Sequence("seq1", "FRMLPSRT-A--L-");
+ AlignmentI alignment = new Alignment(new SequenceI[] { seq });
+
+ AlignmentAnnotation ala = alignment.findOrCreateAnnotation(
+ "Temperature Factor", null, false, seq, null);
+ assertNotNull(ala);
+ assertEquals(seq, ala.sequenceRef);
+ assertEquals("", ala.calcId);
+ }
}