From: tcofoegbu Date: Mon, 11 Jan 2016 11:16:03 +0000 (+0000) Subject: JAL-1991 bug fix for some flat-file printers to check for exact modulus in order... X-Git-Tag: Release_2_10_0~330 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8dbeca869699c196f4239fb1f8909d5a4c23ee86;p=jalview.git JAL-1991 bug fix for some flat-file printers to check for exact modulus in order to avoid outputing an extra redundant header line with empty sequences --- diff --git a/src/jalview/io/ClustalFile.java b/src/jalview/io/ClustalFile.java index a9295a3..f7a45de 100755 --- a/src/jalview/io/ClustalFile.java +++ b/src/jalview/io/ClustalFile.java @@ -47,11 +47,13 @@ public class ClustalFile extends AlignFile super(source); } + @Override public void initData() { super.initData(); } + @Override public void parse() throws IOException { int i = 0; @@ -193,6 +195,7 @@ public class ClustalFile extends AlignFile } } + @Override public String print() { return print(getSeqsAsArray()); @@ -233,7 +236,7 @@ public class ClustalFile extends AlignFile maxid++; int len = 60; - int nochunks = (max / len) + 1; + int nochunks = (max / len) + (max % len > 0 ? 1 : 0); for (i = 0; i < nochunks; i++) { diff --git a/src/jalview/io/FastaFile.java b/src/jalview/io/FastaFile.java index b867ba4..4c2265c 100755 --- a/src/jalview/io/FastaFile.java +++ b/src/jalview/io/FastaFile.java @@ -77,6 +77,7 @@ public class FastaFile extends AlignFile * @throws IOException * DOCUMENT ME! */ + @Override public void parse() throws IOException { StringBuffer sb = new StringBuffer(); @@ -173,7 +174,7 @@ public class FastaFile extends AlignFile addProperties(al); for (int i = 0; i < annotations.size(); i++) { - AlignmentAnnotation aa = (AlignmentAnnotation) annotations + AlignmentAnnotation aa = annotations .elementAt(i); aa.setPadGaps(true, al.getGapCharacter()); al.addAnnotation(aa); @@ -209,7 +210,8 @@ public class FastaFile extends AlignFile out.append(newline); - int nochunks = (s[i].getLength() / len) + 1; + int nochunks = (s[i].getLength() / len) + + (s[i].getLength() % len > 0 ? 1 : 0); for (int j = 0; j < nochunks; j++) { @@ -238,6 +240,7 @@ public class FastaFile extends AlignFile * * @return DOCUMENT ME! */ + @Override public String print() { return print(getSeqsAsArray()); diff --git a/src/jalview/io/MSFfile.java b/src/jalview/io/MSFfile.java index 3de5b30..f62ad81 100755 --- a/src/jalview/io/MSFfile.java +++ b/src/jalview/io/MSFfile.java @@ -69,6 +69,7 @@ public class MSFfile extends AlignFile /** * DOCUMENT ME! */ + @Override public void parse() throws IOException { int i = 0; @@ -343,12 +344,7 @@ public class MSFfile extends AlignFile out.append(newline); int len = 50; - int nochunks = (max / len) + 1; - - if ((max % len) == 0) - { - nochunks--; - } + int nochunks = (max / len) + (max % len > 0 ? 1 : 0); for (i = 0; i < nochunks; i++) { @@ -410,6 +406,7 @@ public class MSFfile extends AlignFile * * @return DOCUMENT ME! */ + @Override public String print() { return print(getSeqsAsArray()); diff --git a/src/jalview/io/PIRFile.java b/src/jalview/io/PIRFile.java index cd3c7a0..5f5c23c 100755 --- a/src/jalview/io/PIRFile.java +++ b/src/jalview/io/PIRFile.java @@ -46,6 +46,7 @@ public class PIRFile extends AlignFile super(source); } + @Override public void parse() throws IOException { StringBuffer sequence; @@ -100,6 +101,7 @@ public class PIRFile extends AlignFile } } + @Override public String print() { return print(getSeqsAsArray()); @@ -174,7 +176,8 @@ public class PIRFile extends AlignFile } } } - int nochunks = (seq.length() / len) + 1; + int nochunks = (seq.length() / len) + + (seq.length() % len > 0 ? 1 : 0); for (int j = 0; j < nochunks; j++) { diff --git a/src/jalview/io/PileUpfile.java b/src/jalview/io/PileUpfile.java index 9570552..79c6531 100755 --- a/src/jalview/io/PileUpfile.java +++ b/src/jalview/io/PileUpfile.java @@ -76,11 +76,13 @@ public class PileUpfile extends MSFfile * * @return DOCUMENT ME! */ + @Override public String print() { return print(getSeqsAsArray()); } + @Override public String print(SequenceI[] s) { StringBuffer out = new StringBuffer("PileUp"); @@ -141,12 +143,7 @@ public class PileUpfile extends MSFfile int len = 50; - int nochunks = (max / len) + 1; - - if ((max % len) == 0) - { - nochunks--; - } + int nochunks = (max / len) + (max % len > 0 ? 1 : 0); for (i = 0; i < nochunks; i++) {