X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignmentAnnotation.java;fp=src%2Fjalview%2Fdatamodel%2FAlignmentAnnotation.java;h=0098d760eabbcc12a13f43d8c7ab947a899ea2b8;hb=8c5cefb3ac80bd094a8dab7ce6735a11583b1772;hp=6c33c1b866861f0c8b4fe82c59e4894e442b8cfc;hpb=34b682702fe2dee7a5d79f95960a1accbea17ef6;p=jalview.git diff --git a/src/jalview/datamodel/AlignmentAnnotation.java b/src/jalview/datamodel/AlignmentAnnotation.java index 6c33c1b..0098d76 100755 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@ -1582,4 +1582,70 @@ public class AlignmentAnnotation } } + public static Iterable findAnnotations( + Iterable list, SequenceI seq, String calcId, + String label) + { + + ArrayList aa = new ArrayList<>(); + for (AlignmentAnnotation ann : list) + { + if ((calcId == null || (ann.getCalcId() != null + && ann.getCalcId().equals(calcId))) + && (seq == null || (ann.sequenceRef != null + && ann.sequenceRef == seq)) + && (label == null + || (ann.label != null && ann.label.equals(label)))) + { + aa.add(ann); + } + } + return aa; + } + + /** + * Answer true if any annotation matches the calcId passed in (if not null). + * + * @param list + * annotation to search + * @param calcId + * @return + */ + public static boolean hasAnnotation(List list, + String calcId) + { + + if (calcId != null && !"".equals(calcId)) + { + for (AlignmentAnnotation a : list) + { + if (a.getCalcId() == calcId) + { + return true; + } + } + } + return false; + } + + public static Iterable findAnnotation( + List list, String calcId) + { + + List aa = new ArrayList<>(); + if (calcId == null) + { + return aa; + } + for (AlignmentAnnotation a : list) + { + + if (a.getCalcId() == calcId || (a.getCalcId() != null + && calcId != null && a.getCalcId().equals(calcId))) + { + aa.add(a); + } + } + return aa; + } }