# 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
			for f in test["import_read_files"]:
				self.cp(f,test["dir"]+("/reads%d.fastq"%i) )
				if i==1:
					line_count = util.line_count(f)
				i+=1
		else:
			self.cp(test["import_read_files"][0],test["dir"]+("/reads.fastq"))
			line_count = util.line_count(test["import_read_files"][0])

		return (line_count - line_count%4)/4

	def importDatasetReal(self,test):
		if test["sampling"]["enable"] == False:
			self.log("Subsampling disabled; Importing all reads")
			test["read_count"] = self.importReadFiles(test)
			self.log("Data set import successful")
			return

		if test["read_count"] == None:
			self.log("No target read count given for real data test, estimating using reference and avg. read length")

			fastq=sam.FASTQ(test["import_read_files"][0])
			i=0
			read=fastq.next_read()
			length_sum=0
			while read.valid and i < 10000:
				length_sum+=len(read.seq)
				i+=1
				read=fastq.next_read()
			avg_len = length_sum/i

# 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

			for f in test["import_read_files"]:
				self.cp(f,test["dir"]+("/reads%d.fastq"%i) )
				if i==1:
					line_count = util.line_count(f)
				i+=1
		else:
			self.cp(test["import_read_files"][0],test["dir"]+("/reads.fastq"))
			line_count = util.line_count(test["import_read_files"][0])

		return (line_count - line_count%4)/4

	def importDatasetReal(self,test):
		if test["sampling"]["enable"] == False:
			self.log("Subsampling disabled; Importing all reads")
			test["read_count"] = self.importReadFiles(test)
			self.log("Data set import successful")
			return

		if test["read_count"] == None:
			self.log("No target read count given for real data test, estimating using reference and avg. read length")

			fastq=sam.FASTQ(test["import_read_files"][0])
			i=0
			read=fastq.next_read()
			length_sum=0
			while read.valid and i < 10000:
				length_sum+=len(read.seq)
				i+=1
				read=fastq.next_read()
			avg_len = length_sum/i

			contig_len = gsample.index(test["reference"],self.config["fastindex_path"])["contig_len"]