JAL-2909 Wire up coordinates dialog with bam file reader
[jalview.git] / src / jalview / io / AlignFile.java
index d36a588..c931cb8 100755 (executable)
@@ -40,7 +40,8 @@ import java.util.Vector;
  * @author $author$
  * @version $Revision$
  */
-public abstract class AlignFile extends FileParse implements AlignmentFileI
+public abstract class AlignFile extends FileParse
+        implements AlignmentFileReaderI, AlignmentFileWriterI
 {
   int noSeqs = 0;
 
@@ -65,7 +66,7 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI
   /**
    * Properties to be added to generated alignment object
    */
-  protected Hashtable properties;
+  private Hashtable properties;
 
   long start;
 
@@ -117,8 +118,7 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI
    * @throws IOException
    */
   public AlignFile(boolean parseImmediately, String dataObject,
-          DataSourceType sourceType)
-          throws IOException
+          DataSourceType sourceType) throws IOException
   {
     super(dataObject, sourceType);
     initData();
@@ -174,11 +174,6 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI
     }
     parseCalled = true;
     parse();
-    // sets the index of each sequence in the alignment
-    for (int i = 0, c = seqs.size(); i < c; i++)
-    {
-      seqs.get(i).setIndex(i);
-    }
   }
 
   /**
@@ -281,9 +276,8 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI
   {
     if (key == null)
     {
-      throw new Error(
-              MessageManager
-                      .getString("error.implementation_error_cannot_have_null_alignment"));
+      throw new Error(MessageManager.getString(
+              "error.implementation_error_cannot_have_null_alignment"));
     }
     if (value == null)
     {
@@ -310,9 +304,9 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI
    */
   protected void initData()
   {
-    seqs = new Vector<SequenceI>();
-    annotations = new Vector<AlignmentAnnotation>();
-    seqGroups = new ArrayList<SequenceGroup>();
+    seqs = new Vector<>();
+    annotations = new Vector<>();
+    seqGroups = new ArrayList<>();
     parseCalled = false;
   }
 
@@ -325,7 +319,7 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI
   @Override
   public void setSeqs(SequenceI[] s)
   {
-    seqs = new Vector<SequenceI>();
+    seqs = new Vector<>();
 
     for (int i = 0; i < s.length; i++)
     {
@@ -370,8 +364,8 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI
   }
 
   /**
-   * Creates the output id. Adds prefix Uniprot format source|id And suffix
-   * Jalview /start-end
+   * Creates the output id. Adds prefix Uniprot format source|id and optionally
+   * suffix Jalview /start-end
    * 
    * @param jvsuffix
    * 
@@ -382,6 +376,11 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI
     return seq.getDisplayId(jvsuffix);
   }
 
+  String printId(SequenceI seq)
+  {
+    return printId(seq, true);
+  }
+
   /**
    * vector of String[] treeName, newickString pairs
    */
@@ -391,7 +390,7 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI
   {
     if (newickStrings == null)
     {
-      newickStrings = new Vector<String[]>();
+      newickStrings = new Vector<>();
     }
     newickStrings.addElement(new String[] { treeName, newickString });
   }
@@ -411,4 +410,17 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI
     }
   }
 
+  protected void addSequence(SequenceI seq)
+  {
+    seqs.add(seq);
+  }
+
+  @Override
+  public Object[] preprocess()
+  {
+    // most AlignFiles will not need to return any preprocessing information
+    // those that do should override this method
+    return null;
+  }
+
 }