Fix ordering of assignments in FastQReader constructor. #878

Merged
merged 1 commit into from May 26, 2017
Jump to file or symbol
Failed to load files and symbols.
+29 −2
Split
@@ -90,8 +90,8 @@ public FastqReader(final BufferedReader reader) {
public FastqReader(final File file, final BufferedReader reader,boolean skipBlankLines) {
this.fastqFile = file;
this.reader = reader;
- this.nextRecord = readNextRecord();
this.skipBlankLines = skipBlankLines;
+ this.nextRecord = readNextRecord();
}
public FastqReader(final File file, final BufferedReader reader) {
@@ -3,7 +3,7 @@ package htsjdk.samtools.fastq
import java.io.{BufferedReader, File, StringReader}
import htsjdk.UnitSpec
-import htsjdk.samtools.SAMUtils
+import htsjdk.samtools.{SAMException, SAMUtils}
import htsjdk.samtools.util.IOUtil
import scala.util.Random
@@ -106,6 +106,33 @@ class FastqReaderWriterTest extends UnitSpec {
in.close()
}
+ it should "honor skipBlankLines when requested" in {
+ val fastq =
+ """
+ |
+ |@SL-XBG:1:1:4:1663#0/2
+ |NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
+ |+SL-XBG:1:1:4:1663#0/2
+ |BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ """.stripMargin
+ val reader = new BufferedReader(new StringReader(fastq))
+ val in = new FastqReader(null, reader, true)
+ while (in.hasNext) in.next()
+ }
+
+ it should "fail on blank lines when skipBlankLines is false" in {
+ val fastq =
+ """
+ |
+ |@SL-XBG:1:1:4:1663#0/2
+ |NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
+ |+SL-XBG:1:1:4:1663#0/2
+ |BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ """.stripMargin
+ val reader = new BufferedReader(new StringReader(fastq))
+ an[SAMException] shouldBe thrownBy { val in = new FastqReader(null, reader, false) }
+ }
+
it should "fail on a truncated file" in {
val fastq =
"""