# Path: lib/gsample.py
# def log(msg):
# def index(reference, fastindex_path = "tools/fastindex"):
# def index_legacy(reference):
# def downsample(index, contig_filename, downsampled_filename, region_count, target_len, single_contig=False,
# 			   region_list=False, spacer_len=200):
# def csample(infile, region_size, sample_fraction, spacer_len=200, fastindex_path=""):
# def ctranslate(reference_file, sampled_index_file, sam_file, target_file, fastindex_path=""):
# 
# Path: tools/fastq2sam.py
# def encode_qname(qname, retain_petag=True):
# 	def __init__(self):
# 	def __init__(self, filename, pe):
# 	def readline(self):
# 	def next_read(self):
# 	def __init__(self):
# 	def align(read):
# 	def align(self, read, paired=False, is_read1=True):
# 	def align_pair(self, read1, read2):
# 	def align(self, read, paired=False, is_read1=True):
# 	def align_pair(self, read1, read2):
# 	def __init__(self, aligner, outfile):
# 	def write(self, what):
# 	def write_sam_header(self, reads):
# 	def write_single(self, read, to):
# 	def align_se(self, infile):
# 	def align_pe(self, infile_1, infile_2):
# class Object:
# class FASTQ:
# class Aligner:
# class DummyAligner(Aligner):
# class dwgsim(Aligner):
# class Converter:
# 
# Path: lib/sam.py
# class SAMRow:
# class SAMFile:
# class Object:
# class FASTQ:
# 	def __init__(self):
# 	def getTag(self,tag_name):
# 	def __init__(self, filename):
# 	def close(self):
# 	def hasLast(self):
# 	def getLast(self):
# 	def getCurr(self):
# 	def getHeader(self):
# 	def isSorted(self):
# 	def next(self):
# 	def __init__(self):
# 	def __init__(self, filename, write=False):
# 	def readline(self):
# 	def next_read(self):
# 	def write_read(self,read):
# 	def close(self):


import os
import shutil
import time
import yaml
import util
import simulator
	import main
from lib import gsample
from tools import fastq2sam
from lib import sam
	def makeDatasetNoSim(self,test):
		util.enterRootDir()

		if test["import_read_files"] == None or len(test["import_read_files"])==0:
			self.mate.error("Teaser: No read files given to import for test '%s'"%test["name"])
			test["type"]=None
			raise RuntimeError

		if test["paired"]:
			if len(test["import_read_files"]) != 2:
				self.mate.error("Teaser: Expected 2 files in field 'import_read_files' for paired-end test '%s', got %d"%(test["name"],len(test["import_read_files"])))
				raise RuntimeError
		else:
			if len(test["import_read_files"]) != 1:
				self.mate.error("Teaser: Expected 1 file in field 'import_read_files' for paired-end test '%s', got %d"%(test["name"],len(test["import_read_files"])))
				raise RuntimeError

		for filename in test["import_read_files"]:
			if not self.isFastq(filename):
				self.mate.error("Teaser: Unsupported read file type of '%s' for test '%s'. Expected FASTQ." % (filename,test["name"]) )
				raise RuntimeError

		if test["type"] == "simulated_custom":
			self.importDatasetCustom(test)
		elif test["type"] == "real":
			self.importDatasetReal(test)

			self.ch(test)
			self.log("Generate dummy alignments")
			aligner = fastq2sam.DummyAligner()

# Path: lib/gsample.py
# def log(msg):
# def index(reference, fastindex_path = "tools/fastindex"):
# def index_legacy(reference):
# def downsample(index, contig_filename, downsampled_filename, region_count, target_len, single_contig=False,
# 			   region_list=False, spacer_len=200):
# def csample(infile, region_size, sample_fraction, spacer_len=200, fastindex_path=""):
# def ctranslate(reference_file, sampled_index_file, sam_file, target_file, fastindex_path=""):
# 
# Path: tools/fastq2sam.py
# def encode_qname(qname, retain_petag=True):
# 	def __init__(self):
# 	def __init__(self, filename, pe):
# 	def readline(self):
# 	def next_read(self):
# 	def __init__(self):
# 	def align(read):
# 	def align(self, read, paired=False, is_read1=True):
# 	def align_pair(self, read1, read2):
# 	def align(self, read, paired=False, is_read1=True):
# 	def align_pair(self, read1, read2):
# 	def __init__(self, aligner, outfile):
# 	def write(self, what):
# 	def write_sam_header(self, reads):
# 	def write_single(self, read, to):
# 	def align_se(self, infile):
# 	def align_pe(self, infile_1, infile_2):
# class Object:
# class FASTQ:
# class Aligner:
# class DummyAligner(Aligner):
# class dwgsim(Aligner):
# class Converter:
# 
# Path: lib/sam.py
# class SAMRow:
# class SAMFile:
# class Object:
# class FASTQ:
# 	def __init__(self):
# 	def getTag(self,tag_name):
# 	def __init__(self, filename):
# 	def close(self):
# 	def hasLast(self):
# 	def getLast(self):
# 	def getCurr(self):
# 	def getHeader(self):
# 	def isSorted(self):
# 	def next(self):
# 	def __init__(self):
# 	def __init__(self, filename, write=False):
# 	def readline(self):
# 	def next_read(self):
# 	def write_read(self,read):
# 	def close(self):


# Path: lib/teaser.py
import os
import shutil
import time
import yaml
import util
import simulator
	import main
from lib import gsample
from tools import fastq2sam
from lib import sam

	def makeDatasetNoSim(self,test):
		util.enterRootDir()

		if test["import_read_files"] == None or len(test["import_read_files"])==0:
			self.mate.error("Teaser: No read files given to import for test '%s'"%test["name"])
			test["type"]=None
			raise RuntimeError

		if test["paired"]:
			if len(test["import_read_files"]) != 2:
				self.mate.error("Teaser: Expected 2 files in field 'import_read_files' for paired-end test '%s', got %d"%(test["name"],len(test["import_read_files"])))
				raise RuntimeError
		else:
			if len(test["import_read_files"]) != 1:
				self.mate.error("Teaser: Expected 1 file in field 'import_read_files' for paired-end test '%s', got %d"%(test["name"],len(test["import_read_files"])))
				raise RuntimeError

		for filename in test["import_read_files"]:
			if not self.isFastq(filename):
				self.mate.error("Teaser: Unsupported read file type of '%s' for test '%s'. Expected FASTQ." % (filename,test["name"]) )
				raise RuntimeError

		if test["type"] == "simulated_custom":
			self.importDatasetCustom(test)
		elif test["type"] == "real":
			self.importDatasetReal(test)

			self.ch(test)
			self.log("Generate dummy alignments")
			aligner = fastq2sam.DummyAligner()

			conv = fastq2sam.Converter(aligner, "mapping_comparison.sam")