示例#1
0
def test_sra2fastq_gz(method):
    infile = "SRR390728"
    outfile = bioconvert_data("SRR390728_1.fastq")
    outfile2 = bioconvert_data("SRR390728_2.fastq")
    with TempFile(suffix=".fastq.gz") as tempfile:
        converter = SRA2FASTQ(infile, tempfile.name, True)
        converter(method=method)
        outbasename, ext = os.path.splitext(tempfile.name)
        if ext == ".gz":
            outbasename, ext = os.path.splitext(outbasename)

        with gzip.open(outbasename + "_1.fastq.gz",
                       'rb') as f_in, open(outbasename + "_1.fastq",
                                           'wb') as f_out:
            shutil.copyfileobj(f_in, f_out)
        with gzip.open(outbasename + "_2.fastq.gz",
                       'rb') as f_in, open(outbasename + "_2.fastq",
                                           'wb') as f_out:
            shutil.copyfileobj(f_in, f_out)

        # Check that the output is correct with a checksum
        assert md5(outbasename + "_1.fastq") == md5(outfile)
        assert md5(outbasename + "_2.fastq") == md5(outfile2)