# Path: data_tools.py
# class ChromParameters(object):
# 	"""Basic information on chromosome, inferred from input file"""
# 	def __init__(self, minPos, maxPos, res, name):
# 		self.minPos = minPos	#minimum genomic coordinate
# 		self.maxPos = maxPos	#maximum genomic coordinate
# 		self.res = res		#resolution (bp)
# 		self.name = name	#e.g. "chr22"
# 
# 	def getLength(self):
# 		"""Number of possible loci"""
# 		return int((self.maxPos - self.minPos)/self.res) + 1
# 
# 	def getAbsoluteIndex(self, genCoord):
# 		"""Converts genomic coordinate into absolute index. Absolute indexing includes empty (zero) points."""
# 		if genCoord < self.minPos or genCoord > self.maxPos + self.res:
# 			return None
# 		else:
# 			return int((genCoord - self.minPos)/self.res) 
# 
# 	def getGenCoord(self, abs_index):
# 		"""Converts absolute index into genomic coordinate"""
# 		return self.minPos + self.res * abs_index
# 
# 	def reduceRes(self, resRatio):
# 		"""Creates low-res version of this chromosome"""
# 		lowRes = self.res * resRatio
# 		lowMinPos = (self.minPos/lowRes)*lowRes		#approximate at low resolution
# 		lowMaxPos = (self.maxPos/lowRes)*lowRes
# 		return ChromParameters(lowMinPos, lowMaxPos, lowRes, self.name)
# 
# Path: tools.py
# class Tracker(object):
# 	"""Tracks progress of task"""
# 	def __init__(self, name, size, currPercentage=0, count=0):
# 		self.name = name	#name of task
# 		self.size = size	#total size of task (e.g. number of lines in file)
# 		self.currPercentage = currPercentage	#current percentage of task complete
# 		self.count = count		#absolute amount of task complete (e.g. number of lines of file read)
# 	def increment(self):
# 		if self.size !=0 and self.size is not None:
# 			self.count += 1
# 			newPercentage = self.currPercentage + 1
# 			if float(self.count)/self.size >= float(newPercentage)/100:	#if at least X% of the file has been read, print percentage
# 				self.currPercentage = newPercentage
# 				print("{} {}% complete".format(self.name, self.currPercentage))	


import sys
import heatmap as hm
import simple_tad as tad
import numpy as np
from data_tools import ChromParameters
from tools import Tracker
sys.path.append("..")

def matFromDixon(path, chrom):
	"""Creates contact matrix from Dixon tsv data"""
	numBins = chrom.getLength()
	mat = np.zeros((numBins, numBins))

# Path: data_tools.py
# class ChromParameters(object):
# 	"""Basic information on chromosome, inferred from input file"""
# 	def __init__(self, minPos, maxPos, res, name):
# 		self.minPos = minPos	#minimum genomic coordinate
# 		self.maxPos = maxPos	#maximum genomic coordinate
# 		self.res = res		#resolution (bp)
# 		self.name = name	#e.g. "chr22"
# 
# 	def getLength(self):
# 		"""Number of possible loci"""
# 		return int((self.maxPos - self.minPos)/self.res) + 1
# 
# 	def getAbsoluteIndex(self, genCoord):
# 		"""Converts genomic coordinate into absolute index. Absolute indexing includes empty (zero) points."""
# 		if genCoord < self.minPos or genCoord > self.maxPos + self.res:
# 			return None
# 		else:
# 			return int((genCoord - self.minPos)/self.res) 
# 
# 	def getGenCoord(self, abs_index):
# 		"""Converts absolute index into genomic coordinate"""
# 		return self.minPos + self.res * abs_index
# 
# 	def reduceRes(self, resRatio):
# 		"""Creates low-res version of this chromosome"""
# 		lowRes = self.res * resRatio
# 		lowMinPos = (self.minPos/lowRes)*lowRes		#approximate at low resolution
# 		lowMaxPos = (self.maxPos/lowRes)*lowRes
# 		return ChromParameters(lowMinPos, lowMaxPos, lowRes, self.name)
# 
# Path: tools.py
# class Tracker(object):
# 	"""Tracks progress of task"""
# 	def __init__(self, name, size, currPercentage=0, count=0):
# 		self.name = name	#name of task
# 		self.size = size	#total size of task (e.g. number of lines in file)
# 		self.currPercentage = currPercentage	#current percentage of task complete
# 		self.count = count		#absolute amount of task complete (e.g. number of lines of file read)
# 	def increment(self):
# 		if self.size !=0 and self.size is not None:
# 			self.count += 1
# 			newPercentage = self.currPercentage + 1
# 			if float(self.count)/self.size >= float(newPercentage)/100:	#if at least X% of the file has been read, print percentage
# 				self.currPercentage = newPercentage
# 				print("{} {}% complete".format(self.name, self.currPercentage))	


# Path: scripts/fig2.py
import sys
import heatmap as hm
import simple_tad as tad
import numpy as np
from data_tools import ChromParameters
from tools import Tracker

sys.path.append("..")

def matFromDixon(path, chrom):
	"""Creates contact matrix from Dixon tsv data"""
	numBins = chrom.getLength()
	mat = np.zeros((numBins, numBins))

	tracker = Tracker("Reading " + path, chrom.size)