*/
AlignmentAnnotation[] getAlignmentAnnotation();
+ /**
+ * Returns a list of annotations matching the given calc id, or an empty list
+ * if calcId is null
+ *
+ * @param calcId
+ * @return
+ */
Iterable<AlignmentAnnotation> findAnnotation(String calcId);
Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
@Override
public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
{
- ArrayList<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
+ List<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
+ if (calcId == null)
+ {
+ return aa;
+ }
for (AlignmentAnnotation a : getAlignmentAnnotation())
{
- if (a.getCalcId() == calcId)
+ if (calcId.equals(a.getCalcId()))
{
aa.add(a);
}
AlignmentAnnotation ann = iter.next();
assertEquals("D.melanogaster.2", ann.sequenceRef.getName());
assertFalse(iter.hasNext());
+
+ // invalid id
+ anns = al.findAnnotation("CalcIdForD.melanogaster.?");
+ assertFalse(iter.hasNext());
+ anns = al.findAnnotation(null);
+ assertFalse(iter.hasNext());
}
@Test(groups = { "Functional" })