X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPopupMenu.java;h=c2bee834e169f2f0d3aa0207d41ac846156fc210;hb=4935082f08648ab92743e14e5e2dfefa3e0dcd4d;hp=997647116aec7b48c31271e18883281acb36c049;hpb=91e9ddff22dd9406d8784b8a91f03d7b94b4a180;p=jalview.git diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 9976471..c2bee83 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -27,6 +27,7 @@ import jalview.commands.ChangeCaseCommand; import jalview.commands.EditCommand; import jalview.commands.EditCommand.Action; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; import jalview.datamodel.DBRefEntry; import jalview.datamodel.PDBEntry; @@ -1765,12 +1766,13 @@ public class PopupMenu extends JPopupMenu /** * Check for any annotations on the underlying dataset sequences (for the - * current selection group) which are not on the alignment annotations for the - * sequence. If any are found, enable the option to add them to the alignment. - * The criteria for 'on the alignment' is finding an alignment annotation on - * the sequence, that matches on calcId and label. A tooltip is also - * constructed that displays the source (calcId) and type (label) of the - * annotations that can be added. + * current selection group) which are not 'on the alignment'.If any are found, + * enable the option to add them to the alignment. The criteria for 'on the + * alignment' is finding an alignment annotation on the alignment, matched on + * calcId, label and sequenceRef. + * + * A tooltip is also constructed that displays the source (calcId) and type + * (label) of the annotations that can be added. * * @param menuItem * @param forSequences @@ -1797,10 +1799,11 @@ public class PopupMenu extends JPopupMenu /* * For each sequence selected in the alignment, make a list of any * annotations on the underlying dataset sequence which are not already on - * the sequence in the alignment. + * the alignment. * * Build a map of { alignmentSequence, } */ + AlignmentI al = this.ap.av.getAlignment(); final Map> candidates = new LinkedHashMap>(); for (SequenceI seq : forSequences) { @@ -1818,11 +1821,12 @@ public class PopupMenu extends JPopupMenu for (AlignmentAnnotation dsann : datasetAnnotations) { /* - * If the sequence has no annotation that matches this one, then add - * this one to the results list. + * Find matching annotations on the alignment. */ - if (seq.getAlignmentAnnotations(dsann.getCalcId(), dsann.label) - .isEmpty()) + final Iterable matchedAlignmentAnnotations = al + .findAnnotations(seq, dsann.getCalcId(), + dsann.label); + if (!matchedAlignmentAnnotations.iterator().hasNext()) { result.add(dsann); tipEntries.put(dsann.getCalcId(), dsann.label); @@ -1891,8 +1895,14 @@ public class PopupMenu extends JPopupMenu } copyAnn.restrict(startRes, endRes); - // add to the sequence (sets copyAnn.datasetSequence) - seq.addAlignmentAnnotation(copyAnn); + /* + * Add to the sequence (sets copyAnn.datasetSequence), unless the + * original annotation is already on the sequence. + */ + if (!seq.hasAnnotation(ann)) + { + seq.addAlignmentAnnotation(copyAnn); + } // adjust for gaps copyAnn.adjustForAlignment(); // add to the alignment and set visible