# Path: lib/util.py
# STATUS_NORMAL=1
# STATUS_MAX_MEMORY_EXCEEDED=2
# STATUS_MAX_RUNTIME_EXCEEDED=3
# MAX_LEN_OUT = 10000
# def runAndMeasure(command,detailed=True,maxtime=0,maxmem=0):
# def runSimple(command):
# def runAndMeasureInternal(return_queue,command,maxtime=0,maxmem=0):
# def runInternal(control_queue,command,max_memory):
# def measureProcess(queue, initial_pids, command, measurement_interval=1, max_runtime=0, max_memory=0, debug=False):
# 	def extendTargets(targets, proc):
# 	def killTargets(targets):
# 	def updateTargets(targets, metrics):
# 	def updateMetrics(target, metrics):
# def loadConfig(name, parent_dir="", already_included=[]):
# def setCallDir(d):
# def setRootDir(d):
# def enterCallDir():
# def enterRootDir():
# def getRootDir():
# def nl2br(text):
# def msg(text="", level=1):
# def yes_no(b):
# def md5(text):
# def merge(x, y):
# def formatFilesize(n):
# def percent(val, base, offset=0):
# def abs_path(path):
# def get_sam_header_line_count(filename):
# def is_sam_sorted(filename):
# def sort_sam(filename,threads=1):
# def sort_sam_picard(filename,threads=-1):
# def line_count(filename):
# def sanitize_string(s):
# def makeExportDropdown(plot_id,csv_filename):
# def parseMD(md,seq):


from stats import *
from sam import *
from lib import util
	import sys
			if dont_advance_test:
				dont_advance_test = False
			else:
				if sam_test.next():
					self.stats.total_testee += 1
				else:
					if not warned_testee_end:
						if self.stats.total_testee == 0:
							self.error("Unexpectedly reached end of mapper output", self.testee_filename, sam_comp.getCurr().qname)
						else:
							self.warn("Unexpectedly reached end of mapper output", self.testee_filename, sam_comp.getCurr().qname)
						warned_testee_end = True

					self.stats.not_found += 1
					self.export_read("fail", sam_comp.getCurr(), sam_comp.getCurr(), "not_found")
					continue

			#Check if source read identifiers are equal
			#If source read is not equal, theres been a shift in the rows of one of the alignments
			#which we have to adapt for
			while sam_test.getCurr().qname != sam_comp.getCurr().qname or sam_test.getCurr().is_secondary:
				if sam_test.getCurr().is_secondary:
					self.stats.ignored_testee += 1
					self.stats.total_testee += 1

					if not sam_test.next():
						self.warn("Unexpectedly reached end of mapper output while skipping secondary alignment",
								  self.testee_filename, sam_comp.getCurr().qname)
						break


# Path: lib/util.py
# STATUS_NORMAL=1
# STATUS_MAX_MEMORY_EXCEEDED=2
# STATUS_MAX_RUNTIME_EXCEEDED=3
# MAX_LEN_OUT = 10000
# def runAndMeasure(command,detailed=True,maxtime=0,maxmem=0):
# def runSimple(command):
# def runAndMeasureInternal(return_queue,command,maxtime=0,maxmem=0):
# def runInternal(control_queue,command,max_memory):
# def measureProcess(queue, initial_pids, command, measurement_interval=1, max_runtime=0, max_memory=0, debug=False):
# 	def extendTargets(targets, proc):
# 	def killTargets(targets):
# 	def updateTargets(targets, metrics):
# 	def updateMetrics(target, metrics):
# def loadConfig(name, parent_dir="", already_included=[]):
# def setCallDir(d):
# def setRootDir(d):
# def enterCallDir():
# def enterRootDir():
# def getRootDir():
# def nl2br(text):
# def msg(text="", level=1):
# def yes_no(b):
# def md5(text):
# def merge(x, y):
# def formatFilesize(n):
# def percent(val, base, offset=0):
# def abs_path(path):
# def get_sam_header_line_count(filename):
# def is_sam_sorted(filename):
# def sort_sam(filename,threads=1):
# def sort_sam_picard(filename,threads=-1):
# def line_count(filename):
# def sanitize_string(s):
# def makeExportDropdown(plot_id,csv_filename):
# def parseMD(md,seq):


# Path: lib/evaluator.py
from stats import *
from sam import *
from lib import util
	import sys

			if dont_advance_test:
				dont_advance_test = False
			else:
				if sam_test.next():
					self.stats.total_testee += 1
				else:
					if not warned_testee_end:
						if self.stats.total_testee == 0:
							self.error("Unexpectedly reached end of mapper output", self.testee_filename, sam_comp.getCurr().qname)
						else:
							self.warn("Unexpectedly reached end of mapper output", self.testee_filename, sam_comp.getCurr().qname)
						warned_testee_end = True

					self.stats.not_found += 1
					self.export_read("fail", sam_comp.getCurr(), sam_comp.getCurr(), "not_found")
					continue

			#Check if source read identifiers are equal
			#If source read is not equal, theres been a shift in the rows of one of the alignments
			#which we have to adapt for
			while sam_test.getCurr().qname != sam_comp.getCurr().qname or sam_test.getCurr().is_secondary:
				if sam_test.getCurr().is_secondary:
					self.stats.ignored_testee += 1
					self.stats.total_testee += 1

					if not sam_test.next():
						self.warn("Unexpectedly reached end of mapper output while skipping secondary alignment",
								  self.testee_filename, sam_comp.getCurr().qname)
						break


					continue