-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Obsolete-and-replace DrOn ingredients with non-obsolete labels in ChEBI
- Loading branch information
1 parent
31a8b07
commit 4e8a376
Showing
8 changed files
with
502 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
# | ||
# Add DRON ingredients to obsolete.tsv | ||
# if they match ChEBI labels. | ||
|
||
fail() { | ||
echo "ERROR: " "$@" | ||
exit 1 | ||
} | ||
|
||
ROOT=$(git rev-parse --show-toplevel) || fail "Not a git repository" | ||
DIR="${ROOT}/src/ontology" | ||
SCRIPTSDIR="${ROOT}/src/scripts" | ||
TEMPLATEDIR="${ROOT}/src/templates" | ||
DB="${DIR}/tmp/dron.db" | ||
|
||
# Load template TSVs into SQLite. | ||
cd "${DIR}" || fail "Could not cd to ${DIR}" | ||
make tmp/dron.db || fail "Could not make tmp/dron.db" | ||
make tmp/chebi.db || fail "Could not make tmp/chebi.db" | ||
|
||
# Find DRON ingredients matching ChEBI labels. | ||
sqlite3 "${DB}" < "${SCRIPTSDIR}/obsolete-dron-ingredients.sql" \ | ||
|| fail "Could not run query for ingredients" | ||
|
||
# Save obsolete.tsv. | ||
cd "${TEMPLATEDIR}" \ | ||
&& sqlite3 "${DB}" < "${SCRIPTSDIR}/save-dron-tables.sql" \ | ||
|| fail "Could not save updated obsolete.tsv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
ATTACH 'tmp/dron.db' AS dron; | ||
ATTACH 'tmp/chebi.db' AS chebi; | ||
|
||
CREATE INDEX IF NOT EXISTS dron.idx_ingredient_label ON ingredient(label); | ||
WITH labels AS ( | ||
SELECT subject, object AS label | ||
FROM chebi.chebi | ||
WHERE predicate = 'rdfs:label' | ||
AND subject NOT IN ( | ||
SELECT subject | ||
FROM chebi.chebi | ||
WHERE predicate = 'owl:deprecated' | ||
) | ||
) | ||
INSERT OR IGNORE INTO dron.obsolete | ||
SELECT | ||
i.curie AS curie, | ||
'obsolete ' || i.label AS label, | ||
'owl:Class' AS type, | ||
l.subject AS replaced_by | ||
FROM dron.ingredient AS i | ||
JOIN labels AS l ON l.label = i.label | ||
WHERE i.curie LIKE 'DRON:%'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.