1+ import pytest
2+ from deeptools .bamCompare2 import r_bamcompare
3+ import os .path
4+ import filecmp
5+ from os import unlink
6+
7+ ROOT = os .path .dirname (os .path .abspath (__file__ )) + "/test_data/"
8+ BAMFILE_A = ROOT + "test1.bam"
9+ BAMFILE_B = ROOT + "test2.bam"
10+
11+
12+ def test_r_bamcompare ():
13+ bamifile1 = BAMFILE_A
14+ bamifile2 = BAMFILE_B
15+ ofile = ROOT + "r_bamcompare_output.bedgraph"
16+ ofiletype = "bedgraph"
17+ norm = "None"
18+ effective_genome_size = 0
19+ scalefactorsmethod = "None"
20+ operation = "ratio"
21+ pseudocount = 0
22+ # filtering options
23+ ignoreduplicates = False
24+ minmappingquality = 0
25+ samflaginclude = 0
26+ samflagexclude = 0
27+ minfraglen = 0
28+ maxfraglen = 0
29+ nproc = 1
30+ _ignorechr = []
31+ binsize = 500
32+ regions = []
33+ verbose = False
34+
35+ # Call the Rust function
36+ r_bamcompare (
37+ bamifile1 , bamifile2 , ofile , ofiletype , norm , effective_genome_size , scalefactorsmethod , operation ,
38+ pseudocount , ignoreduplicates , minmappingquality , samflaginclude , samflagexclude , minfraglen , maxfraglen , nproc ,
39+ _ignorechr , binsize , regions , verbose
40+ )
41+ # Add assertions to verify the expected behavior
42+ expected = ['3R\t 0\t 500\t 0.6213592\n ' ,
43+ '3R\t 500\t 1000\t 0.8252427\n ' ,
44+ '3R\t 1000\t 1500\t 0.2\n ' ,]
45+ _foo = open (ofile , 'r' )
46+ resp = _foo .readlines ()
47+ _foo .close ()
48+ assert f"{ resp } " == f"{ expected } " , f"{ resp } != { expected } "
49+ unlink (ofile )
50+
51+ def test_r_bamcompare_RPKM ():
52+ bamifile1 = BAMFILE_A
53+ bamifile2 = BAMFILE_B
54+ ofile = ROOT + "r_bamcompare_output.bedgraph"
55+ ofiletype = "bedgraph"
56+ norm = "RPKM"
57+ effective_genome_size = 0
58+ scalefactorsmethod = "None"
59+ operation = "ratio"
60+ pseudocount = 0
61+ # filtering options
62+ ignoreduplicates = False
63+ minmappingquality = 0
64+ samflaginclude = 0
65+ samflagexclude = 0
66+ minfraglen = 0
67+ maxfraglen = 0
68+ nproc = 1
69+ _ignorechr = []
70+ binsize = 500
71+ regions = []
72+ verbose = False
73+
74+ # Call the Rust function
75+ r_bamcompare (
76+ bamifile1 , bamifile2 , ofile , ofiletype , norm , effective_genome_size , scalefactorsmethod , operation ,
77+ pseudocount , ignoreduplicates , minmappingquality , samflaginclude , samflagexclude , minfraglen , maxfraglen , nproc ,
78+ _ignorechr , binsize , regions , verbose
79+ )
80+ # Add assertions to verify the expected behavior
81+ expected = ['3R\t 0\t 500\t 0.6213592\n ' ,
82+ '3R\t 500\t 1000\t 0.8252427\n ' ,
83+ '3R\t 1000\t 1500\t 0.2\n ' ,]
84+ _foo = open (ofile , 'r' )
85+ resp = _foo .readlines ()
86+ _foo .close ()
87+ assert f"{ resp } " == f"{ expected } " , f"{ resp } != { expected } "
88+ unlink (ofile )
0 commit comments