Merge branch 'features/JAL-4071_visibleFeaturesCounter' into features/JAL-3417_sdppre...
[jalview.git] / src / jalview / datamodel / Alignment.java
index ac00fa2..f389ad8 100755 (executable)
@@ -21,6 +21,7 @@
 package jalview.datamodel;
 
 import jalview.analysis.AlignmentUtils;
+import jalview.analysis.Conservation;
 import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
 import jalview.io.FastaFile;
 import jalview.util.Comparison;
@@ -47,7 +48,7 @@ import java.util.Vector;
  * @author JimP
  * 
  */
-public class Alignment implements AlignmentI
+public class Alignment implements AlignmentI, AutoCloseable
 {
   private Alignment dataset;
 
@@ -71,6 +72,12 @@ public class Alignment implements AlignmentI
 
   private List<AlignedCodonFrame> codonFrameList;
 
+  private Conservation conservation;
+
+  private ProfilesI consensus;
+
+  private Hashtable[] codonConsensus, rnaStructureConsensus;
+
   private void initAlignment(SequenceI[] seqs)
   {
     groups = Collections.synchronizedList(new ArrayList<SequenceGroup>());
@@ -195,6 +202,7 @@ public class Alignment implements AlignmentI
   {
     synchronized (sequences)
     {
+
       if (i > -1 && i < sequences.size())
       {
         return sequences.get(i);
@@ -302,15 +310,20 @@ public class Alignment implements AlignmentI
   }
 
   @Override
-  public void finalize() throws Throwable
+  public void close()
   {
     if (getDataset() != null)
     {
-      getDataset().removeAlignmentRef();
+      try
+      {
+        getDataset().removeAlignmentRef();
+      } catch (Throwable e)
+      {
+        e.printStackTrace();
+      }
     }
 
     nullReferences();
-    super.finalize();
   }
 
   /**
@@ -589,11 +602,12 @@ public class Alignment implements AlignmentI
     int i = 0;
     SequenceI sq = null;
     String sqname = null;
+    int nseq = sequences.size();
     if (startAfter != null)
     {
       // try to find the sequence in the alignment
       boolean matched = false;
-      while (i < sequences.size())
+      while (i < nseq)
       {
         if (getSequenceAt(i++) == startAfter)
         {
@@ -606,7 +620,7 @@ public class Alignment implements AlignmentI
         i = 0;
       }
     }
-    while (i < sequences.size())
+    while (i < nseq)
     {
       sq = getSequenceAt(i);
       sqname = sq.getName();
@@ -709,7 +723,7 @@ public class Alignment implements AlignmentI
   public int getWidth()
   {
     int maxLength = -1;
-  
+
     for (int i = 0; i < sequences.size(); i++)
     {
       maxLength = Math.max(maxLength, getSequenceAt(i).getLength());
@@ -1188,7 +1202,8 @@ public class Alignment implements AlignmentI
     int maxLength = -1;
 
     SequenceI current;
-    for (int i = 0; i < sequences.size(); i++)
+    int nseq = sequences.size();
+    for (int i = 0; i < nseq; i++)
     {
       current = getSequenceAt(i);
       for (int j = current.getLength(); j > maxLength; j--)
@@ -1205,7 +1220,7 @@ public class Alignment implements AlignmentI
     maxLength++;
 
     int cLength;
-    for (int i = 0; i < sequences.size(); i++)
+    for (int i = 0; i < nseq; i++)
     {
       current = getSequenceAt(i);
       cLength = current.getLength();
@@ -2024,4 +2039,55 @@ public class Alignment implements AlignmentI
     }
   }
 
+  @Override
+  public Hashtable[] getComplementConsensusHash()
+  {
+    return codonConsensus;
+  }
+
+  @Override
+  public Conservation getConservation()
+  {
+    return conservation;
+  }
+
+  @Override
+  public Hashtable[] getRnaStructureConsensusHash()
+  {
+    return rnaStructureConsensus;
+  }
+
+  @Override
+  public ProfilesI getSequenceConsensusHash()
+  {
+    return consensus;
+  }
+
+  @Override
+  public void setComplementConsensusHash(Hashtable[] hconsensus)
+  {
+    codonConsensus = hconsensus;
+
+  }
+
+  @Override
+  public void setConservation(Conservation cons)
+  {
+    conservation = cons;
+
+  }
+
+  @Override
+  public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
+  {
+    rnaStructureConsensus = hStrucConsensus;
+
+  }
+
+  @Override
+  public void setSequenceConsensusHash(ProfilesI hconsensus)
+  {
+    consensus = hconsensus;
+
+  }
 }