Skip to content

Commit

Permalink
added new test to build matrix using RF and updated previous test
Browse files Browse the repository at this point in the history
  • Loading branch information
fidelram committed Jun 27, 2017
1 parent 095560d commit 6571f10
Show file tree
Hide file tree
Showing 18 changed files with 464,529 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hicexplorer/hicBuildMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ def main(args=None):
args.restrictionSequence = args.restrictionSequence.upper()
args.danglingSequence = args.danglingSequence.upper()
dangling_sequences['pat_forw'] = args.danglingSequence
dangling_sequences['pat_rev'] = str(Seq(args.danglingSequence, generic_dna).reverse_complement())
dangling_sequences['pat_rev'] = str(Seq(args.danglingSequence, generic_dna).complement())

sys.stderr.write("dangling sequences to check "
"are {}\n".format(dangling_sequences))
Expand Down
30 changes: 29 additions & 1 deletion hicexplorer/test/test_buildMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
from hicexplorer import HiCMatrix as hm
from tempfile import NamedTemporaryFile, mkdtemp
import shutil
import filecmp
import os
import numpy.testing as nt


ROOT = os.path.dirname(os.path.abspath(__file__)) + "/test_data/"
sam_R1 = ROOT + "small_test_R1_unsorted.bam"
sam_R2 = ROOT + "small_test_R2_unsorted.bam"
dpnii_file = ROOT + "DpnII.bed"


def test_build_matrix():
Expand All @@ -23,10 +25,36 @@ def test_build_matrix():
test = hm.hiCMatrix(ROOT + "small_test_matrix.h5")
new = hm.hiCMatrix(outfile.name)
nt.assert_equal(test.matrix.data, new.matrix.data)
assert test.cut_intervals == new.cut_intervals
nt.assert_equal(test.cut_intervals, new.cut_intervals)

print set(os.listdir(ROOT + "QC/"))
filecmp(ROOT + "QC/QC.log", qc_folder + "/QC.log")
assert set(os.listdir(ROOT + "QC/")) == set(os.listdir(qc_folder))

os.unlink(outfile.name)
shutil.rmtree(qc_folder)


def test_build_matrix_rf():
outfile = NamedTemporaryFile(suffix='.h5', delete=False)
outfile.close()
qc_folder = mkdtemp(prefix="testQC_")
args = "-s {} {} -rs {} -o {} --QCfolder {} " \
"--restrictionSequence GATC " \
"--danglingSequence GATC " \
"--minDistance 150 " \
"--maxDistance 1500".format(sam_R1, sam_R2, dpnii_file,
outfile.name,
qc_folder).split()
hicBuildMatrix.main(args)

test = hm.hiCMatrix(ROOT + "small_test_rf_matrix.h5")
new = hm.hiCMatrix(outfile.name)
nt.assert_equal(test.matrix.data, new.matrix.data)
nt.assert_equal(test.cut_intervals, new.cut_intervals)

print set(os.listdir(ROOT + "QC_rc/"))
assert set(os.listdir(ROOT + "QC_rc/")) == set(os.listdir(qc_folder))

os.unlink(outfile.name)
shutil.rmtree(qc_folder)

0 comments on commit 6571f10

Please sign in to comment.