| Total Complexity | 2 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | |||
| 3 | from mandos.cli import Commands, Searcher |
||
| 4 | from mandos.model.chembl_api import ChemblApi |
||
| 5 | from chembl_webresource_client.new_client import new_client as Chembl |
||
| 6 | from mandos.search.chembl.indication_search import IndicationSearch |
||
| 7 | |||
| 8 | from .. import get_test_resource |
||
| 9 | |||
| 10 | |||
| 11 | class TestIndicationSearch: |
||
| 12 | def test_find(self): |
||
| 13 | df, triples = Commands.trials(get_test_resource("inchis.txt")) |
||
| 14 | assert len(df) == 6 |
||
| 15 | assert len(triples) == 6 |
||
| 16 | assert {t.compound_name.lower() for t in triples} == {"alprazolam"} |
||
| 17 | assert {t.object_id for t in triples} == { |
||
| 18 | "D012559", |
||
| 19 | "D016584", |
||
| 20 | "D003704", |
||
| 21 | "D001008", |
||
| 22 | "D001007", |
||
| 23 | "D003866", |
||
| 24 | } |
||
| 25 | assert {t.object_name.lower() for t in triples} == { |
||
| 26 | "schizophrenia", |
||
| 27 | "panic disorder", |
||
| 28 | "dementia", |
||
| 29 | "anxiety", |
||
| 30 | "depressive disorder", |
||
| 31 | "anxiety disorders", |
||
| 32 | } |
||
| 33 | assert {t.predicate for t in triples} == {"phase-4 indication", "phase-3 indication"} |
||
| 34 | |||
| 35 | def test_cocaine_hcl(self): |
||
| 36 | api = ChemblApi.wrap(Chembl) |
||
| 37 | df, triples = Searcher(IndicationSearch(api, min_phase=3)).search_for(["CHEMBL529437"]) |
||
| 38 | assert len(df) == 1 |
||
| 39 | assert len(triples) == 1 |
||
| 40 | assert triples[0].compound_name.lower() == "cocaine" |
||
| 41 | assert triples[0].compound_id == "CHEMBL370805" |
||
| 42 | assert triples[0].object_id == "D000758" |
||
| 43 | assert triples[0].object_name == "Anesthesia" |
||
| 44 | assert triples[0].predicate == "phase-4 indication" |
||
| 45 | |||
| 46 | |||
| 47 | if __name__ == "__main__": |
||
| 48 | pytest.main() |
||
| 49 |