X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FMegaFile.java;fp=src%2Fjalview%2Fio%2FMegaFile.java;h=2f48bf523661f964fd4e66d5ec7b4e2f929e66c7;hb=db6df7f531341ba6a7ade77103cf071cfb25e543;hp=af9889beb4b2ecf02e05ca667d9c280c16f993bb;hpb=4be0c06f705f53162b4658e382ead85a40a0cffe;p=jalview.git diff --git a/src/jalview/io/MegaFile.java b/src/jalview/io/MegaFile.java index af9889b..2f48bf5 100644 --- a/src/jalview/io/MegaFile.java +++ b/src/jalview/io/MegaFile.java @@ -143,6 +143,9 @@ public class MegaFile extends AlignFile // this can be True, False or null (meaning we don't know yet) private Boolean interleaved; + // write end of line positions as a comment + private boolean writePositionNumbers = true; + public MegaFile() { } @@ -891,17 +894,17 @@ public class MegaFile extends AlignFile int maxSequenceLength = getMaxSequenceLength(s); int numLines = maxSequenceLength / positionsPerLine + 3; // approx - /* - * Size a buffer to hold the whole output - */ - StringBuilder sb = new StringBuilder(numLines - * (maxIdLength + 2 + positionsPerLine)); - int numDataBlocks = (maxSequenceLength - 1) / positionsPerLine + 1; int spaceEvery = this.nucleotide != null && this.nucleotide ? 3 : 10; int chunksPerLine = (positionsPerLine + spaceEvery - 1) / spaceEvery; /* + * Roughly size a buffer to hold the whole output + */ + StringBuilder sb = new StringBuilder(numLines + * (maxIdLength + positionsPerLine + chunksPerLine + 10)); + + /* * Output as: #Seqid CGT AGC ACT ... or blocks of 10 for peptide */ int from = 0; @@ -936,6 +939,12 @@ public class MegaFile extends AlignFile advancedBy += subSequence.length; } } + // write last position as a comment + if (writePositionNumbers) + { + sb.append(SPACE).append(COMMENT_START).append(from + advancedBy) + .append(COMMENT_END); + } sb.append(newline); first = false; }