From cd886ae669962ea7fff5fb46627b3f84e77d295d Mon Sep 17 00:00:00 2001 From: James Procter Date: Fri, 7 Jul 2023 14:42:20 +0100 Subject: [PATCH] JAL-4221 update description when transferring annotation and no description already set --- src/jalview/datamodel/Sequence.java | 7 +++++++ test/jalview/datamodel/SequenceTest.java | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 32d295a..5bb55e5 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -1754,6 +1754,13 @@ public class Sequence extends ASequence implements SequenceI transferAnnotation(entry.getDatasetSequence(), mp); return; } + // transfer from entry to sequence + // if entry has a description and sequence doesn't, then transfer + if (entry.getDescription()!=null && (description==null || description.trim().length()==0)) + { + description = entry.getDescription(); + } + // transfer any new features from entry onto sequence if (entry.getSequenceFeatures() != null) { diff --git a/test/jalview/datamodel/SequenceTest.java b/test/jalview/datamodel/SequenceTest.java index 344d74d..7bbb9f3 100644 --- a/test/jalview/datamodel/SequenceTest.java +++ b/test/jalview/datamodel/SequenceTest.java @@ -2315,8 +2315,16 @@ public class SequenceTest { Sequence origSeq = new Sequence("MYSEQ", "THISISASEQ"); Sequence toSeq = new Sequence("MYSEQ", "THISISASEQ"); + origSeq.setDescription("DESCRIPTION"); origSeq.addDBRef(new DBRefEntry("UNIPROT", "0", "Q12345", null, true)); + + toSeq.transferAnnotation(origSeq, null); + assertEquals("DESCRIPTION",toSeq.getDescription()); + toSeq = new Sequence("MYSEQ", "THISISASEQ"); + toSeq.setDescription("unchanged"); toSeq.transferAnnotation(origSeq, null); + assertEquals("unchanged",toSeq.getDescription()); + assertTrue(toSeq.getDBRefs().size() == 1); assertTrue(toSeq.getDBRefs().get(0).isCanonical()); -- 1.7.10.2