# Path: cutadapt-1.12/tests/utils.py
# def run(params, expected, inpath, inpath2=None):
# 	if type(params) is str:
# 		params = params.split()
# 	with temporary_path(expected) as tmp_fastaq:
# 		params += ['-o', tmp_fastaq ] # TODO not parallelizable
# 		params += [ datapath(inpath) ]
# 		if inpath2:
# 			params += [ datapath(inpath2) ]
# 		assert cutadapt.main(params) is None
# 		# TODO redirect standard output
# 		assert files_equal(cutpath(expected), tmp_fastaq)
# 	# TODO diff log files
# 
# def files_equal(path1, path2):
# 	return os.system("diff -u {0} {1}".format(path1, path2)) == 0
# 
# def datapath(path):
# 	return os.path.join(os.path.dirname(__file__), 'data', path)
# 
# def cutpath(path):
# 	return os.path.join(os.path.dirname(__file__), 'cut', path)
# 
# @contextmanager
# def redirect_stderr():
# 	"Send stderr to stdout. Nose doesn't capture stderr, yet."
# 	old_stderr = sys.stderr
# 	sys.stderr = sys.stdout
# 	yield
# 	sys.stderr = old_stderr
# 
# @contextmanager
# def temporary_path(name):
# 	directory = os.path.join(os.path.dirname(__file__), 'testtmp')
# 	if not os.path.isdir(directory):
# 		os.mkdir(directory)
# 	path = os.path.join(directory, name)
# 	yield path
# 	os.remove(path)


import os
import sys
	import lzma
from nose.tools import raises
from cutadapt.scripts import cutadapt
from cutadapt.compat import StringIO
from .utils import run, files_equal, datapath, cutpath, redirect_stderr, temporary_path
			run("--wildcard-file {0} {1} ACGTNNNACGT".format(wildcardtmp, adapter_type),
				expected, "wildcard_adapter.fa")
			with open(wildcardtmp) as wct:
				lines = wct.readlines()
			lines = [ line.strip() for line in lines ]
			assert lines == ['AAA 1', 'GGG 2', 'CCC 3b', 'TTT 4b']

def test_wildcard_N():
	'''test 'N' wildcard matching with no allowed errors'''
	run("-e 0 -a GGGGGGG --match-read-wildcards", "wildcardN.fa", "wildcardN.fa")

def test_illumina_adapter_wildcard():
	run("-a VCCGAMCYUCKHRKDCUBBCNUWNSGHCGU", "illumina.fastq", "illumina.fastq.gz")

def test_adapter_front():
	'''test adapter in front'''
	run("--front ADAPTER -N", "examplefront.fa", "example.fa")

def test_literal_N():
	'''test matching literal 'N's'''
	run("-N -e 0.2 -a NNNNNNNNNNNNNN", "trimN3.fasta", "trimN3.fasta")

def test_literal_N2():
	run("-N -O 1 -g NNNNNNNNNNNNNN", "trimN5.fasta", "trimN5.fasta")

def test_literal_N_brace_notation():
	'''test matching literal 'N's'''
	run("-N -e 0.2 -a N{14}", "trimN3.fasta", "trimN3.fasta")

def test_literal_N2_brace_notation():

# Path: cutadapt-1.12/tests/utils.py
# def run(params, expected, inpath, inpath2=None):
# 	if type(params) is str:
# 		params = params.split()
# 	with temporary_path(expected) as tmp_fastaq:
# 		params += ['-o', tmp_fastaq ] # TODO not parallelizable
# 		params += [ datapath(inpath) ]
# 		if inpath2:
# 			params += [ datapath(inpath2) ]
# 		assert cutadapt.main(params) is None
# 		# TODO redirect standard output
# 		assert files_equal(cutpath(expected), tmp_fastaq)
# 	# TODO diff log files
# 
# def files_equal(path1, path2):
# 	return os.system("diff -u {0} {1}".format(path1, path2)) == 0
# 
# def datapath(path):
# 	return os.path.join(os.path.dirname(__file__), 'data', path)
# 
# def cutpath(path):
# 	return os.path.join(os.path.dirname(__file__), 'cut', path)
# 
# @contextmanager
# def redirect_stderr():
# 	"Send stderr to stdout. Nose doesn't capture stderr, yet."
# 	old_stderr = sys.stderr
# 	sys.stderr = sys.stdout
# 	yield
# 	sys.stderr = old_stderr
# 
# @contextmanager
# def temporary_path(name):
# 	directory = os.path.join(os.path.dirname(__file__), 'testtmp')
# 	if not os.path.isdir(directory):
# 		os.mkdir(directory)
# 	path = os.path.join(directory, name)
# 	yield path
# 	os.remove(path)


# Path: cutadapt-1.12/tests/tests.py
import os
import sys
	import lzma
from nose.tools import raises
from cutadapt.scripts import cutadapt
from cutadapt.compat import StringIO
from .utils import run, files_equal, datapath, cutpath, redirect_stderr, temporary_path

			run("--wildcard-file {0} {1} ACGTNNNACGT".format(wildcardtmp, adapter_type),
				expected, "wildcard_adapter.fa")
			with open(wildcardtmp) as wct:
				lines = wct.readlines()
			lines = [ line.strip() for line in lines ]
			assert lines == ['AAA 1', 'GGG 2', 'CCC 3b', 'TTT 4b']

def test_wildcard_N():
	'''test 'N' wildcard matching with no allowed errors'''
	run("-e 0 -a GGGGGGG --match-read-wildcards", "wildcardN.fa", "wildcardN.fa")

def test_illumina_adapter_wildcard():
	run("-a VCCGAMCYUCKHRKDCUBBCNUWNSGHCGU", "illumina.fastq", "illumina.fastq.gz")

def test_adapter_front():
	'''test adapter in front'''
	run("--front ADAPTER -N", "examplefront.fa", "example.fa")

def test_literal_N():
	'''test matching literal 'N's'''
	run("-N -e 0.2 -a NNNNNNNNNNNNNN", "trimN3.fasta", "trimN3.fasta")

def test_literal_N2():
	run("-N -O 1 -g NNNNNNNNNNNNNN", "trimN5.fasta", "trimN5.fasta")

def test_literal_N_brace_notation():
	'''test matching literal 'N's'''
	run("-N -e 0.2 -a N{14}", "trimN3.fasta", "trimN3.fasta")

def test_literal_N2_brace_notation():

	run("-N -O 1 -g N{14}", "trimN5.fasta", "trimN5.fasta")