From f83b6877ab7ff3fc5db5c946e16c74e016437311 Mon Sep 17 00:00:00 2001 From: James Procter Date: Wed, 15 Mar 2023 17:28:43 +0000 Subject: [PATCH] =?utf8?q?JAL-4091=20JAL-629=20=E2=80=98Add=20Reference=20An?= =?utf8?q?notations=E2=80=99=20takes=20description=20into=20account=20when=20?= =?utf8?q?looking=20for=20potential=20addees=20-=20reverts=20change=20in=208?= =?utf8?q?fce85002e6f6a5957dc95662c6a3d80fcce8e82=20so=20PAEContactMatrix=20?= =?utf8?q?annotation=20labels=20are=20consistent.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/analysis/AlignmentUtils.java | 14 ++++++++++++-- .../ws/datamodel/alphafold/PAEContactMatrix.java | 10 +++++----- test/jalview/analysis/AlignmentUtilsTests.java | 16 ++++++++++++++-- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 42c4b76..0906872 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -1471,9 +1471,19 @@ public class AlignmentUtils */ final Iterable matchedAlignmentAnnotations = al .findAnnotations(seq, dsann.getCalcId(), dsann.label); - if (matchedAlignmentAnnotations == null - || !matchedAlignmentAnnotations.iterator().hasNext()) + boolean found=false; + if (matchedAlignmentAnnotations != null) { + for (AlignmentAnnotation matched:matchedAlignmentAnnotations) + { + if (dsann.description.equals(matched.description)) + { + found=true; + break; + } + } + } + if (!found) { result.add(dsann); if (labelForCalcId != null) { diff --git a/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java b/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java index 87ccab6..3ce1c83 100644 --- a/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java +++ b/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java @@ -222,17 +222,17 @@ public class PAEContactMatrix implements ContactMatrixI @Override public String getAnnotDescr() { - return "Predicted Alignment Error for " + refSeq.getName(); + return "Predicted Alignment Error"+((refSeq==null) ? "" : (" for " + refSeq.getName())); } @Override public String getAnnotLabel() { StringBuilder label = new StringBuilder("PAE Matrix"); - if (this.getReferenceSeq() != null) - { - label.append(":").append(this.getReferenceSeq().getDisplayId(false)); - } + //if (this.getReferenceSeq() != null) + //{ + // label.append(":").append(this.getReferenceSeq().getDisplayId(false)); + //} return label.toString(); } diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 8b6f67d..1193c39 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -2608,15 +2608,15 @@ public class AlignmentUtilsTests SequenceI sq = new Sequence("a", "SSSQ"); ContactMatrixI cm = new SeqDistanceContactMatrix(4); AlignmentAnnotation cm_aan = sq.addContactList(cm); + cm_aan.description = cm_aan.description + " cm1"; SequenceI dssq = sq.createDatasetSequence(); - Alignment ds = new Alignment(new SequenceI[] { dssq }); // remove annotation on our non-dataset sequence sq.removeAlignmentAnnotation(sq.getAnnotation()[0]); // test transfer Alignment al = new Alignment(new SequenceI[] { sq }); SortedMap tipEntries = new TreeMap<>(); - final Map> candidates = new LinkedHashMap<>(); + Map> candidates = new LinkedHashMap<>(); AlignmentUtils.findAddableReferenceAnnotations(al.getSequences(), tipEntries, candidates, al); @@ -2631,5 +2631,17 @@ public class AlignmentUtilsTests "No contact matrix recovered after reference annotation transfer", cl); + ContactMatrixI cm2 = new SeqDistanceContactMatrix(4); + dssq.addContactList(cm2); + tipEntries = new TreeMap<>(); + candidates = new LinkedHashMap<>(); + + AlignmentUtils.findAddableReferenceAnnotations(al.getSequences(), + tipEntries, candidates, al); + AlignmentUtils.addReferenceAnnotations(candidates, al, null); + assertTrue("Expected two contact map annotation transferred", + al.getAlignmentAnnotation() != null + && al.getAlignmentAnnotation().length == 2); + } } -- 1.7.10.2