tidied up system.out messages and moved many to stderr.
[jalview.git] / src / jalview / datamodel / Alignment.java
index 86d2c0e..d953598 100755 (executable)
@@ -11,8 +11,11 @@ public class Alignment implements AlignmentI
 \r
   protected Vector      sequences;\r
   protected Vector      groups = new Vector();\r
-  protected ArrayList   superGroup = new ArrayList();\r
+  protected Vector   superGroup = new Vector();\r
   protected char        gapCharacter = '-';\r
+  public AlignmentAnnotation [] annotations;\r
+\r
+  public boolean featuresAdded = false;\r
 \r
   /** Make an alignment from an array of Sequences.\r
   *\r
@@ -288,10 +291,10 @@ public class Alignment implements AlignmentI
       len = getHeight()/2;\r
     } else {\r
       len = (getHeight()+1)/2;\r
-      System.out.println("Sort len is odd = " + len);\r
+      System.out.println("DEBUG:Sort len is odd = " + len); // log.\r
     }\r
     for (int i = 0; i < len; i++) {\r
-      System.out.println("Swapping " + seqs[i].getName() + " and " + seqs[getHeight()-i-1].getName());\r
+      System.out.println("DEBUG:Swapping " + seqs[i].getName() + " and " + seqs[getHeight()-i-1].getName()); // log.\r
       SequenceI tmp = seqs[i];\r
       sequences.setElementAt(seqs[getHeight()-i-1],i);\r
       sequences.setElementAt(tmp,getHeight()-i-1);\r
@@ -318,18 +321,19 @@ public class Alignment implements AlignmentI
   public SequenceGroup [] findAllGroups(SequenceI s)\r
   {\r
 \r
-    ArrayList temp = new ArrayList();\r
+    Vector temp = new Vector();\r
 \r
     for (int i = 0; i < this.groups.size();i++)\r
     {\r
       SequenceGroup sg = (SequenceGroup)groups.elementAt(i);\r
 \r
       if (sg.sequences.contains(s))\r
-       temp.add(sg);\r
+       temp.addElement(sg);\r
     }\r
 \r
     SequenceGroup [] ret = new SequenceGroup[temp.size()];\r
-    temp.toArray( ret );\r
+    for(int i=0; i<temp.size(); i++)\r
+      ret[i] = (SequenceGroup)temp.elementAt(i);\r
 \r
     return ret;\r
 \r
@@ -354,19 +358,19 @@ public class Alignment implements AlignmentI
 \r
   public void addSuperGroup(SuperGroup sg)\r
   {\r
-    superGroup.add(sg);\r
+    superGroup.addElement(sg);\r
   }\r
 \r
   public void removeSuperGroup(SuperGroup sg)\r
   {\r
-    superGroup.remove(sg);\r
+    superGroup.removeElement(sg);\r
   }\r
 \r
   public SuperGroup     getSuperGroup(SequenceGroup sg)\r
   {\r
     for (int i = 0; i < this.superGroup.size(); i++)\r
     {\r
-      SuperGroup temp = (SuperGroup) superGroup.get(i);\r
+      SuperGroup temp = (SuperGroup) superGroup.elementAt(i);\r
       if (temp.sequenceGroups.contains(sg))\r
         return temp;\r
     }\r
@@ -381,8 +385,8 @@ public class Alignment implements AlignmentI
 \r
   public void deleteAllGroups()\r
   {\r
-    groups.clear();\r
-    superGroup.clear();\r
+    groups.removeAllElements();\r
+    superGroup.removeAllElements();\r
    int i=0;\r
     while (i < sequences.size()) {\r
      SequenceI s = getSequenceAt(i);\r
@@ -477,12 +481,12 @@ public class Alignment implements AlignmentI
 \r
   public void setGapCharacter(char gc)\r
   {\r
-    char old = getGapCharacter();\r
     gapCharacter = gc;\r
     for (int i=0; i < sequences.size(); i++)\r
      {\r
        Sequence seq = (Sequence)sequences.elementAt(i);\r
-       seq.sequence = seq.sequence.replace(old, gc);\r
+       seq.sequence = seq.sequence.replace('.', gc);\r
+       seq.sequence = seq.sequence.replace('-', gc);\r
      }\r
   }\r
 \r
@@ -503,8 +507,52 @@ public class Alignment implements AlignmentI
         return false;\r
 \r
     return true;\r
+  }\r
+\r
+   public void deleteAnnotation(AlignmentAnnotation aa)\r
+   {\r
+     int aSize = 1;\r
+     if(annotations!=null)\r
+       aSize = annotations.length;\r
+\r
+     AlignmentAnnotation [] temp = new AlignmentAnnotation [aSize-1];\r
+\r
+     int tIndex = 0;\r
+     for (int i = 0; i < aSize; i++)\r
+      {\r
+        if(annotations[i]==aa)\r
+          continue;\r
+\r
+\r
+        temp[tIndex] = annotations[i];\r
+        tIndex++;\r
+      }\r
+\r
+     annotations = temp;\r
 \r
+   }\r
+\r
+  public void addAnnotation(AlignmentAnnotation aa)\r
+  {\r
+    int aSize = 1;\r
+    if(annotations!=null)\r
+      aSize = annotations.length+1;\r
+\r
+    AlignmentAnnotation [] temp = new AlignmentAnnotation [aSize];\r
+    int i=0;\r
+    if (aSize > 1)\r
+      for (i = 0; i < aSize-1; i++)\r
+        temp[i] = annotations[i];\r
+\r
+    temp[i] = aa;\r
+\r
+    annotations = temp;\r
   }\r
+  public AlignmentAnnotation[] getAlignmentAnnotation()\r
+  {\r
+    return annotations;\r
+  }\r
+\r
 }\r
 \r
 \r