Merge branch 'feature/JAL-3187linkedFeatures' into feature/JAL-3251biotypedMappings
[jalview.git] / src / jalview / datamodel / Alignment.java
index 0f51b7e..5ad8be1 100755 (executable)
@@ -21,7 +21,6 @@
 package jalview.datamodel;
 
 import jalview.analysis.AlignmentUtils;
-import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
 import jalview.io.FastaFile;
 import jalview.util.Comparison;
 import jalview.util.LinkedIdentityHashSet;
@@ -47,7 +46,7 @@ import java.util.Vector;
  * @author JimP
  * 
  */
-public class Alignment implements AlignmentI
+public class Alignment implements AlignmentI, AutoCloseable
 {
   private Alignment dataset;
 
@@ -302,15 +301,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();
   }
 
   /**
@@ -712,12 +716,8 @@ public class Alignment implements AlignmentI
   
     for (int i = 0; i < sequences.size(); i++)
     {
-      if (getSequenceAt(i).getLength() > maxLength)
-      {
-        maxLength = getSequenceAt(i).getLength();
-      }
+      maxLength = Math.max(maxLength, getSequenceAt(i).getLength());
     }
-  
     return maxLength;
   }
 
@@ -1145,7 +1145,7 @@ public class Alignment implements AlignmentI
     // verify all mappings are in dataset
     for (AlignedCodonFrame cf : codonFrameList)
     {
-      for (SequenceToSequenceMapping ssm : cf.getMappings())
+      for (SequenceMapping ssm : cf.getMappings())
       {
         if (!seqs.contains(ssm.getFromSeq()))
         {