def test_second_too_short(): # paired-truncated.2.fastq is paired.2.fastq without the last read with redirect_stderr(): cutadapt.main( '-a XX --paired-output out.fastq'.split() + [datapath('paired.1.fastq'), datapath('paired-truncated.2.fastq')])
def test_missing_file(): with pytest.raises(SystemExit): with redirect_stderr(): main([ '-a', 'XX', '--paired-output', 'out.fastq', datapath('paired.1.fastq') ])
def test_unmatched_read_names(): # paired-swapped.1.fastq: paired.1.fastq with reads 2 and 3 swapped with redirect_stderr(): cutadapt.main( '-a XX --paired-output out.fastq'.split() + [datapath('paired-swapped.1.fastq'), datapath('paired.2.fastq')])
def test_missing_file(tmpdir): with redirect_stderr(): with pytest.raises(SystemExit): main([ '--paired-output', str(tmpdir.join('out.fastq')), datapath('paired.1.fastq') ])
def test_interleaved_neither_nor(tmpdir): """Option --interleaved used, but pairs of files given for input and output""" p1 = str(tmpdir.join("temp-paired.1.fastq")) p2 = str(tmpdir.join("temp-paired.2.fastq")) params = "-a XX --interleaved".split() with redirect_stderr(): params += ["-o", p1, "-p1", p2, "paired.1.fastq", "paired.2.fastq"] with pytest.raises(SystemExit): main(params)
def test_interleaved_neither_nor(): """Option --interleaved used, but pairs of files given for input and output""" with temporary_path("temp-paired.1.fastq") as p1: with temporary_path("temp-paired.2.fastq") as p2: params = '-a XX --interleaved'.split() with redirect_stderr(): params += ['-o', p1, '-p1', p2, 'paired.1.fastq', 'paired.2.fastq'] with pytest.raises(SystemExit): main(params)
def test_unmatched_read_names(cores): with pytest.raises(SystemExit): with temporary_path("swapped.1.fastq") as swapped: # Create a file in which reads 2 and 1 are swapped with open(datapath('paired.1.fastq')) as f: lines = f.readlines() lines = lines[0:4] + lines[8:12] + lines[4:8] + lines[12:] with open(swapped, 'w') as f: f.writelines(lines) with redirect_stderr(): main('-a XX -o out1.fastq --paired-output out2.fastq'.split() + ['--cores', str(cores)] + [swapped, datapath('paired.2.fastq')])
def test_second_too_short(cores): with pytest.raises(SystemExit): with temporary_path("truncated.2.fastq") as trunc2: # Create a truncated file in which the last read is missing with open(datapath('paired.2.fastq')) as f: lines = f.readlines() lines = lines[:-4] with open(trunc2, 'w') as f: f.writelines(lines) with redirect_stderr(): main('-a XX -o /dev/null --paired-output out.fastq'.split() + ['--cores', str(cores)] + [datapath('paired.1.fastq'), trunc2])
def test_second_too_short(tmpdir, cores): # Create a truncated file in which the last read is missing trunc2 = tmpdir.join("truncated.2.fastq") with open(datapath("paired.2.fastq")) as f: lines = f.readlines() lines = lines[:-4] trunc2.write("".join(lines)) with redirect_stderr(): with pytest.raises(SystemExit): main([ "-o", "/dev/null", "--paired-output", str(tmpdir.join("out.fastq")), "--cores", str(cores), datapath("paired.1.fastq"), str(trunc2) ])
def test_first_too_short(tmpdir, cores): # Create a truncated file in which the last read is missing trunc1 = tmpdir.join("truncated.1.fastq") with open(datapath('paired.1.fastq')) as f: lines = f.readlines() lines = lines[:-4] trunc1.write(''.join(lines)) with redirect_stderr(): with pytest.raises(SystemExit): main([ '-o', '/dev/null', '--paired-output', str(tmpdir.join('out.fastq')), '--cores', str(cores), str(trunc1), datapath('paired.2.fastq') ])
def test_linked_anywhere(): with pytest.raises(SystemExit): with redirect_stderr(): main(['-b', 'AAA...TTT', datapath('linked.fasta')])
def test_missing_file(tmpdir): with redirect_stderr(): with pytest.raises(SystemExit): main(["--paired-output", str(tmpdir.join("out.fastq")), datapath("paired.1.fastq")])
def test_qualfile_only(): with pytest.raises(SystemExit): with redirect_stderr(): main(['file.qual'])
def test_two_fastqs(): with redirect_stderr(): cutadapt.main([datapath('paired.1.fastq'), datapath('paired.2.fastq')])
def test_paired_end_missing_file(): with redirect_stderr(): cutadapt.main([ '-a', 'XX', '--paired-output', 'out.fastq', datapath('paired.1.fastq') ])
def test_no_args(): with redirect_stderr(): cutadapt.main([])
def test_second_too_short(): # paired-truncated.2.fastq is paired.2.fastq without the last read with redirect_stderr(): cutadapt.main('-a XX --paired-output out.fastq'.split() + [datapath('paired.1.fastq'), datapath('paired-truncated.2.fastq')])
def test_anywhere_anchored_3p(): with redirect_stderr(): main(['-b', 'TTT$', datapath('small.fastq')])
def test_two_fastqs(): with pytest.raises(SystemExit): with redirect_stderr(): main([datapath('paired.1.fastq'), datapath('paired.2.fastq')])
def test_qualfile_only(): with redirect_stderr(): cutadapt.main(['file.qual'])
def test_no_args(): with pytest.raises(SystemExit): with redirect_stderr(): main([])
def test_unmatched_read_names(): # paired-swapped.1.fastq: paired.1.fastq with reads 2 and 3 swapped with redirect_stderr(): cutadapt.main('-a XX --paired-output out.fastq'.split() + [datapath('paired-swapped.1.fastq'), datapath('paired.2.fastq')])
def test_linked_anywhere(): with redirect_stderr(): main(['-b', 'AAA...TTT', datapath('linked.fasta')])
def test_non_iupac_characters(): with redirect_stderr(): main(['-a', 'ZACGT', datapath('small.fastq')])
def test_paired_end_missing_file(): with redirect_stderr(): cutadapt.main(['-a', 'XX', '--paired-output', 'out.fastq', datapath('paired.1.fastq')])
def test_non_iupac_characters(run): with pytest.raises(SystemExit): with redirect_stderr(): main(['-a', 'ZACGT', datapath('small.fastq')])
def test_non_iupac_characters(): with pytest.raises(SystemExit): with redirect_stderr(): main(['-a', 'ZACGT', datapath('small.fastq')])
def test_anywhere_anchored_3p(): with pytest.raises(SystemExit): with redirect_stderr(): main(['-b', 'TTT$', datapath('small.fastq')])
def test_no_args(): with redirect_stderr(): main([])