JAL-2629 adjust placement and optionality of arguments/options
[jalview.git] / src / jalview / io / StockholmFile.java
index 09c5b25..58b171d 100644 (file)
@@ -79,6 +79,8 @@ public class StockholmFile extends AlignFile
 {
   private static final String ANNOTATION = "annotation";
 
+  private static final char UNDERSCORE = '_';
+
   // private static final Regex OPEN_PAREN = new Regex("(<|\\[)", "(");
   // private static final Regex CLOSE_PAREN = new Regex("(>|\\])", ")");
 
@@ -111,14 +113,14 @@ public class StockholmFile extends AlignFile
     featureTypes.put("RF", "Reference Positions");
   }
 
-  AlignmentI al;
+  private AlignmentI al;
 
   public StockholmFile()
   {
   }
 
   /**
-   * Creates a new StockholmFile object for output.
+   * Creates a new StockholmFile object for output
    */
   public StockholmFile(AlignmentI al)
   {
@@ -903,6 +905,10 @@ public class StockholmFile extends AlignFile
     for (int i = 0; i < annots.length(); i++)
     {
       String pos = annots.substring(i, i + 1);
+      if (UNDERSCORE == pos.charAt(0))
+      {
+        pos = " ";
+      }
       Annotation ann;
       ann = new Annotation(pos, "", ' ', 0f); // 0f is 'valid' null - will not
       // be written out
@@ -1171,7 +1177,7 @@ public class StockholmFile extends AlignFile
    * @param ann
    * @param sequenceI
    */
-  private char getAnnotationCharacter(String key, int k, Annotation annot,
+  static char getAnnotationCharacter(String key, int k, Annotation annot,
           SequenceI sequenceI)
   {
     char seq = ' ';
@@ -1183,8 +1189,8 @@ public class StockholmFile extends AlignFile
     {
       if (annot == null)
       {
-        // sensible gap character
-        return ' ';
+        // Stockholm format requires underscore, not space
+        return UNDERSCORE;
       }
       else
       {