file format enum wip changes
[jalview.git] / src / jalview / io / FormatAdapter.java
index 63a14d7..eac1041 100755 (executable)
@@ -22,6 +22,7 @@ package jalview.io;
 
 import jalview.api.AlignExportSettingI;
 import jalview.api.AlignmentViewPanel;
+import jalview.bin.Cache;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
@@ -30,6 +31,8 @@ import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 
+import java.io.IOException;
+
 /**
  * Additional formatting methods used by the application in a number of places.
  * 
@@ -63,9 +66,9 @@ public class FormatAdapter extends AppletFormatAdapter
       annotFromStructure = jalview.bin.Cache.getDefault("ADD_TEMPFACT_ANN",
               true);
       localSecondaryStruct = jalview.bin.Cache.getDefault("ADD_SS_ANN",
-            true);
-    serviceSecondaryStruct = jalview.bin.Cache.getDefault("USE_RNAVIEW",
-            true);
+              true);
+      serviceSecondaryStruct = jalview.bin.Cache.getDefault("USE_RNAVIEW",
+              true);
     }
     else
     {
@@ -107,8 +110,6 @@ public class FormatAdapter extends AppletFormatAdapter
       {
         startRes = seqs[i].getStart();
         endRes = seqs[i].getEnd();
-
-
         if (startEnd != null)
         {
           startIndex = startEnd[0];
@@ -128,9 +129,7 @@ public class FormatAdapter extends AppletFormatAdapter
           }
 
           startRes = seqs[i].findPosition(startIndex);
-          startRes = seqs[i].getStart() > 1 ? startRes - seqs[i].getStart()
-                  : startRes;
-          endRes = seqs[i].findPosition(endIndex) - seqs[i].getStart();
+          endRes = seqs[i].findPosition(endIndex);
         }
 
         tmp[i] = new Sequence(seqs[i].getName(), omitHiddenColumns[i],
@@ -229,24 +228,24 @@ public class FormatAdapter extends AppletFormatAdapter
     return null;
   }
 
-  public boolean getCacheSuffixDefault(String format)
+  public boolean getCacheSuffixDefault(FileFormatI format)
   {
     if (isValidFormat(format))
     {
-      return jalview.bin.Cache.getDefault(format.toUpperCase()
+      return Cache.getDefault(format.toUpperCase()
               + "_JVSUFFIX", true);
     }
     return false;
   }
 
-  public String formatSequences(String format, AlignmentI alignment,
+  public String formatSequences(FileFormatI format, AlignmentI alignment,
           String[] omitHidden, int[] exportRange, ColumnSelection colSel)
   {
     return formatSequences(format, alignment, omitHidden, exportRange,
             getCacheSuffixDefault(format), colSel, null);
   }
 
-  public String formatSequences(String format, AlignmentI alignment,
+  public String formatSequences(FileFormatI format, AlignmentI alignment,
           String[] omitHidden, int[] exportRange, ColumnSelection colSel,
           SequenceGroup sgp)
   {
@@ -266,19 +265,17 @@ public class FormatAdapter extends AppletFormatAdapter
    *          defines hidden columns that are edited out of annotation
    * @return string representation of the alignment formatted as format
    */
-  public String formatSequences(String format, AlignmentI alignment,
+  public String formatSequences(FileFormatI format, AlignmentI alignment,
           String[] omitHidden, int[] exportRange, boolean suffix,
           ColumnSelection colSel)
   {
     return formatSequences(format, alignment, omitHidden, exportRange,
-            suffix, colSel,
-            null);
+            suffix, colSel, null);
   }
 
-  public String formatSequences(String format, AlignmentI alignment,
+  public String formatSequences(FileFormatI format, AlignmentI alignment,
           String[] omitHidden, int[] exportRange, boolean suffix,
-          ColumnSelection colSel,
-          jalview.datamodel.SequenceGroup selgp)
+          ColumnSelection colSel, SequenceGroup selgp)
   {
     if (omitHidden != null)
     {
@@ -311,15 +308,17 @@ public class FormatAdapter extends AppletFormatAdapter
     return this.formatSequences(format, alignment, suffix);
   }
 
-  public AlignmentI readFile(String inFile, String type, String format)
-          throws java.io.IOException
+  @Override
+  public AlignmentI readFile(String file, DataSourceType sourceType,
+          FileFormatI fileFormat) throws IOException
   {
-    AlignmentI al = super.readFile(inFile, type, format);
+    AlignmentI al = super.readFile(file, sourceType, fileFormat);
     return al;
   }
 
-  public AlignmentI readFromFile(FileParse source, String format)
-          throws java.io.IOException
+  @Override
+  public AlignmentI readFromFile(FileParse source, FileFormatI format)
+          throws IOException
   {
     AlignmentI al = super.readFromFile(source, format);
     return al;
@@ -356,12 +355,11 @@ public class FormatAdapter extends AppletFormatAdapter
    *          alignment panel originating the view
    * @return String containing flat file
    */
-  public String formatSequences(String format, AlignmentViewPanel ap,
+  public String formatSequences(FileFormatI format, AlignmentViewPanel ap,
           boolean selectedOnly)
   {
     return formatSequences(format, getCacheSuffixDefault(format), ap,
             selectedOnly);
   }
 
-
 }