Skip to content

Commit

Permalink
Merge pull request #32 from deeptools/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
joachimwolff authored May 15, 2020
2 parents 811a9a8 + fc37201 commit 760e783
Show file tree
Hide file tree
Showing 13 changed files with 231 additions and 181 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ before_install:

- export HIC_TEST_DATA_DIR="`pwd`/hicmatrix/test/test_data/"
- echo $HIC_TEST_DATA_DIR
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o miniconda.sh ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl -L https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -L https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o miniconda.sh ; fi
- bash miniconda.sh -b -p $HOME/miniconda
- PATH_WITHOUT_CONDA="$PATH"
- export PATH="$HOME/miniconda/bin:$PATH"
Expand Down
44 changes: 17 additions & 27 deletions hicmatrix/HiCMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class hiCMatrix:
get sub matrices by chrname.
"""

def __init__(self, pMatrixFile=None, pChrnameList=None):
def __init__(self, pMatrixFile=None, pChrnameList=None, pDistance=None, pNoIntervalTree=None, pUpperTriangleOnly=None):
self.non_homogeneous_warning_already_printed = False
self.bin_size = None
self.bin_size_homogeneous = None # track if the bins are equally spaced or not
Expand All @@ -49,40 +49,30 @@ def __init__(self, pMatrixFile=None, pChrnameList=None):
fileType = 'cool'
if pMatrixFile.endswith('.h5'):
fileType = 'h5'
self.matrixFileHandler = MatrixFileHandler(pFileType=fileType, pMatrixFile=pMatrixFile, pChrnameList=pChrnameList)
self.matrixFileHandler = MatrixFileHandler(pFileType=fileType, pMatrixFile=pMatrixFile, pChrnameList=pChrnameList, pDistance=pDistance)
log.debug('init time: {}'.format(time.time() - start_time))
self.matrix, self.cut_intervals, self.nan_bins, \
self.correction_factors, self.distance_counts = self.matrixFileHandler.load()
# if len(self.matrix.data) == 0:
# log.warning('No data for {}, not initialization of object. '.format(pChrnameList))
# self.interval_trees = None
# self.chrBinBoundaries = None
# return
log.debug('load time: {}'.format(time.time() - start_time))
start_time = time.time()

log.debug('data loaded from file handler')
matrixFileHandler_load = self.matrixFileHandler.load()
# check if there was any exception thrown in the load function
if len(matrixFileHandler_load) == 2:
raise Exception('Matrix failed to load: {}'.format(str(matrixFileHandler_load[1])))
else:
self.matrix, self.cut_intervals, self.nan_bins, \
self.correction_factors, self.distance_counts = matrixFileHandler_load
if self.nan_bins is None:
self.nan_bins = np.array([])

self.fillLowerTriangle()
log.debug('triangle time: {}'.format(time.time() - start_time))
if pUpperTriangleOnly is None or not pUpperTriangleOnly:
self.fillLowerTriangle()
start_time = time.time()

log.debug('fillLowerTriangle')

self.restoreMaskedBins()
log.debug('restoreMaskedBins: {}'.format(time.time() - start_time))
start_time = time.time()

log.debug('restoreMaskedBins')

self.interval_trees, self.chrBinBoundaries = \
self.intervalListToIntervalTree(self.cut_intervals)
log.debug('intervalListToIntervalTree: {}'.format(time.time() - start_time))
start_time = time.time()

log.debug('intervalListToIntervalTree')
if pNoIntervalTree is None or not pNoIntervalTree:
self.interval_trees, self.chrBinBoundaries = \
self.intervalListToIntervalTree(self.cut_intervals)
else:
log.debug('no intervaltree')

elif pMatrixFile is None:
log.debug('Only init object, no matrix given.')
Expand Down Expand Up @@ -1016,6 +1006,6 @@ def intervalListToIntervalTree(self, interval_list):


def check_cooler(pFileName):
if pFileName.endswith('.cool') or cooler.io.is_cooler(pFileName) or'.mcool' in pFileName:
if pFileName.endswith('.cool') or cooler.io.is_cooler(pFileName) or '.mcool' in pFileName:
return True
return False
2 changes: 2 additions & 0 deletions hicmatrix/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging
logging.basicConfig(level=logging.INFO)
# logging.basicConfig(level=logging.DEBUG)

logging.getLogger('cooler').setLevel(logging.WARNING)
2 changes: 1 addition & 1 deletion hicmatrix/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '12'
__version__ = '13'
# Version number differs from HiCExplorer!
Loading

0 comments on commit 760e783

Please sign in to comment.