Skip to content

Commit

Permalink
Trying to optimize the queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Adafede committed Nov 20, 2023
1 parent 7ebca25 commit 291e3f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions update/download_couples_referenced.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

def run(root: Path, retry: int = 3) -> None:
query = """
SELECT DISTINCT ?compound ?taxon ?reference WHERE {
?compound p:P703 ?statement;
# We use InChIKey (P235) instead of SMILES as some of them are incomplete.
wdt:P235 [].
SELECT DISTINCT ?compound ?taxon ?reference WHERE {
# We use InChIKey (P235) instead of SMILES as some of them are incomplete.
?compound wdt:P235 [].
?compound p:P703 ?statement.
?statement ps:P703 ?taxon;
(prov:wasDerivedFrom/pr:P248) ?reference.
}
Expand Down
13 changes: 7 additions & 6 deletions update/download_smiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
def run(root: Path, retry: int = 3) -> None:
query = """
SELECT DISTINCT ?structure ?structure_smiles ?canonical_smiles WHERE {
?structure wdt:P703 ?taxon;
# Using InChIKey (P235) to recognize chemicals.
# Could also be
# P31 wd:Q113145171 `type of a chemical entity`
# P31 wd:Q59199015 `group of stereoisomers`
wdt:P235 [].
# Using InChIKey (P235) to recognize chemicals.
# Could also be
# P31 wd:Q113145171 `type of a chemical entity`
# P31 wd:Q59199015 `group of stereoisomers`
?structure wdt:P235 [].
?structure wdt:P703 ?taxon.
# All P2017 should also have P233 but some of them are not complete.
OPTIONAL {
?structure wdt:P233 ?canonical_smiles.
Expand Down

0 comments on commit 291e3f0

Please sign in to comment.