JAL-1065 + JAL-1066 + JAL-1067 - Added T-Coffee score size constraints
[jalview.git] / src / jalview / gui / AlignFrame.java
index b3e34fb..3ba7319 100755 (executable)
@@ -1016,7 +1016,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       }
       FormatAdapter f = new FormatAdapter();
       String output = f.formatSequences(format,
-              (Alignment) viewport.alignment, // class cast exceptions will
+              viewport.alignment, // class cast exceptions will
               // occur in the distant future
               omitHidden, f.getCacheSuffixDefault(format), viewport.colSel);
 
@@ -3067,7 +3067,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         {
           try
           {
-            sg.cs = (ColourSchemeI) cs.getClass().newInstance();
+            sg.cs = cs.getClass().newInstance();
           } catch (Exception ex)
           {
           }
@@ -3883,9 +3883,18 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
              try 
              {
                  TCoffeeScoreFile result = TCoffeeScoreFile.load(new File(sFilePath));
-                 if( result == null ) { throw new RuntimeException("The file provided does not match the T-Coffee scores file format"); }
+                 if( result == null ) { 
+                         throw new RuntimeException("The file provided does not match the T-Coffee scores file format"); 
+                 }
+
+                 /*
+                  * check that the score matrix matches the alignment dimensions
+                  */
+                 AlignmentI aln; 
+                 if( (aln=viewport.alignment) != null && (aln.getHeight() != result.getHeight() || aln.getWidth() != result.getWidth()) ) {
+                         throw new RuntimeException("The scores matrix does not match the alignment dimensions");
+                 }
 
-                 // TODO check that the loaded scores matches the current MSA 'dimension'
                  changeColour( new TCoffeeColourScheme(result) );
                  tcoffeeScoreFile = result;
                  tcoffeeColour.setEnabled(true);