Skip to content

Commit

Permalink
Added pytest for ComputeMatrix along with associated test files
Browse files Browse the repository at this point in the history
  • Loading branch information
SaimMomin12 committed Jan 22, 2025
1 parent c8b8802 commit 48c1cf5
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 0 deletions.
61 changes: 61 additions & 0 deletions pydeeptools/deeptools/test/test_computeMatrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import deeptools.computeMatrix as cm

import os.path
from os import unlink

ROOT = os.path.dirname(os.path.abspath(__file__)) + "/test_data/"
REGIONS_IN1 = ROOT + "computeMatrix1.bed"
REGIONS_IN2 = ROOT + "computeMatrix2.bed"
BIGWIG_IN1 = ROOT + "bamCoverage_result4.bw"
BIGWIG_IN2 = ROOT + "computeMatrix2.bw"
OUT_ARCHIEVE1 = ROOT + "computeMatrix_result1.gz"
OUT_ARCHIEVE2 = ROOT + "computeMatrix_result2.gz"
OUT_ARCHIEVE3 = ROOT + "computeMatrix_result3.gz"

def test_compute_matrix_with_reference_point_and_advance_options_1():
"""
Test minimal command line args compute matrix with reference based
mode along with advance options of sorting using sum and average
type bin as sum
"""
outfile = '/tmp/computematrix_1.gz'
args = "reference-point --regionsFileName {} --scoreFileName {} -o {} -bs 10 --sortUsing sum --averageTypeBins sum -b 10 -a 10".format(REGIONS_IN1, BIGWIG_IN1, outfile).split()
cm.main(args)

archieve_file_size = os.path.getsize(OUT_ARCHIEVE1)
expected_file_size = os.path.getsize(outfile)
size_tolerance = 500
size_difference = abs(archieve_file_size - expected_file_size)
assert size_difference <= size_tolerance, "File size do not match"
unlink(outfile)

def test_compute_matrix_with_reference_point_and_advance_options_2():
"""
Test minimal command line args compute matrix with reference based mode
with before and after region start length
"""
outfile = '/tmp/computematrix_2.gz'
args = "reference-point --regionsFileName {} --scoreFileName {} -o {} -bs 10 -b 10 -a 10".format(REGIONS_IN2, BIGWIG_IN2, outfile).split()
cm.main(args)

archieve_file_size = os.path.getsize(OUT_ARCHIEVE2)
expected_file_size = os.path.getsize(outfile)
size_tolerance = 500
size_difference = abs(archieve_file_size - expected_file_size)
assert size_difference <= size_tolerance, "File size do not match"
unlink(outfile)

def test_compute_matrix_with_scale_regions():
"""
Test minimal command line args compute matrix with scale regions mode
"""
outfile = '/tmp/computematrix_3.gz'
args = "scale-regions --regionsFileName {} --scoreFileName {} -o {}".format(REGIONS_IN2, BIGWIG_IN2, outfile).split()
cm.main(args)

archieve_file_size = os.path.getsize(OUT_ARCHIEVE3)
expected_file_size = os.path.getsize(outfile)
size_tolerance = 500
size_difference = abs(archieve_file_size - expected_file_size)
assert size_difference <= size_tolerance, "File size do not match"
unlink(outfile)
Binary file not shown.
8 changes: 8 additions & 0 deletions pydeeptools/deeptools/test/test_data/computeMatrix1.bed
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
phiX174 1000 1500 CG11023 0 +
phiX174 150 1750 cda5 0 -
phiX174 150 177 cda8 0 -
phiX174 75 1500 cda9 0 +
phiX174 101 175 C11023 0 +
phiX174 125 150 ca5 0 -
phiX174 450 1750 ca8 0 +
phiX174 80 1500 cda9 0 +
6 changes: 6 additions & 0 deletions pydeeptools/deeptools/test/test_data/computeMatrix2.bed
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ch1 100 150 CG11023 0 +
ch2 150 175 cda5 0 -
ch3 100 125 cda8 0 +
ch1 75 125 C11023 0 +
ch2 125 150 ca5 0 -
ch3 75 100 ca8 0 +
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 48c1cf5

Please sign in to comment.