Merge branch 'test_paolo_JAL-1065' into Tcoffee_JAL-1065
[jalview.git] / src / jalview / gui / AlignFrame.java
index 2ba0d59..221d52c 100755 (executable)
@@ -1014,7 +1014,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);
 
@@ -3065,7 +3065,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         {
           try
           {
-            sg.cs = (ColourSchemeI) cs.getClass().newInstance();
+            sg.cs = cs.getClass().newInstance();
           } catch (Exception ex)
           {
           }
@@ -3881,9 +3881,20 @@ 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"); }
-
-                 // TODO check that the loaded scores matches the current MSA 'dimension'
+                 if( result == null ) { 
+                      // TODO: raise a dialog box here rather than bomb out.
+                 
+                         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()) ) {
+                     // TODO: raise a dialog box here rather than bomb out.
+                   throw new RuntimeException("The scores matrix does not match the alignment dimensions");
+                 }
                  if (result.annotateAlignment(alignPanel.getAlignment(), true))
                  {
                          tcoffeeColour.setEnabled(true);