distinct methods for getting references to selected sequences or getting new seuqence...
authorjprocter <Jim Procter>
Mon, 23 Apr 2007 15:11:55 +0000 (15:11 +0000)
committerjprocter <Jim Procter>
Mon, 23 Apr 2007 15:11:55 +0000 (15:11 +0000)
src/jalview/gui/AlignViewport.java

index f1b7be3..88a6e37 100755 (executable)
@@ -1466,8 +1466,10 @@ public class AlignViewport
     }
 
     /**
-     * This method returns the a new SequenceI [] with
-     * the selection sequence and start and end points adjusted
+     * This method returns an array of new SequenceI objects 
+     * derived from the whole alignment or just the current
+     * selection with start and end points adjusted
+     * @note if you need references to the actual SequenceI objects in the alignment or currently selected then use getSequenceSelection()
      * @return String[]
      */
     public SequenceI[] getSelectionAsNewSequence()
@@ -1477,6 +1479,10 @@ public class AlignViewport
       if (selectionGroup == null)
     {
         sequences = alignment.getSequencesArray();
+        for (int i=0; i<sequences.length; i++)
+        {
+          sequences[i] = new Sequence(sequences[i]); // construct new sequence
+        }
     }
       else
     {
@@ -1485,7 +1491,23 @@ public class AlignViewport
 
       return sequences;
     }
-
+    /**
+     * get the currently selected sequence objects or all the sequences in the alignment.
+     * @return array of references to sequence objects
+     */
+    public SequenceI[] getSequenceSelection()
+    {
+      SequenceI[] sequences;
+      if (selectionGroup==null)
+      {
+        sequences = alignment.getSequencesArray();
+      }
+      else
+      {
+        sequences = selectionGroup.getSequencesInOrder(alignment);
+      }
+      return sequences;
+    }
     /**
      * This method returns the visible alignment as text, as
      * seen on the GUI, ie if columns are hidden they will not