bug fix for Features/Annotations file parameter parsing in JalviewLite reported and...
[jalview.git] / src / jalview / io / AppletFormatAdapter.java
index b37c60e..c7b0575 100755 (executable)
@@ -113,10 +113,21 @@ public class AppletFormatAdapter
    */
   public static final boolean isValidFormat(String format)
   {
+    return isValidFormat(format, false);
+  }
+  /**
+   * validate format is valid for IO
+   * @param format a format string to be compared with either READABLE_FORMATS or WRITEABLE_FORMATS
+   * @param forwriting when true, format is checked for containment in WRITEABLE_FORMATS
+   * @return true if format is valid
+   */
+  public static final boolean isValidFormat(String format, boolean forwriting)
+  {
     boolean valid = false;
-    for (int i = 0; i < READABLE_FORMATS.length; i++)
+    String[] format_list = (forwriting) ? WRITEABLE_FORMATS : READABLE_FORMATS;
+    for (int i = 0; i < format_list.length; i++)
     {
-      if (READABLE_FORMATS[i].equalsIgnoreCase(format))
+      if (format_list[i].equalsIgnoreCase(format))
       {
         return true;
       }
@@ -124,7 +135,7 @@ public class AppletFormatAdapter
 
     return valid;
   }
-
+  
   /**
    * Constructs the correct filetype parser for a characterised datasource
    *
@@ -413,6 +424,7 @@ public class AppletFormatAdapter
       if (f.exists())
       {
         try {
+          System.out.println("Reading file: "+f);
           AppletFormatAdapter afa = new AppletFormatAdapter();
           Runtime r = Runtime.getRuntime();
           System.gc();
@@ -422,6 +434,12 @@ public class AppletFormatAdapter
           t1 +=System.currentTimeMillis();
           System.gc();
           memf += r.totalMemory()-r.freeMemory();
+          if (al!=null)
+          {
+            System.out.println("Alignment contains "+al.getHeight()+" sequences and "+al.getWidth()+" columns.");
+          } else {
+            System.out.println("Couldn't read alignment");
+          }
           System.out.println("Read took "+(t1/1000.0)+" seconds.");
           System.out.println("Difference between free memory now and before is "+(memf/(1024.0*1024.0)*1.0)+" MB");