JAL-727
authorjprocter <Jim Procter>
Wed, 5 Jan 2011 15:52:16 +0000 (15:52 +0000)
committerjprocter <Jim Procter>
Wed, 5 Jan 2011 15:52:16 +0000 (15:52 +0000)
14 files changed:
src/MCview/PDBChain.java
src/jalview/io/AMSAFile.java
src/jalview/io/AnnotationFile.java
src/jalview/io/AppletFormatAdapter.java
src/jalview/io/BLCFile.java
src/jalview/io/ClustalFile.java
src/jalview/io/FastaFile.java
src/jalview/io/FeaturesFile.java
src/jalview/io/FileParse.java
src/jalview/io/FormatAdapter.java
src/jalview/io/MSFfile.java
src/jalview/io/PIRFile.java
src/jalview/io/PfamFile.java
src/jalview/io/PileUpfile.java

index c7eec35..779b4f0 100755 (executable)
@@ -66,7 +66,18 @@ public class PDBChain
     this.pdbid = pdbid.toLowerCase();
     this.id = id;
   }
-
+  /**
+   * character used to write newlines 
+   */
+  protected String newline = System.getProperty("line.separator");
+  public void setNewlineString(String nl)
+  {
+    newline = nl;
+  }
+  public String getNewlineString()
+  {
+    return newline;
+  }
   public String print()
   {
     String tmp = "";
@@ -75,7 +86,7 @@ public class PDBChain
     {
       tmp = tmp + ((Bond) bonds.elementAt(i)).at1.resName + " "
               + ((Bond) bonds.elementAt(i)).at1.resNumber + " " + offset
-              + "\n";
+              + newline;
     }
 
     return tmp;
index 0a4624b..fb2a38b 100644 (file)
@@ -60,7 +60,7 @@ public class AMSAFile extends jalview.io.FastaFile
           out.append(" " + aa.description);
         }
 
-        out.append("\n");
+        out.append(newline);
 
         int nochunks = Math.min(aa.annotations.length, al.getWidth()) / len
                 + 1;
@@ -93,7 +93,7 @@ public class AMSAFile extends jalview.io.FastaFile
             out.append(ch);
 
           }
-          out.append("\n");
+          out.append(newline);
         }
       }
     }
