from __future__ import print_function

import cooler.contrib.higlass as cch
import h5py
import os.path as op

testdir = op.realpath(op.dirname(__file__))

def test_data_retrieval():
    data_file = op.join(testdir, 'data', 'dixon2012-h1hesc-hindiii-allreps-filtered.1000kb.multires.cool')
    
    f = h5py.File(data_file, 'r')
    
    data = cch.get_data(f, 0, 0, 3276799999, 0, 3276799999)

    assert(data['genome_start1'].iloc[0] == 0.)
    assert(data['genome_start2'].iloc[0] == 0.)

    data = cch.get_data(f, 4, 0, 256000000, 0, 256000000)

    assert(data['genome_start1'].iloc[-1] > 255000000)
    assert(data['genome_start1'].iloc[-1] < 256000000)
    #print("ge1", data['genome_end1'])

from __future__ import print_function

import cooler.contrib.higlass as cch
import cooler.contrib.recursive_agg_onefile as ra
import h5py
import os.path as op

testdir = op.realpath(op.dirname(__file__))

def test_data_retrieval():
    data_file = op.join(testdir, 'data', 'dixon2012-h1hesc-hindiii-allreps-filtered.1000kb.multires.cool')
    
    f = h5py.File(data_file, 'r')
    
    data = cch.get_data(f, 0, 0, 3276799999, 0, 3276799999)

    assert(data['genome_start1'].iloc[0] == 0.)
    assert(data['genome_start2'].iloc[0] == 0.)

    data = cch.get_data(f, 4, 0, 256000000, 0, 256000000)

    assert(data['genome_start1'].iloc[-1] > 255000000)
    assert(data['genome_start1'].iloc[-1] < 256000000)
    #print("ge1", data['genome_end1'])


def test_recursive_agg():
    infile = op.join(testdir, 'data', 'GM12878-MboI-matrix.2000kb.cool')
    outfile = '/tmp/bla.cool'
    chunksize = int(10e6)
    n_zooms = 2
    n_cpus = 8
    ra.aggregate(infile, outfile, n_zooms, chunksize, n_cpus)
    ra.balance(outfile, n_zooms, chunksize, n_cpus)
Add test for recursive agg
Add test for recursive agg

  from __future__ import print_function
  
  import cooler.contrib.higlass as cch
+ import cooler.contrib.recursive_agg_onefile as ra
  import h5py
  import os.path as op
  
  testdir = op.realpath(op.dirname(__file__))
  
  def test_data_retrieval():
      data_file = op.join(testdir, 'data', 'dixon2012-h1hesc-hindiii-allreps-filtered.1000kb.multires.cool')
      
      f = h5py.File(data_file, 'r')
      
      data = cch.get_data(f, 0, 0, 3276799999, 0, 3276799999)
  
      assert(data['genome_start1'].iloc[0] == 0.)
      assert(data['genome_start2'].iloc[0] == 0.)
  
      data = cch.get_data(f, 4, 0, 256000000, 0, 256000000)
  
      assert(data['genome_start1'].iloc[-1] > 255000000)
      assert(data['genome_start1'].iloc[-1] < 256000000)
      #print("ge1", data['genome_end1'])
  
+ 
+ def test_recursive_agg():
+     infile = op.join(testdir, 'data', 'GM12878-MboI-matrix.2000kb.cool')
+     outfile = '/tmp/bla.cool'
+     chunksize = int(10e6)
+     n_zooms = 2
+     n_cpus = 8
+     ra.aggregate(infile, outfile, n_zooms, chunksize, n_cpus)
+     ra.balance(outfile, n_zooms, chunksize, n_cpus)
Add test for recursive agg
## Code Before:
from __future__ import print_function

import cooler.contrib.higlass as cch
import h5py
import os.path as op

testdir = op.realpath(op.dirname(__file__))

def test_data_retrieval():
    data_file = op.join(testdir, 'data', 'dixon2012-h1hesc-hindiii-allreps-filtered.1000kb.multires.cool')
    
    f = h5py.File(data_file, 'r')
    
    data = cch.get_data(f, 0, 0, 3276799999, 0, 3276799999)

    assert(data['genome_start1'].iloc[0] == 0.)
    assert(data['genome_start2'].iloc[0] == 0.)

    data = cch.get_data(f, 4, 0, 256000000, 0, 256000000)

    assert(data['genome_start1'].iloc[-1] > 255000000)
    assert(data['genome_start1'].iloc[-1] < 256000000)
    #print("ge1", data['genome_end1'])

## Instruction:
Add test for recursive agg
## Code After:
from __future__ import print_function

import cooler.contrib.higlass as cch
import cooler.contrib.recursive_agg_onefile as ra
import h5py
import os.path as op

testdir = op.realpath(op.dirname(__file__))

def test_data_retrieval():
    data_file = op.join(testdir, 'data', 'dixon2012-h1hesc-hindiii-allreps-filtered.1000kb.multires.cool')
    
    f = h5py.File(data_file, 'r')
    
    data = cch.get_data(f, 0, 0, 3276799999, 0, 3276799999)

    assert(data['genome_start1'].iloc[0] == 0.)
    assert(data['genome_start2'].iloc[0] == 0.)

    data = cch.get_data(f, 4, 0, 256000000, 0, 256000000)

    assert(data['genome_start1'].iloc[-1] > 255000000)
    assert(data['genome_start1'].iloc[-1] < 256000000)
    #print("ge1", data['genome_end1'])


def test_recursive_agg():
    infile = op.join(testdir, 'data', 'GM12878-MboI-matrix.2000kb.cool')
    outfile = '/tmp/bla.cool'
    chunksize = int(10e6)
    n_zooms = 2
    n_cpus = 8
    ra.aggregate(infile, outfile, n_zooms, chunksize, n_cpus)
    ra.balance(outfile, n_zooms, chunksize, n_cpus)