Skip to content

Commit

Permalink
added method to set cut_intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
fidelram committed May 18, 2017
1 parent e89efa0 commit 1ac5c23
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hicexplorer/HiCMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,20 @@ def fillLowerTriangle(matrix):

return matrix

def setCutIntervals(self, cut_intervals):
"""
Replace the cut_intervals of a matrix
"""

# check that the matrix is squared
if len(cut_intervals) != self.matrix.shape[0]:
raise Exception("Length of cut_intervals {} does not match the "
"matrix size {}".format(len(cut_intervals), self.matrix.shape))

self.cut_intervals = cut_intervals
self.interval_trees, self.chrBinBoundaries = \
self.intervalListToIntervalTree(self.cut_intervals)

def setMatrix(self, matrix, cut_intervals):
"""
Initialize a matrix with a given matrix
Expand All @@ -206,6 +220,9 @@ def setMatrix(self, matrix, cut_intervals):
# check that the matrix is squared
if matrix.shape[0] != matrix.shape[1]:
raise Exception("Matrix is not squared. Shape is {}".format(matrix.shape))
if len(cut_intervals) != matrix.shape[0]:
raise Exception("Length of cut_intervals {} does not match the matrix size {}".format(len(cut_intervals),
matrix.shape))
self.matrix = matrix
self.cut_intervals = cut_intervals
self.interval_trees, self.chrBinBoundaries = \
Expand Down

0 comments on commit 1ac5c23

Please sign in to comment.