From e601d78bc7762386f570e346a803684c43a66ff1 Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 5 Jan 2011 15:52:16 +0000 Subject: [PATCH] JAL-727 --- src/MCview/PDBChain.java | 15 +- src/jalview/io/AMSAFile.java | 4 +- src/jalview/io/AnnotationFile.java | 254 +++++++++++++++++++++---------- src/jalview/io/AppletFormatAdapter.java | 15 +- src/jalview/io/BLCFile.java | 12 +- src/jalview/io/ClustalFile.java | 6 +- src/jalview/io/FastaFile.java | 6 +- src/jalview/io/FeaturesFile.java | 60 +++++--- src/jalview/io/FileParse.java | 13 +- src/jalview/io/FormatAdapter.java | 5 +- src/jalview/io/MSFfile.java | 28 ++-- src/jalview/io/PIRFile.java | 30 ++-- src/jalview/io/PfamFile.java | 5 +- src/jalview/io/PileUpfile.java | 25 +-- 14 files changed, 326 insertions(+), 152 deletions(-) diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index c7eec35..779b4f0 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -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; diff --git a/src/jalview/io/AMSAFile.java b/src/jalview/io/AMSAFile.java index 0a4624b..fb2a38b 100644 --- a/src/jalview/io/AMSAFile.java +++ b/src/jalview/io/AMSAFile.java @@ -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); } } } diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index ef46b86..d4284a2 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -27,8 +27,41 @@ import jalview.schemes.*; public class AnnotationFile { - StringBuffer text = new StringBuffer("JALVIEW_ANNOTATION\n" - + "# Created: " + new java.util.Date() + "\n\n"); + public AnnotationFile() + { + init(); + } + + /** + * character used to write newlines + */ + protected String newline = System.getProperty("line.separator"); + + /** + * set new line string and reset the output buffer + * + * @param nl + */ + public void setNewlineString(String nl) + { + newline = nl; + init(); + } + + public String getNewlineString() + { + return newline; + } + + StringBuffer text; + + private void init() + { + text = new StringBuffer("JALVIEW_ANNOTATION"+newline + "# Created: " + + new java.util.Date() + newline + newline); + refSeq = null; + refSeqId = null; + } /** * convenience method for pre-2.4 feature files which have no view, hidden @@ -118,7 +151,9 @@ public class AnnotationFile { if (refSeq != null) { - text.append("\nSEQUENCE_REF\tALIGNMENT\n"); + text.append(newline); + text.append("SEQUENCE_REF\tALIGNMENT"); + text.append(newline); } refSeq = null; @@ -129,7 +164,10 @@ public class AnnotationFile if (refSeq == null || refSeq != row.sequenceRef) { refSeq = row.sequenceRef; - text.append("\nSEQUENCE_REF\t" + refSeq.getName() + "\n"); + text.append(newline); + text.append("SEQUENCE_REF\t"); + text.append(refSeq.getName()); + text.append(newline); } } // mark any group references for the row @@ -138,7 +176,9 @@ public class AnnotationFile if (refGroup != null) { - text.append("\nGROUP_REF\tALIGNMENT\n"); + text.append(newline); + text.append("GROUP_REF\tALIGNMENT"); + text.append(newline); } refGroup = null; @@ -148,7 +188,10 @@ public class AnnotationFile if (refGroup == null || refGroup != row.groupRef) { refGroup = row.groupRef; - text.append("\nGROUP_REF\t" + refGroup.getName() + "\n"); + text.append(newline); + text.append("GROUP_REF\t"); + text.append(refGroup.getName()); + text.append(newline); } } @@ -194,16 +237,16 @@ public class AnnotationFile if (row.getThreshold() != null) { - graphLine - .append("GRAPHLINE\t" - + row.label - + "\t" - + row.getThreshold().value - + "\t" - + row.getThreshold().label - + "\t" - + jalview.util.Format.getHexString(row - .getThreshold().colour) + "\n"); + graphLine.append("GRAPHLINE\t"); + graphLine.append(row.label); + graphLine.append("\t"); + graphLine.append(row.getThreshold().value); + graphLine.append("\t"); + graphLine.append(row.getThreshold().label); + graphLine.append("\t"); + graphLine.append(jalview.util.Format.getHexString(row + .getThreshold().colour)); + graphLine.append(newline); } if (row.graphGroup > -1) @@ -308,25 +351,32 @@ public class AnnotationFile if (row.hasScore()) text.append("\t" + row.score); - text.append("\n"); + text.append(newline); if (color != null && color != java.awt.Color.black && oneColour) { - colours.append("COLOUR\t" + row.label + "\t" - + jalview.util.Format.getHexString(color) + "\n"); + colours.append("COLOUR\t"); + colours.append(row.label); + colours.append("\t"); + colours.append(jalview.util.Format.getHexString(color)); + colours.append(newline); } if (row.scaleColLabel || row.showAllColLabels || row.centreColLabels) { - rowprops.append("ROWPROPERTIES\t" + row.label); - rowprops.append("\tscaletofit=" + row.scaleColLabel); - rowprops.append("\tshowalllabs=" + row.showAllColLabels); - rowprops.append("\tcentrelabs=" + row.centreColLabels); - rowprops.append("\n"); + rowprops.append("ROWPROPERTIES\t"); + rowprops.append(row.label); + rowprops.append("\tscaletofit="); + rowprops.append(row.scaleColLabel); + rowprops.append("\tshowalllabs="); + rowprops.append(row.showAllColLabels); + rowprops.append("\tcentrelabs="); + rowprops.append(row.centreColLabels); + rowprops.append(newline); } } - text.append("\n"); + text.append(newline); text.append(colours.toString()); text.append(graphLine.toString()); @@ -336,7 +386,8 @@ public class AnnotationFile Enumeration en = graphGroup.elements(); while (en.hasMoreElements()) { - text.append(en.nextElement() + "\n"); + text.append(en.nextElement()); + text.append(newline); } } text.append(rowprops.toString()); @@ -349,12 +400,17 @@ public class AnnotationFile if (properties != null) { - text.append("\n\nALIGNMENT"); + text.append(newline); + text.append(newline); + text.append("ALIGNMENT"); Enumeration en = properties.keys(); while (en.hasMoreElements()) { String key = en.nextElement().toString(); - text.append("\t" + key + "=" + properties.get(key)); + text.append("\t"); + text.append(key); + text.append("="); + text.append(properties.get(key)); } // TODO: output alignment visualization settings here if required @@ -380,61 +436,90 @@ public class AnnotationFile else { seqrep = sg.getSeqrep(); - text.append("SEQUENCE_REF\t" + seqrep.getName() + "\n"); - text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t" - + (seqrep.findPosition(sg.getStartRes())) + "\t" - + (seqrep.findPosition(sg.getEndRes())) + "\t" + "-1\t"); + text.append("SEQUENCE_REF\t"); + text.append(seqrep.getName()); + text.append(newline); + text.append("SEQUENCE_GROUP\t"); + text.append(sg.getName()); + text.append("\t"); + text.append((seqrep.findPosition(sg.getStartRes()))); + text.append("\t"); + text.append((seqrep.findPosition(sg.getEndRes()))); + text.append("\t"); + text.append("-1\t"); } for (int s = 0; s < sg.getSize(); s++) { - text.append(sg.getSequenceAt(s).getName() + "\t"); + text.append(sg.getSequenceAt(s).getName()); + text.append("\t"); } - - text.append("\nPROPERTIES\t" + sg.getName() + "\t"); + text.append(newline); + text.append("PROPERTIES\t"); + text.append(sg.getName()); + text.append("\t"); if (sg.getDescription() != null) { - text.append("description=" + sg.getDescription() + "\t"); + text.append("description="); + text.append(sg.getDescription()); + text.append("\t"); } if (sg.cs != null) { - text.append("colour=" + ColourSchemeProperty.getColourName(sg.cs) - + "\t"); + text.append("colour="); + text.append(ColourSchemeProperty.getColourName(sg.cs)); + text.append("\t"); if (sg.cs.getThreshold() != 0) { - text.append("pidThreshold=" + sg.cs.getThreshold()); + text.append("pidThreshold="); + text.append(sg.cs.getThreshold()); } if (sg.cs.conservationApplied()) { - text.append("consThreshold=" + sg.cs.getConservationInc() + "\t"); + text.append("consThreshold="); + text.append(sg.cs.getConservationInc()); + text.append("\t"); } } - text.append("outlineColour=" - + jalview.util.Format.getHexString(sg.getOutlineColour()) - + "\t"); - - text.append("displayBoxes=" + sg.getDisplayBoxes() + "\t"); - text.append("displayText=" + sg.getDisplayText() + "\t"); - text.append("colourText=" + sg.getColourText() + "\t"); - text.append("showUnconserved=" + sg.getShowNonconserved() + "\t"); + text.append("outlineColour="); + text.append(jalview.util.Format.getHexString(sg.getOutlineColour())); + text.append("\t"); + + text.append("displayBoxes="); + text.append(sg.getDisplayBoxes()); + text.append("\t"); + text.append("displayText="); + text.append(sg.getDisplayText()); + text.append("\t"); + text.append("colourText="); + text.append(sg.getColourText()); + text.append("\t"); + text.append("showUnconserved="); + text.append(sg.getShowNonconserved()); + text.append("\t"); if (sg.textColour != java.awt.Color.black) { - text.append("textCol1=" - + jalview.util.Format.getHexString(sg.textColour) + "\t"); + text.append("textCol1="); + text.append(jalview.util.Format.getHexString(sg.textColour)); + text.append("\t"); } if (sg.textColour2 != java.awt.Color.white) { - text.append("textCol2=" - + jalview.util.Format.getHexString(sg.textColour2) + "\t"); + text.append("textCol2="); + text.append(jalview.util.Format.getHexString(sg.textColour2)); + text.append("\t"); } if (sg.thresholdTextColour != 0) { - text.append("textColThreshold=" + sg.thresholdTextColour + "\t"); + text.append("textColThreshold="); + text.append(sg.thresholdTextColour); + text.append("\t"); } if (sg.idColour != null) { - text.append("idColour=" - + jalview.util.Format.getHexString(sg.idColour) + "\t"); + text.append("idColour="); + text.append(jalview.util.Format.getHexString(sg.idColour)); + text.append("\t"); } if (sg.isHidereps()) { @@ -447,9 +532,11 @@ public class AnnotationFile if (seqrep != null) { // terminate the last line and clear the sequence ref for the group - text.append("\nSEQUENCE_REF"); + text.append(newline); + text.append("SEQUENCE_REF"); } - text.append("\n\n"); + text.append(newline); + text.append(newline); } } @@ -502,7 +589,7 @@ public class AnnotationFile public boolean parseAnnotationFrom(AlignmentI al, BufferedReader in) throws Exception { - boolean modified=false; + boolean modified = false; String groupRef = null; Hashtable groupRefRows = new Hashtable(); @@ -526,10 +613,11 @@ public class AnnotationFile if (aa[aai].autoCalculated) { // make a note of the name and description - autoAnnots - .put(autoAnnotsKey(aa[aai], aa[aai].sequenceRef, (aa[aai].groupRef==null ? null : aa[aai].groupRef.getName()) - ), - new Integer(1)); + autoAnnots.put( + autoAnnotsKey(aa[aai], aa[aai].sequenceRef, + (aa[aai].groupRef == null ? null + : aa[aai].groupRef.getName())), + new Integer(1)); } } } @@ -578,23 +666,26 @@ public class AnnotationFile { // TODO: use graduated colour def'n here too colourAnnotations(al, st.nextToken(), st.nextToken()); - modified=true;continue; + modified = true; + continue; } else if (token.equalsIgnoreCase("COMBINE")) { combineAnnotations(al, st); - modified=true;continue; + modified = true; + continue; } else if (token.equalsIgnoreCase("ROWPROPERTIES")) { addRowProperties(al, st); - modified=true;continue; + modified = true; + continue; } else if (token.equalsIgnoreCase("GRAPHLINE")) { addLine(al, st); - modified=true; + modified = true; continue; } @@ -659,18 +750,21 @@ public class AnnotationFile else if (token.equalsIgnoreCase("PROPERTIES")) { addProperties(al, st); - modified=true; continue; + modified = true; + continue; } else if (token.equalsIgnoreCase("BELOW_ALIGNMENT")) { setBelowAlignment(al, st); - modified=true;continue; + modified = true; + continue; } else if (token.equalsIgnoreCase("ALIGNMENT")) { addAlignmentDetails(al, st); - modified=true;continue; + modified = true; + continue; } // Parse out the annotation row @@ -742,8 +836,8 @@ public class AnnotationFile annotation.score = score; if (!overrideAutoAnnot - && autoAnnots - .containsKey(autoAnnotsKey(annotation, refSeq, groupRef))) + && autoAnnots.containsKey(autoAnnotsKey(annotation, refSeq, + groupRef))) { // skip - we've already got an automatic annotation of this type. continue; @@ -791,7 +885,7 @@ public class AnnotationFile } } // and set modification flag - modified=true; + modified = true; } // Finally, resolve the groupRefs Enumeration en = groupRefRows.keys(); @@ -838,16 +932,12 @@ public class AnnotationFile return modified; } - private Object autoAnnotsKey(AlignmentAnnotation annotation, SequenceI refSeq, String groupRef) + private Object autoAnnotsKey(AlignmentAnnotation annotation, + SequenceI refSeq, String groupRef) { - return annotation.graph - + "\t" - + annotation.label - + "\t" - + annotation.description - + "\t" - + (refSeq != null ? refSeq - .getDisplayId(true) : ""); + return annotation.graph + "\t" + annotation.label + "\t" + + annotation.description + "\t" + + (refSeq != null ? refSeq.getDisplayId(true) : ""); } Annotation parseAnnotation(String string, int graphStyle) @@ -1387,7 +1477,7 @@ public class AnnotationFile else { sp.append(atos.substring(p)); - sp.append("\n"); + sp.append(newline); } p = cp + 1; } while (p > 0); diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 5eb4d2b..d42157b 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -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()); diff --git a/src/jalview/io/BLCFile.java b/src/jalview/io/BLCFile.java index d0eb80e..f024415 100755 --- a/src/jalview/io/BLCFile.java +++ b/src/jalview/io/BLCFile.java @@ -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(); } diff --git a/src/jalview/io/ClustalFile.java b/src/jalview/io/ClustalFile.java index 4c700ed..7e22f3d 100755 --- a/src/jalview/io/ClustalFile.java +++ b/src/jalview/io/ClustalFile.java @@ -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(); diff --git a/src/jalview/io/FastaFile.java b/src/jalview/io/FastaFile.java index 5a15862..b8e001a 100755 --- a/src/jalview/io/FastaFile.java +++ b/src/jalview/io/FastaFile.java @@ -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); } } diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 7c70b54..64bb539 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -607,7 +607,7 @@ public class FeaturesFile extends AlignFile } else if (tag != null && tag.equalsIgnoreCase("br")) { - sb.append("\n"); + sb.append(newline); } else if (token.startsWith("lt;")) { @@ -726,7 +726,10 @@ public class FeaturesFile extends AlignFile color = Format.getHexString(new java.awt.Color(Integer .parseInt(visible.get(type).toString()))); } - out.append(type + "\t" + color + "\n"); + out.append(type); + out.append("\t"); + out.append(color); + out.append(newline); } } // Work out which groups are both present and visible @@ -765,7 +768,10 @@ public class FeaturesFile extends AlignFile if (groups.size() > 0 && groupIndex < groups.size()) { group = groups.elementAt(groupIndex).toString(); - out.append("\nSTARTGROUP\t" + group + "\n"); + out.append(newline); + out.append("STARTGROUP\t"); + out.append(group); + out.append(newline); } else { @@ -838,22 +844,28 @@ public class FeaturesFile extends AlignFile out.append("\t"); } - out.append(seqs[i].getName() - + "\t-1\t" - + next[j].begin - + "\t" - + next[j].end - + "\t" - + next[j].type - + ((next[j].score != Float.NaN) ? "\t" + next[j].score - + "\n" : "\n")); + out.append(seqs[i].getName()); + out.append("\t-1\t"); + out.append(next[j].begin); + out.append("\t"); + out.append(next[j].end); + out.append("\t"); + out.append(next[j].type); + if (next[j].score != Float.NaN) + { + out.append("\t"); + out.append(next[j].score); + } + out.append(newline); } } } if (group != null) { - out.append("ENDGROUP\t" + group + "\n"); + out.append("ENDGROUP\t"); + out.append(group); + out.append(newline); groupIndex++; } else @@ -912,13 +924,24 @@ public class FeaturesFile extends AlignFile source = next[j].getDescription(); } - out.append(seqs[i].getName() + "\t" + source + "\t" - + next[j].type + "\t" + next[j].begin + "\t" - + next[j].end + "\t" + next[j].score + "\t"); + out.append(seqs[i].getName()); + out.append("\t"); + out.append(source); + out.append("\t"); + out.append(next[j].type); + out.append( "\t"); + out.append( next[j].begin ); + out.append("\t"); + out.append( + next[j].end); + out.append( "\t"); + out.append( next[j].score); + out.append( "\t"); if (next[j].getValue("STRAND") != null) { - out.append(next[j].getValue("STRAND") + "\t"); + out.append(next[j].getValue("STRAND")); + out.append( "\t"); } else { @@ -933,13 +956,14 @@ public class FeaturesFile extends AlignFile { out.append("."); } + // TODO: verify/check GFF - should there be a /t here before attribute output ? if (next[j].getValue("ATTRIBUTES") != null) { out.append(next[j].getValue("ATTRIBUTES")); } - out.append("\n"); + out.append(newline); } } diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index 4714b8f..0515507 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -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 diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index 79a9190..a71d645 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -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(); diff --git a/src/jalview/io/MSFfile.java b/src/jalview/io/MSFfile.java index 1f38ca0..28f1f97 100755 --- a/src/jalview/io/MSFfile.java +++ b/src/jalview/io/MSFfile.java @@ -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(); diff --git a/src/jalview/io/PIRFile.java b/src/jalview/io/PIRFile.java index ef06b0c..fcd790e 100755 --- a/src/jalview/io/PIRFile.java +++ b/src/jalview/io/PIRFile.java @@ -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); } } diff --git a/src/jalview/io/PfamFile.java b/src/jalview/io/PfamFile.java index 1407ddc..14debd4 100755 --- a/src/jalview/io/PfamFile.java +++ b/src/jalview/io/PfamFile.java @@ -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(); } diff --git a/src/jalview/io/PileUpfile.java b/src/jalview/io/PileUpfile.java index dd28176..e4fb76a 100755 --- a/src/jalview/io/PileUpfile.java +++ b/src/jalview/io/PileUpfile.java @@ -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(); -- 1.7.10.2