From eb2477856cdeb2ec0e1f96457612d4fa972ad3c2 Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 2 May 2007 13:41:22 +0000 Subject: [PATCH] only return non-empty subsequences when getting selection as new sequences --- src/jalview/datamodel/SequenceGroup.java | 49 ++++++++++++++++++------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 47d56b7..18fb53b 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -93,34 +93,45 @@ public class SequenceGroup int iSize = sequences.size(); SequenceI[] seqs = new SequenceI[iSize]; SequenceI[] inorder = getSequencesInOrder(align); - - for (int i = 0; i < iSize; i++) + + for (int i = 0,ipos=0; i < inorder.length; i++) { SequenceI seq = inorder[i]; - seqs[i] = seq.getSubSequence(startRes, endRes+1); - - seqs[i].setDescription(seq.getDescription()); - seqs[i].setDBRef(seq.getDBRef()); - seqs[i].setSequenceFeatures(seq.getSequenceFeatures()); - if (seq.getDatasetSequence() != null) + seqs[ipos] = seq.getSubSequence(startRes, endRes+1); + if (seqs[ipos]!=null) { - seqs[i].setDatasetSequence(seq.getDatasetSequence()); - } + seqs[ipos].setDescription(seq.getDescription()); + seqs[ipos].setDBRef(seq.getDBRef()); + seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures()); + if (seq.getDatasetSequence() != null) + { + seqs[ipos].setDatasetSequence(seq.getDatasetSequence()); + } - if (seq.getAnnotation() != null) - { - for (int a = 0; a < seq.getAnnotation().length; a++) + if (seq.getAnnotation() != null) { - AlignmentAnnotation newannot = new AlignmentAnnotation(seq.getAnnotation()[a]); - newannot.restrict(startRes, endRes); - newannot.setSequenceRef(seqs[i]); - newannot.adjustForAlignment(); - seqs[i].addAlignmentAnnotation(newannot); + for (int a = 0; a < seq.getAnnotation().length; a++) + { + AlignmentAnnotation newannot = new AlignmentAnnotation(seq + .getAnnotation()[a]); + newannot.restrict(startRes, endRes); + newannot.setSequenceRef(seqs[ipos]); + newannot.adjustForAlignment(); + seqs[ipos].addAlignmentAnnotation(newannot); + } } + ipos++; + } else { + iSize--; } } - + if (iSize!=inorder.length) + { + SequenceI[] nseqs = new SequenceI[iSize]; + System.arraycopy(seqs, 0, nseqs, 0, iSize); + seqs = nseqs; + } return seqs; } -- 1.7.10.2