X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=aef203817de8246f177dfd4f77eb86d229956981;hb=ca160187a050f6d4e50158cd5b51f75c83a7179e;hp=e1c87a921394049e99a09388412fcf52a7aa84fd;hpb=0eda79421bb03c19e3b74c4b83b1644ca12ea66c;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index e1c87a9..aef2038 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -1653,8 +1653,10 @@ public class Alignment implements AlignmentI, AutoCloseable public Iterable findAnnotations(SequenceI seq, String calcId, String label) { - return AlignmentAnnotation.findAnnotations( - Arrays.asList(getAlignmentAnnotation()), seq, calcId, label); + return annotations == null ? null + : AlignmentAnnotation.findAnnotations( + Arrays.asList(getAlignmentAnnotation()), seq, calcId, + label); } @Override @@ -2045,9 +2047,56 @@ public class Alignment implements AlignmentI, AutoCloseable } @Override + public ContactMatrixI getContactMatrixFor(AlignmentAnnotation _aa) + { + ContactMatrixI cm = cmholder.getContactMatrixFor(_aa); + if (cm == null && _aa.groupRef != null) + { + cm = _aa.groupRef.getContactMatrixFor(_aa); + } + if (cm == null && _aa.sequenceRef != null) + { + cm = _aa.sequenceRef.getContactMatrixFor(_aa); + if (cm == null) + { + // TODO fix up this logic and unify with getContactListFor + cm = _aa.sequenceRef.getDatasetSequence().getContactMatrixFor(_aa); + } + } + return cm; + } + + @Override public ContactListI getContactListFor(AlignmentAnnotation _aa, int column) { - return cmholder.getContactListFor(_aa, column); + if (_aa.annotations==null || column>=_aa.annotations.length || column<0) + { + return null; + } + ContactListI cl = cmholder.getContactListFor(_aa, column); + if (cl == null && _aa.groupRef != null) + { + cl = _aa.groupRef.getContactListFor(_aa, column); + } + if (cl == null && _aa.sequenceRef != null) + { + if (_aa.annotations[column] != null) + { + // sequence associated + cl = _aa.sequenceRef.getContactListFor(_aa, column); + if (cl == null && _aa.sequenceRef.getDatasetSequence() != null) + { + int spos = _aa.sequenceRef.findPosition(column); + if (spos >= _aa.sequenceRef.getStart() + && spos <= 1 + _aa.sequenceRef.getEnd()) + { + cl = _aa.sequenceRef.getDatasetSequence().getContactListFor(_aa, + spos - _aa.sequenceRef.getStart()); + } + } + } + } + return cl; } @Override @@ -2056,8 +2105,7 @@ public class Alignment implements AlignmentI, AutoCloseable AlignmentAnnotation aa = cmholder.addContactList(cm); Annotation _aa[] = new Annotation[getWidth()]; - Annotation dummy = new Annotation(0.0f); - for (int i = 0; i < _aa.length; _aa[i++] = dummy) + for (int i = 0; i < _aa.length; _aa[i++] = new Annotation(0.0f)) { ; } @@ -2065,4 +2113,12 @@ public class Alignment implements AlignmentI, AutoCloseable addAnnotation(aa); return aa; } + + @Override + public void addContactListFor(AlignmentAnnotation annotation, + ContactMatrixI cm) + { + cmholder.addContactListFor(annotation, cm); + + } }