From a6607c36fa6de9ab147e5f9bba9eb94f9790ce3a Mon Sep 17 00:00:00 2001 From: Adriano Rutz Date: Mon, 18 Dec 2023 15:17:52 +0100 Subject: [PATCH] some fixes --- api/api.py | 9 +++++---- doc/EXAMPLE_QUERIES.md | 10 ++++++---- update/generate_database_taxo.py | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/api/api.py b/api/api.py index 5a8f9fc..986bd70 100644 --- a/api/api.py +++ b/api/api.py @@ -100,6 +100,7 @@ def get_matching_taxa_from_taxon_in_item(dm: DataModel, item: Item) -> set[int] taxa = dm.get_taxa() else: taxa = dm.get_taxa() + print(taxa) return taxa @@ -191,9 +192,9 @@ async def search_structures(item: Item) -> StructureResult: ) if item.limit == 0: - items = dm.get_dict_of_wid_to_smiles(matching_structures).items() + items = list(dm.get_dict_of_wid_to_smiles(matching_structures).items()) else: - items = dm.get_dict_of_wid_to_smiles(matching_structures).items()[: item.limit] + items = list(dm.get_dict_of_wid_to_smiles(matching_structures).items())[: item.limit] return StructureResult( ids=matching_structures, @@ -216,9 +217,9 @@ async def search_taxa(item: Item) -> TaxonResult: matching_taxa = matching_taxa_by_taxon & matching_taxa_by_structure if item.limit == 0: - items = dm.get_dict_of_wid_to_taxon_name(matching_taxa).items() + items = list(dm.get_dict_of_wid_to_taxon_name(matching_taxa).items()) else: - items = dm.get_dict_of_wid_to_taxon_name(matching_taxa).items()[: item.limit] + items = list(dm.get_dict_of_wid_to_taxon_name(matching_taxa).items())[: item.limit] return TaxonResult( ids=matching_taxa, diff --git a/doc/EXAMPLE_QUERIES.md b/doc/EXAMPLE_QUERIES.md index 43624f7..3d722ad 100644 --- a/doc/EXAMPLE_QUERIES.md +++ b/doc/EXAMPLE_QUERIES.md @@ -5,7 +5,7 @@ Careful that's taxus anywhere in the name, so you'll get Cephalotaxus as well! ```shell -curl -XPOST -H 'Accept: application/json' -H 'Content-Type: application/json' http://127.0.0.1:8000/v1_0/structures -d '{"molecule":"Cl", "substructure_search": true, "taxon_name":"Taxus"}' +curl -XPOST -H 'Accept: application/json' -H 'Content-Type: application/json' http://127.0.0.1:5000/v1_0/structures -d '{"structure":"Cl", "substructure_search": true, "taxon_name":"Taxus"}' ``` ## Taxa @@ -13,13 +13,15 @@ curl -XPOST -H 'Accept: application/json' -H 'Content-Type: application/json' ht ### Get all the taxa with gent in their name producing a structure with chlorine in it ```shell -curl -XPOST -H 'Accept: application/json' -H 'Content-Type: application/json' http://127.0.0.1:8000/v1_0/taxa -d '{"molecule":"Cl", "substructure_search": true, "taxon_name":"gent"}' +curl -XPOST -H 'Accept: application/json' -H 'Content-Type: application/json' http://127.0.0.1:5000/v1_0/taxa -d '{"structure":"Cl", "substructure_search": true, "taxon_name":"Gent"}' ``` ### Get all the taxa producing chlorinated structures +#### TODO THIS ONE IS NOT WORKING ANYMORE (FIX IT) + ```shell -curl -XPOST -H 'Accept: application/json' -H 'Content-Type: application/json' http://127.0.0.1:8000/v1_0/taxa -d '{"molecule":"Cl", "substructure_search": true}' +curl -XPOST -H 'Accept: application/json' -H 'Content-Type: application/json' http://127.0.0.1:5000/v1_0/taxa -d '{"structure":"Cl", "substructure_search": true}' ``` ## Couples @@ -29,5 +31,5 @@ curl -XPOST -H 'Accept: application/json' -H 'Content-Type: application/json' ht Careful that's taxus anywhere in the name, so you'll get Cephalotaxus as well! ```shell -curl -XPOST -H 'Accept: application/json' -H 'Content-Type: application/json' http://127.0.0.1:8000/v1_0/couples -d '{"molecule":"O=C(OC1C(=C)C2CC3(O)CC(OC(=O)C)C(=C(C(OC(=O)C)C(OC(=O)C)C2(C)C(OC(=O)C)C1)C3(C)C)C)C=CC=4C=CC=CC4", "taxon_name":"tax"}' +curl -XPOST -H 'Accept: application/json' -H 'Content-Type: application/json' http://127.0.0.1:5000/v1_0/couples -d '{"structure":"O=C(OC1C(=C)C2CC3(O)CC(OC(=O)C)C(=C(C(OC(=O)C)C(OC(=O)C)C2(C)C(OC(=O)C)C1)C3(C)C)C)C=CC=4C=CC=CC4", "taxon_name":"tax"}' ``` diff --git a/update/generate_database_taxo.py b/update/generate_database_taxo.py index b1ce3ca..bb3e36b 100644 --- a/update/generate_database_taxo.py +++ b/update/generate_database_taxo.py @@ -101,7 +101,7 @@ def run(path: Path) -> None: with open(path / "taxa_all.csv", "r") as f: reader = DictReader(f) - dict_all_taxa: dict = {row["taxon"]: row["taxon_name"] for row in reader} + dict_all_taxa: dict = {int(row["taxon"]): row["taxon_name"] for row in reader} database = { "taxonomy_direct_parents": taxon_direct_parents,