Esempio n. 1
0
    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
Esempio n. 2
0
    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"]
        )
Esempio n. 3
0
    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"]
        )
Esempio n. 4
0
    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
Esempio n. 5
0
 def test_complex_genes_no_genes(self):
     with pytest.raises(ValueError, match=r"No genes have been selected."):
         Complexes.complex_genes([], complexes=None)
Esempio n. 6
0
 def test_complex_genes_no_column(self):
     with pytest.raises(KeyError):
         Complexes.complex_genes("foo", complexes=pd.DataFrame({"foo": range(10)}))
Esempio n. 7
0
 def test_complex_genes_wrong_dtype(self):
     with pytest.raises(TypeError):
         Complexes.complex_genes("foo", complexes=42)