示例#1
0
 def test_fastqreader_dos(self):
     # DOS line breaks
     with open('tests/data/dos.fastq', 'rb') as f:
         assert b'\r\n' in f.read()
     with FastqReader("tests/data/dos.fastq") as f:
         dos_reads = list(f)
     with FastqReader("tests/data/small.fastq") as f:
         unix_reads = list(f)
     assert dos_reads == unix_reads
示例#2
0
    def test_two_header_detection(self):
        fastq = BytesIO(b'@r1\nACG\n+r1\nHHH\n@r2\nT\n+r2\n#\n')
        with FastqReader(fastq) as fq:
            assert fq.two_headers
            list(fq)

        fastq = BytesIO(b'@r1\nACG\n+\nHHH\n@r2\nT\n+r2\n#\n')
        with FastqReader(fastq) as fq:
            assert not fq.two_headers
            list(fq)
示例#3
0
 def test_half_record_line_numbers(self):
     fastq = BytesIO(b'@r\nACG\n+\nHH\n')
     # Choose the buffer size such that only parts of the record fit
     # We want to ensure that the line number is reset properly
     # after the record has been half-parsed
     buffer_size = len('@r\nACG\n+\n')
     with raises(FastqFormatError) as info:
         with FastqReader(fastq, buffer_size=buffer_size) as fq:
             list(fq)  # pragma: no cover
     assert 'Length of sequence and qualities differ' in info.value.message
     assert info.value.line == 3
示例#4
0
    def test_context_manager(self):
        filename = "tests/data/simple.fastq"
        with open(filename, 'rb') as f:
            assert not f.closed
            _ = list(dnaio.open(f))
            assert not f.closed
        assert f.closed

        with FastqReader(filename) as sr:
            tmp_sr = sr
            assert not sr._file.closed
            _ = list(sr)
            assert not sr._file.closed
        assert tmp_sr._file is None
示例#5
0
 def test_second_header_not_equal(self):
     fastq = BytesIO(b'@r1\nACG\n+xy\nXXX\n')
     with raises(FastqFormatError) as info:
         with FastqReader(fastq) as fq:
             list(fq)  # pragma: no cover
     assert "Sequence descriptions don't match" in info.value.message
示例#6
0
 def test_differing_lengths(self, s, line):
     fastq = BytesIO(s)
     with raises(FastqFormatError) as info:
         with FastqReader(fastq) as fq:
             list(fq)
     assert info.value.line == line
示例#7
0
 def test_fastq_incomplete(self, s, line):
     fastq = BytesIO(s)
     with raises(FastqFormatError) as info:
         with FastqReader(fastq) as fq:
             list(fq)
     assert info.value.line == line
示例#8
0
 def test_empty_fastq(self):
     with FastqReader(BytesIO(b'')) as fq:
         assert list(fq) == []
示例#9
0
 def test_fastq_wrongformat(self):
     with raises(FastqFormatError) as info:
         with FastqReader("tests/data/withplus.fastq") as f:
             list(f)  # pragma: no cover
     assert info.value.line == 2
示例#10
0
 def test_fastqreader_buffersize_too_small(self):
     with raises(ValueError) as e:
         with FastqReader("tests/data/simple.fastq", buffer_size=0) as f:
             _ = list(f)  # pragma: no cover
     assert "buffer size too small" in e.value.args[0]
示例#11
0
 def test_fastqreader_buffersize(self, buffer_size):
     with FastqReader("tests/data/simple.fastq",
                      buffer_size=buffer_size) as f:
         reads = list(f)
     assert reads == simple_fastq
示例#12
0
 def test_fastqreader(self):
     with FastqReader(SIMPLE_FASTQ) as f:
         reads = list(f)
     assert reads == simple_fastq
示例#13
0
 def test_fastqreader(self):
     with FastqReader("tests/data/simple.fastq") as f:
         reads = list(f)
     assert reads == simple_fastq