@@ -26,8 +26,8 @@ def get_batch(self, chromosomes, starts, ends):
2626
2727
2828def test_same_output (bigwig_path ):
29- pybigwig_collection = PyBigWigCollection (bigwig_path , first_n_files = 2 )
30- collection = BigWigCollection (bigwig_path , first_n_files = 2 )
29+ pybigwig_collection = PyBigWigCollection (bigwig_path , first_n_files = 3 )
30+ collection = BigWigCollection (bigwig_path , first_n_files = 3 )
3131
3232 df = pd .read_csv (config .example_positions , sep = "\t " )
3333 df = df [df ["chr" ].isin (collection .get_chromosomes_present_in_all_files ())]
@@ -49,3 +49,31 @@ def test_same_output(bigwig_path):
4949 print (this_batch [pybigwig_batch != this_batch ])
5050 print (pybigwig_batch [pybigwig_batch != this_batch ])
5151 assert (pybigwig_batch == this_batch ).all ()
52+
53+
54+ def test_same_output_with_nans (bigwig_path ):
55+ pybigwig_collection = PyBigWigCollection (bigwig_path , first_n_files = 3 )
56+ collection = BigWigCollection (bigwig_path , first_n_files = 3 )
57+
58+ df = pd .read_csv (config .example_positions , sep = "\t " )
59+ df = df [df ["chr" ].isin (collection .get_chromosomes_present_in_all_files ())]
60+ chromosomes , starts , ends = (
61+ list (df ["chr" ]),
62+ list (df ["center" ] - 1000 ),
63+ list (df ["center" ] + 1000 ),
64+ )
65+
66+ pybigwig_batch = pybigwig_collection .get_batch (chromosomes , starts , ends )
67+
68+ this_batch = collection .get_batch (
69+ chromosomes , starts , ends , default_value = np .nan
70+ ).get ()
71+ print ("PyBigWig:" )
72+ print (pybigwig_batch )
73+ print (type (this_batch ), "shape:" , pybigwig_batch .shape )
74+ print ("This Library:" )
75+ print (this_batch )
76+ print (type (this_batch ), "shape:" , this_batch .shape )
77+ print (this_batch [pybigwig_batch != this_batch ])
78+ print (pybigwig_batch [pybigwig_batch != this_batch ])
79+ assert np .allclose (pybigwig_batch , this_batch , equal_nan = True )
0 commit comments