Skip to content

Commit

Permalink
Added 1 more test function for r_bamcoverage and fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gerikson committed Jan 20, 2025
1 parent fc2f825 commit 3f207df
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion pydeeptools/deeptools/test/test_r_bamcoverage.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pytest
from deeptools.bamCoverage2 import r_bamcoverage
from deeptools.hp import r_bamcoverage
import os.path
import filecmp
from os import unlink

ROOT = os.path.dirname(os.path.abspath(__file__)) + "/test_data/"
BAMFILE_A = ROOT + "testA.bam"
BAMFILE_B = ROOT + "testB.bam"


def test_r_bamcoverage():
Expand Down Expand Up @@ -92,4 +93,47 @@ def test_r_bamcoverage_RPKM():
resp = _foo.readlines()
_foo.close()
assert f"{resp}" == f"{expected}", f"{resp} != {expected}"
unlink(ofile)

def test_r_bamcoverage_RPKM_with_effectivegenomesize():
bamifile = BAMFILE_B
ofile = ROOT + "testB.bedgraph"
ofiletype = "bedgraph"
norm = "RPKM"
effectivegenomesize = 142573017
scalefactor = 1.0
mnase = False
offset = [1, -1] # Adjusted to a regular Python list
extendreads = 0
centerreads = False
filterrnastrand = "none"
blacklist = ""
ignorechr = []
skipnoncovregions = False
smoothlength = 0
binsize = 50
ignoreduplicates = False
minmappingquality = 0
samflaginclude = 0
samflagexclude = 0
minfraglen = 0
maxfraglen = 0
nproc = 1
regions = []
verbose = False


# Call the Rust function
r_bamcoverage(
bamifile, ofile, ofiletype, norm, effectivegenomesize, scalefactor, mnase, offset, extendreads,
centerreads, filterrnastrand, blacklist, ignorechr, skipnoncovregions, smoothlength,
binsize, ignoreduplicates, minmappingquality, samflaginclude, samflagexclude, minfraglen, maxfraglen,
nproc, regions, verbose
)
# Add assertions to verify the expected behavior
expected = ['3R\t0\t50\t0\n', '3R\t50\t150\t5000000\n', '3R\t150\t200\t10000000\n']
_foo = open(ofile, 'r')
resp = _foo.readlines()
_foo.close()
assert f"{resp}" == f"{expected}", f"{resp} != {expected}"
unlink(ofile)

0 comments on commit 3f207df

Please sign in to comment.