Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adafede committed Dec 18, 2023
1 parent 3e8797e commit a6607c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
9 changes: 5 additions & 4 deletions api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions doc/EXAMPLE_QUERIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
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

### 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
Expand All @@ -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"}'
```
2 changes: 1 addition & 1 deletion update/generate_database_taxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a6607c3

Please sign in to comment.