Merge branch 'develop' into bug/JAL-2255_seq-fetcher-broken-on-linux
[jalview.git] / src / jalview / io / StockholmFile.java
index 27be358..2061f29 100644 (file)
@@ -97,7 +97,8 @@ public class StockholmFile extends AlignFile
     this.al = al;
   }
 
-  public StockholmFile(String inFile, String type) throws IOException
+  public StockholmFile(String inFile, DataSourceType type)
+          throws IOException
   {
     super(inFile, type);
   }
@@ -880,8 +881,13 @@ public class StockholmFile extends AlignFile
     return annot;
   }
 
-  public String print(SequenceI[] s)
+  @Override
+  public String print(SequenceI[] s, boolean jvSuffix)
   {
+    out = new StringBuffer();
+    out.append("# STOCKHOLM 1.0");
+    out.append(newline);
+
     // find max length of id
     int max = 0;
     int maxid = 0;
@@ -889,7 +895,7 @@ public class StockholmFile extends AlignFile
     Hashtable dataRef = null;
     while ((in < s.length) && (s[in] != null))
     {
-      String tmp = printId(s[in]);
+      String tmp = printId(s[in], jvSuffix);
       if (s[in].getSequence().length > max)
       {
         max = s[in].getSequence().length;
@@ -986,7 +992,7 @@ public class StockholmFile extends AlignFile
 
             // out.append("#=GR ");
             out.append(new Format("%-" + maxid + "s").form("#=GR "
-                    + printId(s[i]) + " " + key + " "));
+                    + printId(s[i], jvSuffix) + " " + key + " "));
             ann = alAnot[j].annotations;
             boolean isrna = alAnot[j].isValidStruc();
             String seq = "";
@@ -1000,7 +1006,8 @@ public class StockholmFile extends AlignFile
         }
       }
 
-      out.append(new Format("%-" + maxid + "s").form(printId(s[i]) + " "));
+      out.append(new Format("%-" + maxid + "s")
+              .form(printId(s[i], jvSuffix) + " "));
       out.append(s[i].getSequenceAsString());
       out.append(newline);
       i++;
@@ -1053,6 +1060,10 @@ public class StockholmFile extends AlignFile
         out.append(newline);
       }
     }
+
+    out.append("//");
+    out.append(newline);
+
     return out.toString();
   }
 
@@ -1105,13 +1116,12 @@ public class StockholmFile extends AlignFile
     return seq;
   }
 
-  @Override
   public String print()
   {
     out = new StringBuffer();
     out.append("# STOCKHOLM 1.0");
     out.append(newline);
-    print(getSeqsAsArray());
+    print(getSeqsAsArray(), false);
 
     out.append("//");
     out.append(newline);