Sequence is char []
[jalview.git] / src / jalview / datamodel / Alignment.java
index cb73d0c..b5f31bc 100755 (executable)
@@ -137,7 +137,7 @@ public class Alignment implements AlignmentI
         {
           Sequence ds = new Sequence(snew.getName(),
                                      AlignSeq.extractGaps("-. ",
-              snew.getSequence()),
+              snew.getSequenceAsString()),
                                      snew.getStart(),
                                      snew.getEnd());
 
@@ -259,7 +259,26 @@ public class Alignment implements AlignmentI
     {
         if (!groups.contains(sg))
         {
-            groups.addElement(sg);
+          if(hiddenSequences.getSize()>0)
+          {
+            //We're not going to make groups of
+            //Hidden sequences
+            int i, iSize = sg.getSize(false);
+            for (i = 0; i < iSize; i++)
+            {
+              if (!sequences.contains(sg.getSequenceAt(i)))
+              {
+                sg.deleteSequence(sg.getSequenceAt(i), false);
+                iSize--;
+                i--;
+              }
+            }
+
+            if (sg.getSize(true) < 1)
+              return;
+          }
+
+          groups.addElement(sg);
         }
     }
 
@@ -269,15 +288,6 @@ public class Alignment implements AlignmentI
     public void deleteAllGroups()
     {
         groups.removeAllElements();
-
-        int i = 0;
-
-        while (i < sequences.size())
-        {
-            SequenceI s = getSequenceAt(i);
-            s.setColor(java.awt.Color.white);
-            i++;
-        }
     }
 
     /**    */
@@ -391,9 +401,9 @@ public class Alignment implements AlignmentI
         for (int i = 0; i < sequences.size(); i++)
         {
             Sequence seq = (Sequence) sequences.elementAt(i);
-            seq.setSequence( seq.getSequence().replace('.', gc) );
-            seq.setSequence( seq.getSequence().replace('-', gc) );
-            seq.setSequence( seq.getSequence().replace(' ', gc) );
+            seq.setSequence( seq.getSequenceAsString().replace('.', gc) );
+            seq.setSequence( seq.getSequenceAsString().replace('-', gc) );
+            seq.setSequence( seq.getSequenceAsString().replace(' ', gc) );
         }
     }
 
@@ -442,6 +452,9 @@ public class Alignment implements AlignmentI
             aSize = annotations.length;
         }
 
+        if(aSize<1)
+          return;
+
         AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize - 1];
 
         int tIndex = 0;
@@ -563,22 +576,25 @@ public class Alignment implements AlignmentI
         // Can only be done once, if dataset is not null
         // This will not be performed
         Sequence[] seqs = new Sequence[getHeight()];
+        SequenceI currentSeq;
         for (int i = 0; i < getHeight(); i++)
         {
-          if(getSequenceAt(i).getDatasetSequence()!=null)
+          currentSeq = getSequenceAt(i);
+          if(currentSeq.getDatasetSequence()!=null)
           {
-            seqs[i] = (Sequence)getSequenceAt(i).getDatasetSequence();
+            seqs[i] = (Sequence)currentSeq.getDatasetSequence();
           }
           else
           {
-            seqs[i] = new Sequence(getSequenceAt(i).getName(),
+            seqs[i] = new Sequence(currentSeq.getName(),
                                    AlignSeq.extractGaps(
                                        jalview.util.Comparison.GapChars,
-                                       getSequenceAt(i).getSequence()
+                                       currentSeq.getSequenceAsString()
                                    ),
-                                   getSequenceAt(i).getStart(),
-                                   getSequenceAt(i).getEnd());
-            seqs[i].sequenceFeatures = getSequenceAt(i).getSequenceFeatures();
+                                   currentSeq.getStart(),
+                                   currentSeq.getEnd());
+            seqs[i].sequenceFeatures = currentSeq.getSequenceFeatures();
+            seqs[i].setDescription(currentSeq.getDescription());
             getSequenceAt(i).setSequenceFeatures(null);
             getSequenceAt(i).setDatasetSequence(seqs[i]);
           }
@@ -597,7 +613,8 @@ public class Alignment implements AlignmentI
       return dataset;
     }
 
-    public boolean padGaps() {
+    public boolean padGaps()
+    {
       boolean modified=false;
 
       //Remove excess gaps from the end of alignment
@@ -620,14 +637,17 @@ public class Alignment implements AlignmentI
 
       maxLength++;
 
+      int cLength;
       for (int i = 0; i < sequences.size();
            i++)
       {
         current = getSequenceAt(i);
+        cLength = current.getLength();
 
-        if (current.getLength() < maxLength)
+        if (cLength < maxLength)
         {
-          current.insertCharAt(maxLength - 1, gapCharacter);
+          current.insertCharAt(cLength,
+                              maxLength-cLength, gapCharacter);
           modified=true;
         }
         else if(current.getLength() > maxLength)