-
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.
Merge pull request #26 from mcwdsi/update-labels
Update Labels
- Loading branch information
Showing
11 changed files
with
62,240 additions
and
62,033 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
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,67 @@ | ||
-- Create RxNorm tables in a SQLite database. | ||
-- Adapted from their scripts/mysql/Table_scripts_mysql_rxn.sql | ||
|
||
-- DROP TABLE IF EXISTS RXNCONSO; | ||
CREATE TABLE RXNCONSO | ||
( | ||
RXCUI varchar(8) NOT NULL, | ||
LAT varchar (3) DEFAULT 'ENG' NOT NULL, | ||
TS varchar (1), | ||
LUI varchar(8), | ||
STT varchar (3), | ||
SUI varchar (8), | ||
ISPREF varchar (1), | ||
RXAUI varchar(8) NOT NULL, | ||
SAUI varchar (50), | ||
SCUI varchar (50), | ||
SDUI varchar (50), | ||
SAB varchar (20) NOT NULL, | ||
TTY varchar (20) NOT NULL, | ||
CODE varchar (50) NOT NULL, | ||
STR varchar (3000) NOT NULL, | ||
SRL varchar (10), | ||
SUPPRESS varchar (1), | ||
CVF varchar(50) | ||
) | ||
; | ||
|
||
-- DROP TABLE IF EXISTS RXNSAT; | ||
CREATE TABLE RXNSAT | ||
( | ||
RXCUI varchar(8) , | ||
LUI varchar(8), | ||
SUI varchar(8), | ||
RXAUI varchar(9), | ||
STYPE varchar (50), | ||
CODE varchar (50), | ||
ATUI varchar(11), | ||
SATUI varchar (50), | ||
ATN varchar (1000) NOT NULL, | ||
SAB varchar (20) NOT NULL, | ||
ATV varchar (4000), | ||
SUPPRESS varchar (1), | ||
CVF varchar (50) | ||
) | ||
; | ||
|
||
-- DROP TABLE IF EXISTS RXNREL; | ||
CREATE TABLE RXNREL | ||
( | ||
RXCUI1 varchar(8) , | ||
RXAUI1 varchar(8), | ||
STYPE1 varchar(50), | ||
REL varchar(4) , | ||
RXCUI2 varchar(8) , | ||
RXAUI2 varchar(8), | ||
STYPE2 varchar(50), | ||
RELA varchar(100) , | ||
RUI varchar(10), | ||
SRUI varchar(50), | ||
SAB varchar(20) NOT NULL, | ||
SL varchar(1000), | ||
DIR varchar(1), | ||
RG varchar(10), | ||
SUPPRESS varchar(1), | ||
CVF varchar(50) | ||
) | ||
; |
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,25 @@ | ||
#!/bin/sh | ||
|
||
RXNORM=${1:?Please enter an RxNorm_full version: MMDDYYY} | ||
UMLS_APIKEY=${UMLS_APIKEY:-2} | ||
UMLS_APIKEY=${UMLS_APIKEY:?Please provide a UMLS API key https://uts.nlm.nih.gov/uts/edit-profile} | ||
|
||
fail() { | ||
echo "ERROR: $@" | ||
exit 1 | ||
} | ||
|
||
ROOT=$(git rev-parse --show-toplevel) || fail "Not a git repository" | ||
DIR="${ROOT}/src/ontology/tmp/rxnorm" | ||
FILE="${DIR}/RxNorm_full_${RXNORM}.zip" | ||
|
||
mkdir -p "${DIR}" || fail "Could not create ${DIR}" | ||
|
||
echo "Downloading RxNorm_full_${RXNORM}" | ||
curl -L -o "${FILE}" --fail-with-body \ | ||
"https://uts-ws.nlm.nih.gov/download?url=https://download.nlm.nih.gov/umls/kss/rxnorm/RxNorm_full_${RXNORM}.zip&apiKey=${UMLS_APIKEY}" \ | ||
|| fail "Could not download ${FILE}" | ||
|
||
echo "Extracting RRF files to ${DIR}/" | ||
unzip -j -d "${DIR}" "${FILE}" rrf/* \ | ||
|| fail "Could not unzip ${FILE}" |
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,32 @@ | ||
-- Create RxNorm tables in a SQLite database. | ||
-- Adapted from their scripts/mysql/Table_scripts_mysql_rxn.sql | ||
|
||
DROP INDEX IF EXISTS IDX_RXNCONSO_RXCUI; | ||
CREATE INDEX IDX_RXNCONSO_RXCUI ON RXNCONSO(RXCUI); | ||
|
||
DROP INDEX IF EXISTS IDX_RXNCONSO_RXAUI; | ||
CREATE INDEX IDX_RXNCONSO_RXAUI ON RXNCONSO(RXAUI); | ||
|
||
DROP INDEX IF EXISTS IDX_RXNCONSO_SAB; | ||
CREATE INDEX IDX_RXNCONSO_SAB ON RXNCONSO(SAB); | ||
|
||
DROP INDEX IF EXISTS IDX_RXNSAT_RXCUI; | ||
CREATE INDEX IDX_RXNSAT_RXCUI ON RXNSAT(RXCUI); | ||
|
||
DROP INDEX IF EXISTS IDX_RXNSAT_SAB; | ||
CREATE INDEX IDX_RXNSAT_SAB ON RXNSAT(SAB); | ||
|
||
DROP INDEX IF EXISTS IDX_RXNREL_RXCUI1; | ||
CREATE INDEX IDX_RXNREL_RXCUI1 ON RXNREL(RXCUI1); | ||
|
||
DROP INDEX IF EXISTS IDX_RXNREL_RXCUI2; | ||
CREATE INDEX IDX_RXNREL_RXCUI2 ON RXNREL(RXCUI2); | ||
|
||
DROP INDEX IF EXISTS IDX_RXNREL_RXAUI1; | ||
CREATE INDEX IDX_RXNREL_RXAUI1 ON RXNREL(RXAUI1); | ||
|
||
DROP INDEX IF EXISTS IDX_RXNREL_RXAUI2; | ||
CREATE INDEX IDX_RXNREL_RXAUI2 ON RXNREL(RXAUI2); | ||
|
||
DROP INDEX IF EXISTS IDX_RXNREL_RELA; | ||
CREATE INDEX IDX_RXNREL_RELA ON RXNREL(RELA); |
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,10 @@ | ||
-- Load RxNorm RRF tables into SQLite. | ||
|
||
PRAGMA foreign_keys = ON; | ||
|
||
.mode csv | ||
.separator | | ||
|
||
.import tmp/rxnorm/RXNCONSO.RRF RXNCONSO | ||
.import tmp/rxnorm/RXNSAT.RRF RXNSAT | ||
.import tmp/rxnorm/RXNREL.RRF RXNREL |
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
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,51 @@ | ||
ATTACH 'tmp/dron.db' AS dron; | ||
ATTACH 'tmp/chebi.db' AS chebi; | ||
ATTACH 'tmp/rxnorm.db' AS rxnorm; | ||
|
||
-- Update labels from ChEBI. | ||
UPDATE dron.ingredient AS d | ||
SET label = c.object | ||
FROM chebi.chebi AS c | ||
WHERE d.curie LIKE 'CHEBI:%' | ||
AND d.curie = c.subject | ||
AND c.predicate = 'rdfs:label' | ||
AND d.label != c.object; | ||
|
||
-- Update ingredient labels from RxNorm | ||
UPDATE dron.ingredient AS d | ||
SET label = r.STR | ||
FROM rxnorm.RXNCONSO AS r | ||
WHERE d.curie LIKE 'DRON:%' | ||
AND d.rxcui = r.RXCUI | ||
AND r.SAB = 'RXNORM' | ||
AND r.TTY = 'IN'; | ||
|
||
-- clinical_drug_form | ||
CREATE INDEX IF NOT EXISTS dron.clinical_drug_form_rxcui | ||
ON clinical_drug_form(rxcui); | ||
UPDATE dron.clinical_drug_form AS d | ||
SET label = r.STR | ||
FROM rxnorm.RXNCONSO AS r | ||
WHERE d.rxcui = r.RXCUI | ||
AND r.SAB = 'RXNORM' | ||
AND r.TTY = 'SCDF'; | ||
|
||
-- clinical_drug | ||
CREATE INDEX IF NOT EXISTS dron.clinical_drug_rxcui | ||
ON clinical_drug(rxcui); | ||
UPDATE dron.clinical_drug AS d | ||
SET label = r.STR | ||
FROM rxnorm.RXNCONSO AS r | ||
WHERE d.rxcui = r.RXCUI | ||
AND r.SAB = 'RXNORM' | ||
AND r.TTY = 'SCD'; | ||
|
||
-- branded_drug | ||
CREATE INDEX IF NOT EXISTS dron.branded_drug_rxcui | ||
ON branded_drug(rxcui); | ||
UPDATE dron.branded_drug AS d | ||
SET label = r.STR | ||
FROM rxnorm.RXNCONSO AS r | ||
WHERE d.rxcui = r.RXCUI | ||
AND r.SAB = 'RXNORM' | ||
AND r.TTY = 'SBD'; |
Oops, something went wrong.