From a3a196ed2104760ffeeebbca65fc03c361d29b17 Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 3 Aug 2009 16:38:09 +0000 Subject: [PATCH] fix feature creation for selected region beyond end of sequence bug: https://mantis.lifesci.dundee.ac.uk/view.php?id=53503 --- src/jalview/appletgui/APopupMenu.java | 23 ++++++++++++++++------- src/jalview/gui/PopupMenu.java | 24 ++++++++++++++++-------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 6a177b5..0226349 100755 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -556,19 +556,28 @@ public class APopupMenu extends java.awt.PopupMenu implements { return; } - - int gSize = sg.getSize(); - SequenceI[] seqs = new SequenceI[gSize]; - SequenceFeature[] features = new SequenceFeature[gSize]; - + int rsize=0,gSize = sg.getSize(); + SequenceI[] rseqs,seqs = new SequenceI[gSize]; + SequenceFeature[] tfeatures,features = new SequenceFeature[gSize]; + for (int i = 0; i < gSize; i++) { - seqs[i] = sg.getSequenceAt(i); int start = sg.getSequenceAt(i).findPosition(sg.getStartRes()); int end = sg.findEndRes(sg.getSequenceAt(i)); - features[i] = new SequenceFeature(null, null, null, start, end, + if (start<=end) + { + seqs[rsize] = sg.getSequenceAt(i); + features[rsize] = new SequenceFeature(null, null, null, start, end, "Jalview"); + rsize++; + } } + rseqs = new SequenceI[rsize]; + tfeatures = new SequenceFeature[rsize]; + System.arraycopy(seqs,0,rseqs, 0, rsize); + System.arraycopy(features, 0, tfeatures, 0, rsize); + features = tfeatures; + seqs = rseqs; if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs, features, true, ap)) diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index a1a8715..bd55d50 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -1532,20 +1532,28 @@ public class PopupMenu extends JPopupMenu { return; } - - int gSize = sg.getSize(); - SequenceI[] seqs = new SequenceI[gSize]; - SequenceFeature[] features = new SequenceFeature[gSize]; - + int rsize=0,gSize = sg.getSize(); + SequenceI[] rseqs,seqs = new SequenceI[gSize]; + SequenceFeature[] tfeatures,features = new SequenceFeature[gSize]; + for (int i = 0; i < gSize; i++) { - seqs[i] = sg.getSequenceAt(i).getDatasetSequence(); int start = sg.getSequenceAt(i).findPosition(sg.getStartRes()); int end = sg.findEndRes(sg.getSequenceAt(i)); - features[i] = new SequenceFeature(null, null, null, start, end, + if (start<=end) + { + seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence(); + features[rsize] = new SequenceFeature(null, null, null, start, end, "Jalview"); + rsize++; + } } - + rseqs = new SequenceI[rsize]; + tfeatures = new SequenceFeature[rsize]; + System.arraycopy(seqs,0,rseqs, 0, rsize); + System.arraycopy(features, 0, tfeatures, 0, rsize); + features = tfeatures; + seqs = rseqs; if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs, features, true, ap)) { -- 1.7.10.2