index ef46b86..d4284a2 100755 (executable)
@@ -27,8 +27,41 @@ import jalview.schemes.*;
 \r
 public class AnnotationFile\r
 {\r
-  StringBuffer text = new StringBuffer("JALVIEW_ANNOTATION\n"\r
-          + "# Created: " + new java.util.Date() + "\n\n");\r
+  public AnnotationFile()\r
+  {\r
+    init();\r
+  }\r
+\r
+  /**\r
+   * character used to write newlines\r
+   */\r
+  protected String newline = System.getProperty("line.separator");\r
+\r
+  /**\r
+   * set new line string and reset the output buffer\r
+   * \r
+   * @param nl\r
+   */\r
+  public void setNewlineString(String nl)\r
+  {\r
+    newline = nl;\r
+    init();\r
+  }\r
+\r
+  public String getNewlineString()\r
+  {\r
+    return newline;\r
+  }\r
+\r
+  StringBuffer text;\r
+\r
+  private void init()\r
+  {\r
+    text = new StringBuffer("JALVIEW_ANNOTATION"+newline + "# Created: "\r
+            + new java.util.Date() + newline + newline);\r
+    refSeq = null;\r
+    refSeqId = null;\r
+  }\r
 \r
   /**\r
    * convenience method for pre-2.4 feature files which have no view, hidden\r
@@ -118,7 +151,9 @@ public class AnnotationFile
         {\r
           if (refSeq != null)\r
           {\r
-            text.append("\nSEQUENCE_REF\tALIGNMENT\n");\r
+            text.append(newline);\r
+            text.append("SEQUENCE_REF\tALIGNMENT");\r
+            text.append(newline);\r
           }\r
 \r
           refSeq = null;\r
@@ -129,7 +164,10 @@ public class AnnotationFile
           if (refSeq == null || refSeq != row.sequenceRef)\r
           {\r
             refSeq = row.sequenceRef;\r
-            text.append("\nSEQUENCE_REF\t" + refSeq.getName() + "\n");\r
+            text.append(newline);\r
+            text.append("SEQUENCE_REF\t");\r
+            text.append(refSeq.getName());\r
+            text.append(newline);\r
           }\r
         }\r
         // mark any group references for the row\r
@@ -138,7 +176,9 @@ public class AnnotationFile
 \r
           if (refGroup != null)\r
           {\r
-            text.append("\nGROUP_REF\tALIGNMENT\n");\r
+            text.append(newline);\r
+            text.append("GROUP_REF\tALIGNMENT");\r
+            text.append(newline);\r
           }\r
 \r
           refGroup = null;\r
@@ -148,7 +188,10 @@ public class AnnotationFile
           if (refGroup == null || refGroup != row.groupRef)\r
           {\r
             refGroup = row.groupRef;\r
-            text.append("\nGROUP_REF\t" + refGroup.getName() + "\n");\r
+            text.append(newline);\r
+            text.append("GROUP_REF\t");\r
+            text.append(refGroup.getName());\r
+            text.append(newline);\r
           }\r
         }\r
 \r
@@ -194,16 +237,16 @@ public class AnnotationFile
 \r
           if (row.getThreshold() != null)\r
           {\r
-            graphLine\r
-                    .append("GRAPHLINE\t"\r
-                            + row.label\r
-                            + "\t"\r
-                            + row.getThreshold().value\r
-                            + "\t"\r
-                            + row.getThreshold().label\r
-                            + "\t"\r
-                            + jalview.util.Format.getHexString(row\r
-                                    .getThreshold().colour) + "\n");\r
+            graphLine.append("GRAPHLINE\t");\r
+            graphLine.append(row.label);\r
+            graphLine.append("\t");\r
+            graphLine.append(row.getThreshold().value);\r
+            graphLine.append("\t");\r
+            graphLine.append(row.getThreshold().label);\r
+            graphLine.append("\t");\r
+            graphLine.append(jalview.util.Format.getHexString(row\r
+                    .getThreshold().colour));\r
+            graphLine.append(newline);\r
           }\r
 \r
           if (row.graphGroup > -1)\r
@@ -308,25 +351,32 @@ public class AnnotationFile
         if (row.hasScore())\r
           text.append("\t" + row.score);\r
 \r
-        text.append("\n");\r
+        text.append(newline);\r
 \r
         if (color != null && color != java.awt.Color.black && oneColour)\r
         {\r
-          colours.append("COLOUR\t" + row.label + "\t"\r
-                  + jalview.util.Format.getHexString(color) + "\n");\r
+          colours.append("COLOUR\t");\r
+          colours.append(row.label);\r
+          colours.append("\t");\r
+          colours.append(jalview.util.Format.getHexString(color));\r
+          colours.append(newline);\r
         }\r
         if (row.scaleColLabel || row.showAllColLabels\r
                 || row.centreColLabels)\r
         {\r
-          rowprops.append("ROWPROPERTIES\t" + row.label);\r
-          rowprops.append("\tscaletofit=" + row.scaleColLabel);\r
-          rowprops.append("\tshowalllabs=" + row.showAllColLabels);\r
-          rowprops.append("\tcentrelabs=" + row.centreColLabels);\r
-          rowprops.append("\n");\r
+          rowprops.append("ROWPROPERTIES\t");\r
+          rowprops.append(row.label);\r
+          rowprops.append("\tscaletofit=");\r
+          rowprops.append(row.scaleColLabel);\r
+          rowprops.append("\tshowalllabs=");\r
+          rowprops.append(row.showAllColLabels);\r
+          rowprops.append("\tcentrelabs=");\r
+          rowprops.append(row.centreColLabels);\r
+          rowprops.append(newline);\r
         }\r
       }\r
 \r
-      text.append("\n");\r
+      text.append(newline);\r
 \r
       text.append(colours.toString());\r
       text.append(graphLine.toString());\r
@@ -336,7 +386,8 @@ public class AnnotationFile
         Enumeration en = graphGroup.elements();\r
         while (en.hasMoreElements())\r
         {\r
-          text.append(en.nextElement() + "\n");\r
+          text.append(en.nextElement());\r
+          text.append(newline);\r
         }\r
       }\r
       text.append(rowprops.toString());\r
@@ -349,12 +400,17 @@ public class AnnotationFile
 \r
     if (properties != null)\r
     {\r
-      text.append("\n\nALIGNMENT");\r
+      text.append(newline);\r
+      text.append(newline);\r
+      text.append("ALIGNMENT");\r
       Enumeration en = properties.keys();\r
       while (en.hasMoreElements())\r
       {\r
         String key = en.nextElement().toString();\r
-        text.append("\t" + key + "=" + properties.get(key));\r
+        text.append("\t");\r
+        text.append(key);\r
+        text.append("=");\r
+        text.append(properties.get(key));\r
       }\r
       // TODO: output alignment visualization settings here if required\r
 \r
@@ -380,61 +436,90 @@ public class AnnotationFile
       else\r
       {\r
         seqrep = sg.getSeqrep();\r
-        text.append("SEQUENCE_REF\t" + seqrep.getName() + "\n");\r
-        text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t"\r
-                + (seqrep.findPosition(sg.getStartRes())) + "\t"\r
-                + (seqrep.findPosition(sg.getEndRes())) + "\t" + "-1\t");\r
+        text.append("SEQUENCE_REF\t");\r
+        text.append(seqrep.getName());\r
+        text.append(newline);\r
+        text.append("SEQUENCE_GROUP\t");\r
+        text.append(sg.getName());\r
+        text.append("\t");\r
+        text.append((seqrep.findPosition(sg.getStartRes())));\r
+        text.append("\t");\r
+        text.append((seqrep.findPosition(sg.getEndRes())));\r
+        text.append("\t");\r
+        text.append("-1\t");\r
       }\r
       for (int s = 0; s < sg.getSize(); s++)\r
       {\r
-        text.append(sg.getSequenceAt(s).getName() + "\t");\r
+        text.append(sg.getSequenceAt(s).getName());\r
+        text.append("\t");\r
       }\r
-\r
-      text.append("\nPROPERTIES\t" + sg.getName() + "\t");\r
+      text.append(newline);\r
+      text.append("PROPERTIES\t");\r
+      text.append(sg.getName());\r
+      text.append("\t");\r
 \r
       if (sg.getDescription() != null)\r
       {\r
-        text.append("description=" + sg.getDescription() + "\t");\r
+        text.append("description=");\r
+        text.append(sg.getDescription());\r
+        text.append("\t");\r
       }\r
       if (sg.cs != null)\r
       {\r
-        text.append("colour=" + ColourSchemeProperty.getColourName(sg.cs)\r
-                + "\t");\r
+        text.append("colour=");\r
+        text.append(ColourSchemeProperty.getColourName(sg.cs));\r
+        text.append("\t");\r
         if (sg.cs.getThreshold() != 0)\r
         {\r
-          text.append("pidThreshold=" + sg.cs.getThreshold());\r
+          text.append("pidThreshold=");\r
+          text.append(sg.cs.getThreshold());\r
         }\r
         if (sg.cs.conservationApplied())\r
         {\r
-          text.append("consThreshold=" + sg.cs.getConservationInc() + "\t");\r
+          text.append("consThreshold=");\r
+          text.append(sg.cs.getConservationInc());\r
+          text.append("\t");\r
         }\r
       }\r
-      text.append("outlineColour="\r
-              + jalview.util.Format.getHexString(sg.getOutlineColour())\r
-              + "\t");\r
-\r
-      text.append("displayBoxes=" + sg.getDisplayBoxes() + "\t");\r
-      text.append("displayText=" + sg.getDisplayText() + "\t");\r
-      text.append("colourText=" + sg.getColourText() + "\t");\r
-      text.append("showUnconserved=" + sg.getShowNonconserved() + "\t");\r
+      text.append("outlineColour=");\r
+      text.append(jalview.util.Format.getHexString(sg.getOutlineColour()));\r
+      text.append("\t");\r
+\r
+      text.append("displayBoxes=");\r
+      text.append(sg.getDisplayBoxes());\r
+      text.append("\t");\r
+      text.append("displayText=");\r
+      text.append(sg.getDisplayText());\r
+      text.append("\t");\r
+      text.append("colourText=");\r
+      text.append(sg.getColourText());\r
+      text.append("\t");\r
+      text.append("showUnconserved=");\r
+      text.append(sg.getShowNonconserved());\r
+      text.append("\t");\r
       if (sg.textColour != java.awt.Color.black)\r
       {\r
-        text.append("textCol1="\r
-                + jalview.util.Format.getHexString(sg.textColour) + "\t");\r
+        text.append("textCol1=");\r
+        text.append(jalview.util.Format.getHexString(sg.textColour));\r
+        text.append("\t");\r
       }\r
       if (sg.textColour2 != java.awt.Color.white)\r
       {\r
-        text.append("textCol2="\r
-                + jalview.util.Format.getHexString(sg.textColour2) + "\t");\r
+        text.append("textCol2=");\r
+        text.append(jalview.util.Format.getHexString(sg.textColour2));\r
+        text.append("\t");\r
       }\r
       if (sg.thresholdTextColour != 0)\r
       {\r
-        text.append("textColThreshold=" + sg.thresholdTextColour + "\t");\r
+        text.append("textColThreshold=");\r
+        text.append(sg.thresholdTextColour);\r
+        text.append("\t");\r
       }\r
       if (sg.idColour != null)\r
       {\r
-        text.append("idColour="\r
-                + jalview.util.Format.getHexString(sg.idColour) + "\t");\r
+        text.append("idColour=");\r
+        text.append(jalview.util.Format.getHexString(sg.idColour));\r
+        text.append("\t");\r
       }\r
       if (sg.isHidereps())\r
       {\r
@@ -447,9 +532,11 @@ public class AnnotationFile
       if (seqrep != null)\r
       {\r
         // terminate the last line and clear the sequence ref for the group\r
-        text.append("\nSEQUENCE_REF");\r
+        text.append(newline);\r
+        text.append("SEQUENCE_REF");\r
       }\r
-      text.append("\n\n");\r
+      text.append(newline);\r
+      text.append(newline);\r
 \r
     }\r
   }\r
@@ -502,7 +589,7 @@ public class AnnotationFile
   public boolean parseAnnotationFrom(AlignmentI al, BufferedReader in)\r
           throws Exception\r
   {\r
-    boolean modified=false;\r
+    boolean modified = false;\r
     String groupRef = null;\r
     Hashtable groupRefRows = new Hashtable();\r
 \r
@@ -526,10 +613,11 @@ public class AnnotationFile
             if (aa[aai].autoCalculated)\r
             {\r
               // make a note of the name and description\r
-              autoAnnots\r
-                      .put(autoAnnotsKey(aa[aai], aa[aai].sequenceRef, (aa[aai].groupRef==null ? null : aa[aai].groupRef.getName())\r
-                              ),\r
-                              new Integer(1));\r
+              autoAnnots.put(\r
+                      autoAnnotsKey(aa[aai], aa[aai].sequenceRef,\r
+                              (aa[aai].groupRef == null ? null\r
+                                      : aa[aai].groupRef.getName())),\r
+                      new Integer(1));\r
             }\r
           }\r
         }\r
@@ -578,23 +666,26 @@ public class AnnotationFile
         {\r
           // TODO: use graduated colour def'n here too\r
           colourAnnotations(al, st.nextToken(), st.nextToken());\r
-          modified=true;continue;\r
+          modified = true;\r
+          continue;\r
         }\r
 \r
         else if (token.equalsIgnoreCase("COMBINE"))\r
         {\r
           combineAnnotations(al, st);\r
-          modified=true;continue;\r
+          modified = true;\r
+          continue;\r
         }\r
         else if (token.equalsIgnoreCase("ROWPROPERTIES"))\r
         {\r
           addRowProperties(al, st);\r
-          modified=true;continue;\r
+          modified = true;\r
+          continue;\r
         }\r
         else if (token.equalsIgnoreCase("GRAPHLINE"))\r
         {\r
           addLine(al, st);\r
-          modified=true;\r
+          modified = true;\r
           continue;\r
         }\r
 \r
@@ -659,18 +750,21 @@ public class AnnotationFile
         else if (token.equalsIgnoreCase("PROPERTIES"))\r
         {\r
           addProperties(al, st);\r
-          modified=true;          continue;\r
+          modified = true;\r
+          continue;\r
         }\r
 \r
         else if (token.equalsIgnoreCase("BELOW_ALIGNMENT"))\r
         {\r
           setBelowAlignment(al, st);\r
-          modified=true;continue;\r
+          modified = true;\r
+          continue;\r
         }\r
         else if (token.equalsIgnoreCase("ALIGNMENT"))\r
         {\r
           addAlignmentDetails(al, st);\r
-          modified=true;continue;\r
+          modified = true;\r
+          continue;\r
         }\r
 \r
         // Parse out the annotation row\r
@@ -742,8 +836,8 @@ public class AnnotationFile
 \r
         annotation.score = score;\r
         if (!overrideAutoAnnot\r
-                && autoAnnots\r
-                        .containsKey(autoAnnotsKey(annotation, refSeq, groupRef)))\r
+                && autoAnnots.containsKey(autoAnnotsKey(annotation, refSeq,\r
+                        groupRef)))\r
         {\r
           // skip - we've already got an automatic annotation of this type.\r
           continue;\r
@@ -791,7 +885,7 @@ public class AnnotationFile
           }\r
         }\r
         // and set modification flag\r
-        modified=true;\r
+        modified = true;\r
       }\r
       // Finally, resolve the groupRefs\r
       Enumeration en = groupRefRows.keys();\r
@@ -838,16 +932,12 @@ public class AnnotationFile
     return modified;\r
   }\r
 \r
-  private Object autoAnnotsKey(AlignmentAnnotation annotation, SequenceI refSeq, String groupRef)\r
+  private Object autoAnnotsKey(AlignmentAnnotation annotation,\r
+          SequenceI refSeq, String groupRef)\r
   {\r
-    return annotation.graph\r
-    + "\t"\r
-    + annotation.label\r
-    + "\t"\r
-    + annotation.description\r
-    + "\t"\r
-    + (refSeq != null ? refSeq\r
-            .getDisplayId(true) : "");\r
+    return annotation.graph + "\t" + annotation.label + "\t"\r
+            + annotation.description + "\t"\r
+            + (refSeq != null ? refSeq.getDisplayId(true) : "");\r
   }\r
 \r
   Annotation parseAnnotation(String string, int graphStyle)\r
@@ -1387,7 +1477,7 @@ public class AnnotationFile
         else\r
         {\r
           sp.append(atos.substring(p));\r
-          sp.append("\n");\r
+          sp.append(newline);\r
         }\r
         p = cp + 1;\r
       } while (p > 0);\r
index 5eb4d2b..d42157b 100755 (executable)
@@ -117,7 +117,18 @@ public class AppletFormatAdapter
   AlignFile afile = null;
 
   String inFile;
-
+  /**
+   * character used to write newlines 
+   */
+  protected String newline = System.getProperty("line.separator");
+  public void setNewlineString(String nl)
+  {
+    newline = nl;
+  }
+  public String getNewlineString()
+  {
+    return newline;
+  }
   /**
    * check that this format is valid for reading
    * 
@@ -441,7 +452,7 @@ public class AppletFormatAdapter
         throw new Exception(
                 "Implementation error: Unknown file format string");
       }
-
+      afile.setNewlineString(newline);
       afile.addJVSuffix(jvsuffix);
 
       afile.setSeqs(alignment.getSequencesArray());
index d0eb80e..f024415 100755 (executable)
@@ -142,7 +142,7 @@ public class BLCFile extends AlignFile
         {
           // header lines - keep them for the alignment comments.
           headerLines.append(line);
-          headerLines.append("\n");
+          headerLines.append(newline);
           numHeaderLines++;
         }
       } while (!idsFound);
@@ -240,7 +240,7 @@ public class BLCFile extends AlignFile
         out.append(" " + s[i].getDescription());
       }
 
-      out.append("\n");
+      out.append(newline);
 
       if (s[i].getSequence().length > max)
       {
@@ -250,7 +250,8 @@ public class BLCFile extends AlignFile
       i++;
     }
 
-    out.append("* iteration 1\n");
+    out.append("* iteration 1");
+    out.append(newline);
 
     for (int j = 0; j < max; j++)
     {
@@ -270,10 +271,11 @@ public class BLCFile extends AlignFile
         i++;
       }
 
-      out.append("\n");
+      out.append(newline);
     }
 
-    out.append("*\n");
+    out.append("*");
+    out.append(newline);
 
     return out.toString();
   }
index 4c700ed..7e22f3d 100755 (executable)
@@ -149,7 +149,7 @@ public class ClustalFile extends AlignFile
 
   public String print(SequenceI[] s)
   {
-    StringBuffer out = new StringBuffer("CLUSTAL\n\n");
+    StringBuffer out = new StringBuffer("CLUSTAL"+newline+newline);
 
     int max = 0;
     int maxid = 0;
@@ -207,11 +207,11 @@ public class ClustalFile extends AlignFile
           }
         }
 
-        out.append("\n");
+        out.append(newline);
         j++;
       }
 
-      out.append("\n");
+      out.append(newline);
     }
 
     return out.toString();
index 5a15862..b8e001a 100755 (executable)
@@ -203,7 +203,7 @@ public class FastaFile extends AlignFile
         out.append(" " + s[i].getDescription());
       }
 
-      out.append("\n");
+      out.append(newline);
 
       int nochunks = (s[i].getLength() / len) + 1;
 
@@ -214,12 +214,12 @@ public class FastaFile extends AlignFile
 
         if (end < s[i].getLength())
         {
-          out.append(s[i].getSequenceAsString(start, end) + "\n");
+          out.append(s[i].getSequenceAsString(start, end) + newline);
         }
         else if (start < s[i].getLength())
         {
           out.append(s[i].getSequenceAsString(start, s[i].getLength())
-                  + "\n");
+                  + newline);
         }
       }
 
index 7c70b54..64bb539 100755 (executable)
@@ -607,7 +607,7 @@ public class FeaturesFile extends AlignFile
       }\r
       else if (tag != null && tag.equalsIgnoreCase("br"))\r
       {\r
-        sb.append("\n");\r
+        sb.append(newline);\r
       }\r
       else if (token.startsWith("lt;"))\r
       {\r
@@ -726,7 +726,10 @@ public class FeaturesFile extends AlignFile
           color = Format.getHexString(new java.awt.Color(Integer\r
                   .parseInt(visible.get(type).toString())));\r
         }\r
-        out.append(type + "\t" + color + "\n");\r
+        out.append(type);\r
+        out.append("\t");\r
+        out.append(color);\r
+        out.append(newline);\r
       }\r
     }\r
     // Work out which groups are both present and visible\r
@@ -765,7 +768,10 @@ public class FeaturesFile extends AlignFile
       if (groups.size() > 0 && groupIndex < groups.size())\r
       {\r
         group = groups.elementAt(groupIndex).toString();\r
-        out.append("\nSTARTGROUP\t" + group + "\n");\r
+        out.append(newline);\r
+        out.append("STARTGROUP\t");\r
+        out.append(group);\r
+        out.append(newline);\r
       }\r
       else\r
       {\r
@@ -838,22 +844,28 @@ public class FeaturesFile extends AlignFile
 \r
               out.append("\t");\r
             }\r
-            out.append(seqs[i].getName()\r
-                    + "\t-1\t"\r
-                    + next[j].begin\r
-                    + "\t"\r
-                    + next[j].end\r
-                    + "\t"\r
-                    + next[j].type\r
-                    + ((next[j].score != Float.NaN) ? "\t" + next[j].score\r
-                            + "\n" : "\n"));\r
+            out.append(seqs[i].getName());\r
+            out.append("\t-1\t");\r
+            out.append(next[j].begin);\r
+            out.append("\t");\r
+            out.append(next[j].end);\r
+            out.append("\t");\r
+            out.append(next[j].type);\r
+            if (next[j].score != Float.NaN)\r
+            {\r
+              out.append("\t");\r
+              out.append(next[j].score);\r
+            }\r
+            out.append(newline);\r
           }\r
         }\r
       }\r
 \r
       if (group != null)\r
       {\r
-        out.append("ENDGROUP\t" + group + "\n");\r
+        out.append("ENDGROUP\t");\r
+        out.append(group);\r
+        out.append(newline);\r
         groupIndex++;\r
       }\r
       else\r
@@ -912,13 +924,24 @@ public class FeaturesFile extends AlignFile
             source = next[j].getDescription();\r
           }\r
 \r
-          out.append(seqs[i].getName() + "\t" + source + "\t"\r
-                  + next[j].type + "\t" + next[j].begin + "\t"\r
-                  + next[j].end + "\t" + next[j].score + "\t");\r
+          out.append(seqs[i].getName());\r
+          out.append("\t");\r
+          out.append(source);\r
+          out.append("\t");\r
+          out.append(next[j].type);\r
+          out.append( "\t");\r
+          out.append(  next[j].begin );\r
+          out.append("\t");\r
+          out.append(\r
+                  next[j].end);\r
+          out.append( "\t");\r
+          out.append( next[j].score);\r
+          out.append( "\t");\r
 \r
           if (next[j].getValue("STRAND") != null)\r
           {\r
-            out.append(next[j].getValue("STRAND") + "\t");\r
+            out.append(next[j].getValue("STRAND"));\r
+            out.append( "\t");\r
           }\r
           else\r
           {\r
@@ -933,13 +956,14 @@ public class FeaturesFile extends AlignFile
           {\r
             out.append(".");\r
           }\r
+          // TODO: verify/check GFF - should there be a /t here before attribute output ?\r
 \r
           if (next[j].getValue("ATTRIBUTES") != null)\r
           {\r
             out.append(next[j].getValue("ATTRIBUTES"));\r
           }\r
 \r
-          out.append("\n");\r
+          out.append(newline);\r
 \r
         }\r
       }\r
index 4714b8f..0515507 100755 (executable)
@@ -38,7 +38,18 @@ public class FileParse
   // same data source
 
   protected char suffixSeparator = '#';
-
+  /**
+   * character used to write newlines 
+   */
+  protected String newline = System.getProperty("line.separator");
+  public void setNewlineString(String nl)
+  {
+    newline = nl;
+  }
+  public String getNewlineString()
+  {
+    return newline;
+  }
   /**
    * '#' separated string tagged on to end of filename or url that was clipped
    * off to resolve to valid filename
index 79a9190..a71d645 100755 (executable)
@@ -36,7 +36,7 @@ public class FormatAdapter extends AppletFormatAdapter
   }
 
   /**
-   * create sequences with each seuqence string replaced with the one given in
+   * create sequences with each sequence string replaced with the one given in
    * omitHiddenCOlumns
    * 
    * @param seqs
@@ -194,7 +194,8 @@ public class FormatAdapter extends AppletFormatAdapter
   {
     if (omitHidden != null)
     {
-      //
+      // TODO consider using AlignmentView to prune to visible region
+      // TODO prune sequence annotation and groups to visible region
       Alignment alv = new Alignment(replaceStrings(
               alignment.getSequencesArray(), omitHidden));
       AlignmentAnnotation[] ala = alignment.getAlignmentAnnotation();
index 1f38ca0..28f1f97 100755 (executable)
@@ -216,9 +216,10 @@ public class MSFfile extends AlignFile
     SequenceI[] s = new SequenceI[seqs.length];
 
     StringBuffer out = new StringBuffer("!!" + (is_NA ? "NA" : "AA")
-            + "_MULTIPLE_ALIGNMENT 1.0\n\n"); // TODO: JBPNote : Jalview doesn't
-    // remember NA or AA yet.
-
+            + "_MULTIPLE_ALIGNMENT 1.0");
+     // TODO: JBPNote : Jalview doesn't remember NA or AA yet.
+    out.append(newline);
+    out.append(newline);
     int max = 0;
     int maxid = 0;
     int i = 0;
@@ -284,7 +285,10 @@ public class MSFfile extends AlignFile
     long maxNB = 0;
     out.append("   MSF: " + s[0].getSequence().length + "   Type: "
             + (is_NA ? "N" : "P") + "    Check:  " + (bigChecksum % 10000)
-            + "   ..\n\n\n");
+            + "   ..");
+    out.append(newline);
+    out.append(newline);
+    out.append(newline);
 
     String[] nameBlock = new String[s.length];
     String[] idBlock = new String[s.length];
@@ -297,7 +301,7 @@ public class MSFfile extends AlignFile
 
       idBlock[i] = new String("Len: "
               + maxLenpad.form(s[i].getSequence().length) + "  Check: "
-              + maxChkpad.form(checksums[i]) + "  Weight: 1.00\n");
+              + maxChkpad.form(checksums[i]) + "  Weight: 1.00"+newline);
 
       if (s[i].getName().length() > maxid)
       {
@@ -330,8 +334,10 @@ public class MSFfile extends AlignFile
     }
 
     maxid++;
-    out.append("\n\n//\n\n");
-
+    out.append(newline);
+    out.append(newline);out.append("//");
+    out.append(newline);
+    out.append(newline);
     int len = 50;
 
     int nochunks = (max / len) + 1;
@@ -367,7 +373,7 @@ public class MSFfile extends AlignFile
             }
             else
             {
-              out.append("\n");
+              out.append(newline);
             }
           }
           else
@@ -375,13 +381,13 @@ public class MSFfile extends AlignFile
             if (start < s[j].getSequence().length)
             {
               out.append(s[j].getSequenceAsString().substring(start));
-              out.append("\n");
+              out.append(newline);
             }
             else
             {
               if (k == 0)
               {
-                out.append("\n");
+                out.append(newline);
               }
             }
           }
@@ -390,7 +396,7 @@ public class MSFfile extends AlignFile
         j++;
       }
 
-      out.append("\n");
+      out.append(newline);
     }
 
     return out.toString();
index ef06b0c..fcd790e 100755 (executable)
@@ -127,16 +127,19 @@ public class PIRFile extends AlignFile
         // tRNA N3
         // other functional RNA N1
 
-        out.append(">N1;" + s[i].getName() + "\n");
+        out.append(">N1;" + s[i].getName());
+        out.append(newline);
         if (s[i].getDescription() == null)
         {
           out.append(s[i].getName() + " "
                   + (s[i].getEnd() - s[i].getStart() + 1));
-          out.append(is_NA ? " bases\n" : " residues\n");
+          out.append(is_NA ? " bases" : " residues");
+          out.append(newline);
         }
         else
         {
-          out.append(s[i].getDescription() + "\n");
+          out.append(s[i].getDescription());
+          out.append(newline);
         }
       }
       else
@@ -144,21 +147,26 @@ public class PIRFile extends AlignFile
 
         if (useModellerOutput)
         {
-          out.append(">P1;" + s[i].getName() + "\n");
+          out.append(">P1;" + s[i].getName());
+          out.append(newline);
           md = new ModellerDescription(s[i]);
-          out.append(md.getDescriptionLine() + "\n");
+          out.append(md.getDescriptionLine());
+          out.append(newline);
         }
         else
         {
-          out.append(">P1;" + printId(s[i]) + "\n");
+          out.append(">P1;" + printId(s[i]));
+          out.append(newline);
           if (s[i].getDescription() != null)
           {
-            out.append(s[i].getDescription() + "\n");
+            out.append(s[i].getDescription());
+            out.append(newline);
           }
           else
           {
             out.append(s[i].getName() + " "
-                    + (s[i].getEnd() - s[i].getStart() + 1) + " residues\n");
+                    + (s[i].getEnd() - s[i].getStart() + 1) + " residues");
+            out.append(newline);
           }
         }
       }
@@ -171,11 +179,13 @@ public class PIRFile extends AlignFile
 
         if (end < seq.length())
         {
-          out.append(seq.substring(start, end) + "\n");
+          out.append(seq.substring(start, end));
+          out.append(newline);
         }
         else if (start < seq.length())
         {
-          out.append(seq.substring(start) + "\n");
+          out.append(seq.substring(start));
+          out.append(newline);
         }
       }
 
index 1407ddc..14debd4 100755 (executable)
@@ -160,11 +160,12 @@ public class PfamFile extends AlignFile
     {
       out.append(new Format("%-" + maxid + "s").form(printId(s[j]) + " "));
 
-      out.append(s[j].getSequenceAsString() + "\n");
+      out.append(s[j].getSequenceAsString());
+      out.append(newline);
       j++;
     }
 
-    out.append("\n");
+    out.append(newline);
 
     return out.toString();
   }
index dd28176..e4fb76a 100755 (executable)
@@ -80,8 +80,10 @@ public class PileUpfile extends MSFfile
 
   public String print(SequenceI[] s)
   {
-    StringBuffer out = new StringBuffer("PileUp\n\n");
-
+    StringBuffer out = new StringBuffer("PileUp");
+    out.append(newline);
+    out.append(newline);
+    
     int max = 0;
     int maxid = 0;
 
@@ -97,14 +99,18 @@ public class PileUpfile extends MSFfile
 
     out.append("   MSF: " + s[0].getSequence().length
             + "   Type: P    Check:  " + bigChecksum % 10000
-            + "   ..\n\n\n");
+            + "   ..");
+    out.append(newline);
+    out.append(newline);
+    out.append(newline);
 
     i = 0;
     while ((i < s.length) && (s[i] != null))
     {
       String seq = s[i].getSequenceAsString();
       out.append(" Name: " + printId(s[i]) + " oo  Len:  " + seq.length()
-              + "  Check:  " + checksums[i] + "  Weight:  1.00\n");
+              + "  Check:  " + checksums[i] + "  Weight:  1.00");
+      out.append(newline);
 
       if (seq.length() > max)
       {
@@ -125,7 +131,8 @@ public class PileUpfile extends MSFfile
     }
 
     maxid++;
-    out.append("\n\n//\n\n");
+    out.append(newline);out.append(newline);out.append("//");
+    out.append(newline);out.append(newline);
 
     int len = 50;
 
@@ -162,7 +169,7 @@ public class PileUpfile extends MSFfile
             }
             else
             {
-              out.append("\n");
+              out.append(newline);
             }
           }
           else
@@ -170,13 +177,13 @@ public class PileUpfile extends MSFfile
             if (start < s[j].getSequence().length)
             {
               out.append(s[j].getSequenceAsString().substring(start));
-              out.append("\n");
+              out.append(newline);
             }
             else
             {
               if (k == 0)
               {
-                out.append("\n");
+                out.append(newline);
               }
             }
           }
@@ -185,7 +192,7 @@ public class PileUpfile extends MSFfile
         j++;
       }
 
-      out.append("\n");
+      out.append(newline);
     }
 
     return out.toString();