def test_trim_fastq_exception():
    passed = False
    try:
        oxbs_qc_func.trim_fastq('test_data/mjb042_oxBS_R1.txt', -1,
                                'mjb042_oxBS_R1.fq')  ### Invalid -1
    except oxbs_qc_func.TrimFastqException:
        passed = True
    assert passed

    passed = False
    try:
        x = oxbs_qc_func.trim_fastq(
            'test_data/mjb042_oxBS_R1.txt.gz', 1,
            'test_data/mjb042_oxBS_R1.txt.gz')  ## input == output
    except oxbs_qc_func.TrimFastqException:
        passed = True
    assert passed

    passed = False
    try:
        x = oxbs_qc_func.trim_fastq(
            'test_data/mjb042_oxBS_R1.txt.gz', 1,
            '/nonsense/mjb042_oxBS_R1.txt.gz')  ## output dir does not exists
    except oxbs_qc_func.TrimFastqException:
        passed = True
    assert passed
def test_trim_fastq_exception():
    passed= False
    try:
        oxbs_qc_func.trim_fastq('test_data/mjb042_oxBS_R1.txt', -1, 'mjb042_oxBS_R1.fq') ### Invalid -1
    except oxbs_qc_func.TrimFastqException:
        passed= True
    assert passed

    passed= False
    try:
        x= oxbs_qc_func.trim_fastq('test_data/mjb042_oxBS_R1.txt.gz', 1, 'test_data/mjb042_oxBS_R1.txt.gz') ## input == output
    except oxbs_qc_func.TrimFastqException:
        passed= True
    assert passed

    passed= False
    try:
        x= oxbs_qc_func.trim_fastq('test_data/mjb042_oxBS_R1.txt.gz', 1, '/nonsense/mjb042_oxBS_R1.txt.gz') ## output dir does not exists
    except oxbs_qc_func.TrimFastqException:
        passed= True
    assert passed
def test_trim_fastq_1():
    try:
        os.makedirs('test_out')
    except OSError:
        pass
    xout= oxbs_qc_func.trim_fastq('test_data/mjb042_oxBS_R1.txt.gz', 20, 'test_out/mjb042_oxBS_R1.fq')
    assert xout
    assert os.path.exists('test_out/mjb042_oxBS_R1.fq.gz') ## Note .gz included!

    ## Same number of lines in input and output
    tfq= gzip.open('test_out/mjb042_oxBS_R1.fq.gz').readlines()
    fq= gzip.open('test_data/mjb042_oxBS_R1.txt.gz').readlines()
    assert len(tfq) == len(fq)

    ## Lenght of read AND quality == 20
    read_quality_qlen= [len(tfq[x].strip()) for x in range(1, 100, 2)]
    assert set(read_quality_qlen) == set([20])
def test_trim_fastq_1():
    try:
        os.makedirs('test_out')
    except OSError:
        pass
    xout = oxbs_qc_func.trim_fastq('test_data/mjb042_oxBS_R1.txt.gz', 20,
                                   'test_out/mjb042_oxBS_R1.fq')
    assert xout
    assert os.path.exists(
        'test_out/mjb042_oxBS_R1.fq.gz')  ## Note .gz included!

    ## Same number of lines in input and output
    tfq = gzip.open('test_out/mjb042_oxBS_R1.fq.gz').readlines()
    fq = gzip.open('test_data/mjb042_oxBS_R1.txt.gz').readlines()
    assert len(tfq) == len(fq)

    ## Lenght of read AND quality == 20
    read_quality_qlen = [len(tfq[x].strip()) for x in range(1, 100, 2)]
    assert set(read_quality_qlen) == set([20])