From: James Procter Date: Mon, 20 Mar 2023 15:23:38 +0000 (+0000) Subject: JAL-2349 fix off by one when resolving columns for sequence associated contact matrix X-Git-Tag: Release_2_11_3_0~15^2^2~11 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a3125b0190d8f97ea9543006686d5fe4b8247ff2;p=jalview.git JAL-2349 fix off by one when resolving columns for sequence associated contact matrix --- diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 321eee3..517a6dd 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -2080,10 +2080,10 @@ public class Alignment implements AlignmentI, AutoCloseable if (spos >= _aa.sequenceRef.getStart() && spos <= 1 + _aa.sequenceRef.getEnd()) { - cl = _aa.sequenceRef.getContactListFor(_aa, spos); + cl = _aa.sequenceRef.getContactListFor(_aa, spos-_aa.sequenceRef.getStart()); if (cl == null && _aa.sequenceRef.getDatasetSequence() != null) { - _aa.sequenceRef.getDatasetSequence().getContactListFor(_aa, spos); + _aa.sequenceRef.getDatasetSequence().getContactListFor(_aa, spos-_aa.sequenceRef.getStart()); } } } diff --git a/src/jalview/datamodel/ContactMapHolderI.java b/src/jalview/datamodel/ContactMapHolderI.java index ba23e67..342abf8 100644 --- a/src/jalview/datamodel/ContactMapHolderI.java +++ b/src/jalview/datamodel/ContactMapHolderI.java @@ -6,10 +6,13 @@ public interface ContactMapHolderI { /** * resolve a contact list instance (if any) associated with the annotation row - * and column position + * and column position Columns of ContactMap are indexed relative to context + * object (columns of alignment, positions on sequence relative to + * sequence.getStart()) * * @param _aa * @param column + * - base 0 column index * @return */ ContactListI getContactListFor(AlignmentAnnotation _aa, int column); diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 1193c39..4baa384 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -2630,6 +2630,11 @@ public class AlignmentUtilsTests assertNotNull( "No contact matrix recovered after reference annotation transfer", cl); + // semantics of sequence associated contact list is slightly tricky - column 3 in alignment should have data + cl = al.getContactListFor(alan, 3); + assertNotNull( + "Contact matrix should have data for last position in sequence", + cl); ContactMatrixI cm2 = new SeqDistanceContactMatrix(4); dssq.addContactList(cm2);