def test_comples_genes_empty_complexes(self, caplog): df = pd.DataFrame() with caplog.at_level(logging.WARNING): res = Complexes.complex_genes("foo", complexes=df) assert res is df assert "Complexes are empty" in caplog.text
def test_complexes_no_total_match(self, complexes: pd.DataFrame): res = Complexes.complex_genes( ["bar", "baz", "bar"], complexes=complexes, total_match=False ) assert res.shape == (3, 2) assert all( any(v in ("bar", "baz") for v in vs.split("_")) for vs in res["components_genesymbols"] )
def test_complexes_complexes_specified(self, complexes: pd.DataFrame): res = Complexes.complex_genes("foo", complexes=complexes, total_match=False) assert isinstance(res, pd.DataFrame) assert res.shape == (2, 2) assert set(res.columns) == {"components_genesymbols", "dummy"} assert all( any(v in "foo" for v in vs.split("_")) for vs in res["components_genesymbols"] )
def test_complex_genes_complexes_not_specified( self, cache_backup, requests_mock, tsv_data: bytes ): url = urljoin(options.url, Complexes._query_type.endpoint) df = pd.read_csv(StringIO(tsv_data.decode("utf-8")), sep="\t") requests_mock.register_uri("GET", f"{url}?format=tsv", content=tsv_data) res = Complexes.complex_genes("fooo") np.testing.assert_array_equal(res.columns, df.columns) assert res.empty
def test_complex_genes_no_genes(self): with pytest.raises(ValueError, match=r"No genes have been selected."): Complexes.complex_genes([], complexes=None)
def test_complex_genes_no_column(self): with pytest.raises(KeyError): Complexes.complex_genes("foo", complexes=pd.DataFrame({"foo": range(10)}))
def test_complex_genes_wrong_dtype(self): with pytest.raises(TypeError): Complexes.complex_genes("foo", complexes=42)