import os
import pytest
import gzip
import tempfile
import shutil
from utils import run, dpath, rm, symlink_in_tempdir

def test_cutadapt_simple(sample1_se_fq):
    snakefile = '''
                rule cutadapt:
                    input:
                        fastq='sample1_R1.fastq.gz'
                    output:
                        fastq='sample1_R1.trim.fastq.gz'
                    params: extra='-a AAA'
                    wrapper: {wrapper}
                '''
    input_data_func=symlink_in_tempdir(sample1_se_fq, 'sample1_R1.fastq.gz')

    def check():
        """
        check for line lengths and that they are at least different sized
        """
        a = sum(1 for _ in gzip.open('sample1_R1.fastq.gz'))
        b = sum(1 for _ in gzip.open('sample1_R1.trim.fastq.gz'))
        assert a == b == 9924

        assert os.path.getsize('sample1_R1.fastq.gz') != os.path.getsize('sample1_R1.trim.fastq.gz')

    run(dpath('../wrappers/cutadapt'), snakefile, check, input_data_func)

@@ -514,44 +514,1064 @@
 dir(
-sample1_se_fq, 'sample1_R1.fastq.gz'
+%0A        %7B%0A            sample1_se_fq: 'sample1_R1.fastq.gz'%0A        %7D%0A    )%0A%0A    def check():%0A        %22%22%22%0A        check for line lengths and that they are at least different sized%0A        %22%22%22%0A        a = sum(1 for _ in gzip.open('sample1_R1.fastq.gz'))%0A        b = sum(1 for _ in gzip.open('sample1_R1.trim.fastq.gz'))%0A        assert a == b == 9924%0A%0A        assert os.path.getsize('sample1_R1.fastq.gz') != os.path.getsize('sample1_R1.trim.fastq.gz')%0A%0A    run(dpath('../wrappers/cutadapt'), snakefile, check, input_data_func)%0A%0A%0Adef test_cutadapt_simple_with_log(sample1_se_fq):%0A    snakefile = '''%0A                rule cutadapt:%0A                    input:%0A                        fastq='sample1_R1.fastq.gz'%0A                    output:%0A                        fastq='sample1_R1.trim.fastq.gz'%0A                    params: extra='-a AAA'%0A                    log: 'sample1.cutadapt.log'%0A                    wrapper: %7Bwrapper%7D%0A                '''%0A    input_data_func=symlink_in_tempdir(%0A        %7B%0A            sample1_se_fq: 'sample1_R1.fastq.gz'%0A        %7D%0A    
 )%0A%0A 
@@ -1832,32 +1832,109 @@
 t a == b == 9924
+%0A        assert 'This is cutadapt' in open('sample1.cutadapt.log').readline()
 %0A%0A        assert
@@ -2013,32 +2013,32 @@
 rim.fastq.gz')%0A%0A
-
     run(dpath('.
@@ -2075,28 +2075,29 @@
 le, check, input_data_func)%0A
+%0A

update cutadapt test with new symlink_in_tempdir