Manith Marapperuma 👾
commited on
Commit
·
9bc8d7e
1
Parent(s):
ff49da5
initial_commit
Browse files- DrugInteraction.owl +399 -0
- Notebooks/DrugInteraction.owl +72 -0
- Notebooks/Final/test_with_input.ipynb +207 -0
- Notebooks/sparql.ipynb +169 -0
- Notebooks/testOnto.ipynb +320 -0
- agents/__init__.py +4 -0
- agents/__pycache__/__init__.cpython-312.pyc +0 -0
- agents/__pycache__/alternative_agent.cpython-312.pyc +0 -0
- agents/__pycache__/base_agent.cpython-312.pyc +0 -0
- agents/__pycache__/conflict_agent.cpython-312.pyc +0 -0
- agents/__pycache__/interaction_agent.cpython-312.pyc +0 -0
- agents/__pycache__/similarity_agent.cpython-312.pyc +0 -0
- agents/alternative_agent.py +22 -0
- agents/base_agent.py +23 -0
- agents/conflict_agent.py +22 -0
- agents/interaction_agent.py +22 -0
- agents/similarity_agent.py +22 -0
- analyzers/__init__.py +1 -0
- analyzers/__pycache__/__init__.cpython-312.pyc +0 -0
- analyzers/__pycache__/drug_interaction_analyzer.cpython-312.pyc +0 -0
- analyzers/drug_interaction_analyzer.py +89 -0
- app.py +242 -0
- appcli.py +171 -0
- img/header-image.webp +0 -0
- img/header_image.webp +0 -0
- img/img.png +0 -0
- ontology/DrugInteraction.owl +399 -0
- requirements.txt +7 -0
DrugInteraction.owl
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<rdf:RDF
|
| 3 |
+
xmlns="http://www.example.org/DrugInteraction.owl#"
|
| 4 |
+
xmlns:owl="http://www.w3.org/2002/07/owl#"
|
| 5 |
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
| 6 |
+
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
| 7 |
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
|
| 8 |
+
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
|
| 9 |
+
|
| 10 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#">
|
| 11 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/>
|
| 12 |
+
<rdfs:comment>
|
| 13 |
+
Ontology capturing Drug Interactions, Alternatives, Conflicts, and Similarities.
|
| 14 |
+
</rdfs:comment>
|
| 15 |
+
</rdf:Description>
|
| 16 |
+
<!-- -->
|
| 17 |
+
<!-- -->
|
| 18 |
+
<!-- ################################################################# -->
|
| 19 |
+
<!-- # -->
|
| 20 |
+
<!-- # Object Properties -->
|
| 21 |
+
<!-- # -->
|
| 22 |
+
<!-- ################################################################# -->
|
| 23 |
+
<!-- -->
|
| 24 |
+
<!-- -->
|
| 25 |
+
<!-- http://www.example.org/DrugInteraction.owl#hasAlternative -->
|
| 26 |
+
|
| 27 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#hasAlternative">
|
| 28 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
|
| 29 |
+
<rdfs:domain rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 30 |
+
<rdfs:range rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 31 |
+
<rdfs:label>hasAlternative</rdfs:label>
|
| 32 |
+
</rdf:Description>
|
| 33 |
+
<!-- -->
|
| 34 |
+
<!-- http://www.example.org/DrugInteraction.owl#hasConflict -->
|
| 35 |
+
|
| 36 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#hasConflict">
|
| 37 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
|
| 38 |
+
<rdfs:domain rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 39 |
+
<rdfs:range rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 40 |
+
<rdfs:label>hasConflict</rdfs:label>
|
| 41 |
+
</rdf:Description>
|
| 42 |
+
<!-- -->
|
| 43 |
+
<!-- http://www.example.org/DrugInteraction.owl#hasInteraction -->
|
| 44 |
+
|
| 45 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#hasInteraction">
|
| 46 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
|
| 47 |
+
<rdfs:domain rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 48 |
+
<rdfs:range rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 49 |
+
<rdfs:label>hasInteraction</rdfs:label>
|
| 50 |
+
</rdf:Description>
|
| 51 |
+
<!-- -->
|
| 52 |
+
<!-- http://www.example.org/DrugInteraction.owl#hasSimilarity -->
|
| 53 |
+
|
| 54 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#hasSimilarity">
|
| 55 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
|
| 56 |
+
<rdfs:domain rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 57 |
+
<rdfs:range rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 58 |
+
<rdfs:label>hasSimilarity</rdfs:label>
|
| 59 |
+
</rdf:Description>
|
| 60 |
+
<!-- -->
|
| 61 |
+
<!-- -->
|
| 62 |
+
<!-- -->
|
| 63 |
+
<!-- ################################################################# -->
|
| 64 |
+
<!-- # -->
|
| 65 |
+
<!-- # Classes -->
|
| 66 |
+
<!-- # -->
|
| 67 |
+
<!-- ################################################################# -->
|
| 68 |
+
<!-- -->
|
| 69 |
+
<!-- -->
|
| 70 |
+
<!-- http://www.example.org/DrugInteraction.owl#AlternativeDrug -->
|
| 71 |
+
|
| 72 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#AlternativeDrug">
|
| 73 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 74 |
+
<rdfs:label>AlternativeDrug</rdfs:label>
|
| 75 |
+
</rdf:Description>
|
| 76 |
+
<!-- -->
|
| 77 |
+
<!-- http://www.example.org/DrugInteraction.owl#Conflict -->
|
| 78 |
+
|
| 79 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Conflict">
|
| 80 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 81 |
+
<rdfs:label>Conflict</rdfs:label>
|
| 82 |
+
</rdf:Description>
|
| 83 |
+
<!-- -->
|
| 84 |
+
<!-- http://www.example.org/DrugInteraction.owl#Consumable -->
|
| 85 |
+
|
| 86 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Consumable">
|
| 87 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 88 |
+
<rdfs:comment>consumables</rdfs:comment>
|
| 89 |
+
</rdf:Description>
|
| 90 |
+
<!-- -->
|
| 91 |
+
<!-- http://www.example.org/DrugInteraction.owl#Drug -->
|
| 92 |
+
|
| 93 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Drug">
|
| 94 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 95 |
+
<rdfs:label>Drug</rdfs:label>
|
| 96 |
+
</rdf:Description>
|
| 97 |
+
<!-- -->
|
| 98 |
+
<!-- http://www.example.org/DrugInteraction.owl#DrugInteraction -->
|
| 99 |
+
|
| 100 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#DrugInteraction">
|
| 101 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 102 |
+
<rdfs:label>DrugInteraction</rdfs:label>
|
| 103 |
+
</rdf:Description>
|
| 104 |
+
<!-- -->
|
| 105 |
+
<!-- http://www.example.org/DrugInteraction.owl#Similarity -->
|
| 106 |
+
|
| 107 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Similarity">
|
| 108 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 109 |
+
<rdfs:label>Similarity</rdfs:label>
|
| 110 |
+
</rdf:Description>
|
| 111 |
+
<!-- -->
|
| 112 |
+
<!-- -->
|
| 113 |
+
<!-- -->
|
| 114 |
+
<!-- ################################################################# -->
|
| 115 |
+
<!-- # -->
|
| 116 |
+
<!-- # Individuals -->
|
| 117 |
+
<!-- # -->
|
| 118 |
+
<!-- ################################################################# -->
|
| 119 |
+
<!-- -->
|
| 120 |
+
<!-- -->
|
| 121 |
+
<!-- http://www.example.org/DrugInteraction.owl#Alcohol -->
|
| 122 |
+
|
| 123 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Alcohol">
|
| 124 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 125 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 126 |
+
<rdfs:label>Alcohol</rdfs:label>
|
| 127 |
+
</rdf:Description>
|
| 128 |
+
<!-- -->
|
| 129 |
+
<!-- http://www.example.org/DrugInteraction.owl#Amlodipine -->
|
| 130 |
+
|
| 131 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Amlodipine">
|
| 132 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 133 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 134 |
+
<hasSimilarity rdf:resource="http://www.example.org/DrugInteraction.owl#Nifedipine"/>
|
| 135 |
+
<rdfs:label>Amlodipine</rdfs:label>
|
| 136 |
+
</rdf:Description>
|
| 137 |
+
<!-- -->
|
| 138 |
+
<!-- http://www.example.org/DrugInteraction.owl#Apixaban -->
|
| 139 |
+
|
| 140 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Apixaban">
|
| 141 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 142 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 143 |
+
<rdfs:label>Apixaban</rdfs:label>
|
| 144 |
+
</rdf:Description>
|
| 145 |
+
<!-- -->
|
| 146 |
+
<!-- http://www.example.org/DrugInteraction.owl#Aspirin -->
|
| 147 |
+
|
| 148 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Aspirin">
|
| 149 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 150 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 151 |
+
<rdfs:label>Aspirin</rdfs:label>
|
| 152 |
+
</rdf:Description>
|
| 153 |
+
<!-- -->
|
| 154 |
+
<!-- http://www.example.org/DrugInteraction.owl#Atorvastatin -->
|
| 155 |
+
|
| 156 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Atorvastatin">
|
| 157 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 158 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 159 |
+
<hasConflict rdf:resource="http://www.example.org/DrugInteraction.owl#grapefruitJuice"/>
|
| 160 |
+
<rdfs:label>Atorvastatin</rdfs:label>
|
| 161 |
+
</rdf:Description>
|
| 162 |
+
<!-- -->
|
| 163 |
+
<!-- http://www.example.org/DrugInteraction.owl#Caffeine -->
|
| 164 |
+
|
| 165 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Caffeine">
|
| 166 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 167 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 168 |
+
<rdfs:label>Caffeine</rdfs:label>
|
| 169 |
+
</rdf:Description>
|
| 170 |
+
<!-- -->
|
| 171 |
+
<!-- http://www.example.org/DrugInteraction.owl#Ciprofloxacin -->
|
| 172 |
+
|
| 173 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Ciprofloxacin">
|
| 174 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 175 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 176 |
+
<rdfs:label>Ciprofloxacin</rdfs:label>
|
| 177 |
+
</rdf:Description>
|
| 178 |
+
<!-- -->
|
| 179 |
+
<!-- http://www.example.org/DrugInteraction.owl#Clopidogrel -->
|
| 180 |
+
|
| 181 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Clopidogrel">
|
| 182 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 183 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 184 |
+
<hasInteraction rdf:resource="http://www.example.org/DrugInteraction.owl#Omeprazole"/>
|
| 185 |
+
<rdfs:label>Clopidogrel</rdfs:label>
|
| 186 |
+
</rdf:Description>
|
| 187 |
+
<!-- -->
|
| 188 |
+
<!-- http://www.example.org/DrugInteraction.owl#Empagliflozin -->
|
| 189 |
+
|
| 190 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Empagliflozin">
|
| 191 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 192 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 193 |
+
<rdfs:label>Empagliflozin</rdfs:label>
|
| 194 |
+
</rdf:Description>
|
| 195 |
+
<!-- -->
|
| 196 |
+
<!-- http://www.example.org/DrugInteraction.owl#Erythromycin -->
|
| 197 |
+
|
| 198 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Erythromycin">
|
| 199 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 200 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 201 |
+
<rdfs:label>Erythromycin</rdfs:label>
|
| 202 |
+
</rdf:Description>
|
| 203 |
+
<!-- -->
|
| 204 |
+
<!-- http://www.example.org/DrugInteraction.owl#Esomeprazole -->
|
| 205 |
+
|
| 206 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Esomeprazole">
|
| 207 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 208 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 209 |
+
<rdfs:label>Esomeprazole</rdfs:label>
|
| 210 |
+
</rdf:Description>
|
| 211 |
+
<!-- -->
|
| 212 |
+
<!-- http://www.example.org/DrugInteraction.owl#Fluoxetine -->
|
| 213 |
+
|
| 214 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Fluoxetine">
|
| 215 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 216 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 217 |
+
<rdfs:label>Fluoxetine</rdfs:label>
|
| 218 |
+
</rdf:Description>
|
| 219 |
+
<!-- -->
|
| 220 |
+
<!-- http://www.example.org/DrugInteraction.owl#Glucophage -->
|
| 221 |
+
|
| 222 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Glucophage">
|
| 223 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 224 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 225 |
+
<rdfs:label>Glucophage</rdfs:label>
|
| 226 |
+
</rdf:Description>
|
| 227 |
+
<!-- -->
|
| 228 |
+
<!-- http://www.example.org/DrugInteraction.owl#Ibuprofen -->
|
| 229 |
+
|
| 230 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Ibuprofen">
|
| 231 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 232 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 233 |
+
<hasSimilarity rdf:resource="http://www.example.org/DrugInteraction.owl#Naproxen"/>
|
| 234 |
+
<rdfs:label>Ibuprofen</rdfs:label>
|
| 235 |
+
</rdf:Description>
|
| 236 |
+
<!-- -->
|
| 237 |
+
<!-- http://www.example.org/DrugInteraction.owl#Lisinopril -->
|
| 238 |
+
|
| 239 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Lisinopril">
|
| 240 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 241 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 242 |
+
<hasAlternative rdf:resource="http://www.example.org/DrugInteraction.owl#Losartan"/>
|
| 243 |
+
<hasInteraction rdf:resource="http://www.example.org/DrugInteraction.owl#Spironolactone"/>
|
| 244 |
+
<rdfs:label>Lisinopril</rdfs:label>
|
| 245 |
+
</rdf:Description>
|
| 246 |
+
<!-- -->
|
| 247 |
+
<!-- http://www.example.org/DrugInteraction.owl#Losartan -->
|
| 248 |
+
|
| 249 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Losartan">
|
| 250 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 251 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 252 |
+
<rdfs:label>Losartan</rdfs:label>
|
| 253 |
+
</rdf:Description>
|
| 254 |
+
<!-- -->
|
| 255 |
+
<!-- http://www.example.org/DrugInteraction.owl#Metformin -->
|
| 256 |
+
|
| 257 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Metformin">
|
| 258 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 259 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 260 |
+
<hasAlternative rdf:resource="http://www.example.org/DrugInteraction.owl#Empagliflozin"/>
|
| 261 |
+
<hasInteraction rdf:resource="http://www.example.org/DrugInteraction.owl#Ciprofloxacin"/>
|
| 262 |
+
<hasSimilarity rdf:resource="http://www.example.org/DrugInteraction.owl#Glucophage"/>
|
| 263 |
+
<rdfs:label>Metformin</rdfs:label>
|
| 264 |
+
</rdf:Description>
|
| 265 |
+
<!-- -->
|
| 266 |
+
<!-- http://www.example.org/DrugInteraction.owl#Metronidazole -->
|
| 267 |
+
|
| 268 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Metronidazole">
|
| 269 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 270 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 271 |
+
<hasConflict rdf:resource="http://www.example.org/DrugInteraction.owl#Alcohol"/>
|
| 272 |
+
<rdfs:label>Metronidazole</rdfs:label>
|
| 273 |
+
</rdf:Description>
|
| 274 |
+
<!-- -->
|
| 275 |
+
<!-- http://www.example.org/DrugInteraction.owl#Naproxen -->
|
| 276 |
+
|
| 277 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Naproxen">
|
| 278 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 279 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 280 |
+
<rdfs:label>Naproxen</rdfs:label>
|
| 281 |
+
</rdf:Description>
|
| 282 |
+
<!-- -->
|
| 283 |
+
<!-- http://www.example.org/DrugInteraction.owl#Nifedipine -->
|
| 284 |
+
|
| 285 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Nifedipine">
|
| 286 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 287 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 288 |
+
<rdfs:label>Nifedipine</rdfs:label>
|
| 289 |
+
</rdf:Description>
|
| 290 |
+
<!-- -->
|
| 291 |
+
<!-- http://www.example.org/DrugInteraction.owl#Omeprazole -->
|
| 292 |
+
|
| 293 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Omeprazole">
|
| 294 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 295 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 296 |
+
<hasAlternative rdf:resource="http://www.example.org/DrugInteraction.owl#Pantoprazole"/>
|
| 297 |
+
<hasSimilarity rdf:resource="http://www.example.org/DrugInteraction.owl#Esomeprazole"/>
|
| 298 |
+
<rdfs:label>Omeprazole</rdfs:label>
|
| 299 |
+
</rdf:Description>
|
| 300 |
+
<!-- -->
|
| 301 |
+
<!-- http://www.example.org/DrugInteraction.owl#Pantoprazole -->
|
| 302 |
+
|
| 303 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Pantoprazole">
|
| 304 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 305 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 306 |
+
<rdfs:label>Pantoprazole</rdfs:label>
|
| 307 |
+
</rdf:Description>
|
| 308 |
+
<!-- -->
|
| 309 |
+
<!-- http://www.example.org/DrugInteraction.owl#Phenelzine -->
|
| 310 |
+
|
| 311 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Phenelzine">
|
| 312 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 313 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 314 |
+
<hasConflict rdf:resource="http://www.example.org/DrugInteraction.owl#tyramineFoods"/>
|
| 315 |
+
<rdfs:label>Phenelzine</rdfs:label>
|
| 316 |
+
</rdf:Description>
|
| 317 |
+
<!-- -->
|
| 318 |
+
<!-- http://www.example.org/DrugInteraction.owl#Rosuvastatin -->
|
| 319 |
+
|
| 320 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Rosuvastatin">
|
| 321 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 322 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 323 |
+
<rdfs:label>Rosuvastatin</rdfs:label>
|
| 324 |
+
</rdf:Description>
|
| 325 |
+
<!-- -->
|
| 326 |
+
<!-- http://www.example.org/DrugInteraction.owl#Sertraline -->
|
| 327 |
+
|
| 328 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Sertraline">
|
| 329 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 330 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 331 |
+
<hasSimilarity rdf:resource="http://www.example.org/DrugInteraction.owl#Fluoxetine"/>
|
| 332 |
+
<rdfs:label>Sertraline</rdfs:label>
|
| 333 |
+
</rdf:Description>
|
| 334 |
+
<!-- -->
|
| 335 |
+
<!-- http://www.example.org/DrugInteraction.owl#Simvastatin -->
|
| 336 |
+
|
| 337 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Simvastatin">
|
| 338 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 339 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 340 |
+
<hasAlternative rdf:resource="http://www.example.org/DrugInteraction.owl#Rosuvastatin"/>
|
| 341 |
+
<hasInteraction rdf:resource="http://www.example.org/DrugInteraction.owl#Erythromycin"/>
|
| 342 |
+
<rdfs:label>Simvastatin</rdfs:label>
|
| 343 |
+
</rdf:Description>
|
| 344 |
+
<!-- -->
|
| 345 |
+
<!-- http://www.example.org/DrugInteraction.owl#Spironolactone -->
|
| 346 |
+
|
| 347 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Spironolactone">
|
| 348 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 349 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 350 |
+
<rdfs:label>Spironolactone</rdfs:label>
|
| 351 |
+
</rdf:Description>
|
| 352 |
+
<!-- -->
|
| 353 |
+
<!-- http://www.example.org/DrugInteraction.owl#Theophylline -->
|
| 354 |
+
|
| 355 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Theophylline">
|
| 356 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 357 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 358 |
+
<hasConflict rdf:resource="http://www.example.org/DrugInteraction.owl#Caffeine"/>
|
| 359 |
+
<rdfs:label>Theophylline</rdfs:label>
|
| 360 |
+
</rdf:Description>
|
| 361 |
+
<!-- -->
|
| 362 |
+
<!-- http://www.example.org/DrugInteraction.owl#Warfarin -->
|
| 363 |
+
|
| 364 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Warfarin">
|
| 365 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 366 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 367 |
+
<hasAlternative rdf:resource="http://www.example.org/DrugInteraction.owl#Apixaban"/>
|
| 368 |
+
<hasConflict rdf:resource="http://www.example.org/DrugInteraction.owl#greenLeafyVegetables"/>
|
| 369 |
+
<hasInteraction rdf:resource="http://www.example.org/DrugInteraction.owl#Aspirin"/>
|
| 370 |
+
<rdfs:label>Warfarin</rdfs:label>
|
| 371 |
+
</rdf:Description>
|
| 372 |
+
<!-- -->
|
| 373 |
+
<!-- http://www.example.org/DrugInteraction.owl#grapefruitJuice -->
|
| 374 |
+
|
| 375 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#grapefruitJuice">
|
| 376 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 377 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 378 |
+
<rdfs:label>GrapefruitJuice</rdfs:label>
|
| 379 |
+
</rdf:Description>
|
| 380 |
+
<!-- -->
|
| 381 |
+
<!-- http://www.example.org/DrugInteraction.owl#greenLeafyVegetables -->
|
| 382 |
+
|
| 383 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#greenLeafyVegetables">
|
| 384 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 385 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 386 |
+
<rdfs:label>GreenLeafyVegetables</rdfs:label>
|
| 387 |
+
</rdf:Description>
|
| 388 |
+
<!-- -->
|
| 389 |
+
<!-- http://www.example.org/DrugInteraction.owl#tyramineFoods -->
|
| 390 |
+
|
| 391 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#tyramineFoods">
|
| 392 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 393 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 394 |
+
<rdfs:label>TyramineFoods</rdfs:label>
|
| 395 |
+
</rdf:Description>
|
| 396 |
+
<!-- -->
|
| 397 |
+
<!-- Generated by the OWL API (version 4.5.29.2024-05-13T12:11:03Z) https://github.com/owlcs/owlapi -->
|
| 398 |
+
|
| 399 |
+
</rdf:RDF>
|
Notebooks/DrugInteraction.owl
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<rdf:RDF xmlns="http://www.example.org/DrugInteraction.owl#"
|
| 3 |
+
xml:base="http://www.example.org/DrugInteraction.owl"
|
| 4 |
+
xmlns:owl="http://www.w3.org/2002/07/owl#"
|
| 5 |
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
| 6 |
+
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
|
| 7 |
+
|
| 8 |
+
<!-- Ontology Header -->
|
| 9 |
+
<owl:Ontology rdf:about="http://www.example.org/DrugInteraction.owl"/>
|
| 10 |
+
|
| 11 |
+
<!-- Classes -->
|
| 12 |
+
<owl:Class rdf:about="#TestProgram"/>
|
| 13 |
+
<owl:Class rdf:about="#Drug"/>
|
| 14 |
+
<owl:Class rdf:about="#Interaction"/>
|
| 15 |
+
<owl:Class rdf:about="#Conflict"/>
|
| 16 |
+
<owl:Class rdf:about="#Similarity"/>
|
| 17 |
+
|
| 18 |
+
<!-- Object Properties -->
|
| 19 |
+
<owl:ObjectProperty rdf:about="#causedBy">
|
| 20 |
+
<rdfs:domain rdf:resource="#Interaction"/>
|
| 21 |
+
<rdfs:range rdf:resource="#Drug"/>
|
| 22 |
+
</owl:ObjectProperty>
|
| 23 |
+
|
| 24 |
+
<owl:ObjectProperty rdf:about="#between">
|
| 25 |
+
<rdfs:domain rdf:resource="#Conflict"/>
|
| 26 |
+
<rdfs:range rdf:resource="#Drug"/>
|
| 27 |
+
</owl:ObjectProperty>
|
| 28 |
+
|
| 29 |
+
<owl:ObjectProperty rdf:about="#relatedTo">
|
| 30 |
+
<rdfs:domain rdf:resource="#Similarity"/>
|
| 31 |
+
<rdfs:range rdf:resource="#Drug"/>
|
| 32 |
+
</owl:ObjectProperty>
|
| 33 |
+
|
| 34 |
+
<!-- Individuals: Drugs -->
|
| 35 |
+
<owl:NamedIndividual rdf:about="#Warfarin">
|
| 36 |
+
<rdf:type rdf:resource="#Drug"/>
|
| 37 |
+
</owl:NamedIndividual>
|
| 38 |
+
<owl:NamedIndividual rdf:about="#Aspirin">
|
| 39 |
+
<rdf:type rdf:resource="#Drug"/>
|
| 40 |
+
</owl:NamedIndividual>
|
| 41 |
+
<owl:NamedIndividual rdf:about="#Nitroglycerin">
|
| 42 |
+
<rdf:type rdf:resource="#Drug"/>
|
| 43 |
+
</owl:NamedIndividual>
|
| 44 |
+
<owl:NamedIndividual rdf:about="#Sildenafil">
|
| 45 |
+
<rdf:type rdf:resource="#Drug"/>
|
| 46 |
+
</owl:NamedIndividual>
|
| 47 |
+
|
| 48 |
+
<!-- Instances: Interactions -->
|
| 49 |
+
<owl:NamedIndividual rdf:about="#Interaction1">
|
| 50 |
+
<rdf:type rdf:resource="#Interaction"/>
|
| 51 |
+
<causedBy rdf:resource="#Warfarin"/>
|
| 52 |
+
<causedBy rdf:resource="#Aspirin"/>
|
| 53 |
+
<rdfs:label>Warfarin and Aspirin Interaction</rdfs:label>
|
| 54 |
+
</owl:NamedIndividual>
|
| 55 |
+
|
| 56 |
+
<!-- Instances: Conflicts -->
|
| 57 |
+
<owl:NamedIndividual rdf:about="#Conflict1">
|
| 58 |
+
<rdf:type rdf:resource="#Conflict"/>
|
| 59 |
+
<between rdf:resource="#Sildenafil"/>
|
| 60 |
+
<between rdf:resource="#Nitroglycerin"/>
|
| 61 |
+
<rdfs:label>Sildenafil and Nitroglycerin Conflict</rdfs:label>
|
| 62 |
+
</owl:NamedIndividual>
|
| 63 |
+
|
| 64 |
+
<!-- Instances: Similarities -->
|
| 65 |
+
<owl:NamedIndividual rdf:about="#Similarity1">
|
| 66 |
+
<rdf:type rdf:resource="#Similarity"/>
|
| 67 |
+
<relatedTo rdf:resource="#Warfarin"/>
|
| 68 |
+
<relatedTo rdf:resource="#Aspirin"/>
|
| 69 |
+
<rdfs:label>Similarity Between Warfarin and Aspirin</rdfs:label>
|
| 70 |
+
</owl:NamedIndividual>
|
| 71 |
+
|
| 72 |
+
</rdf:RDF>
|
Notebooks/Final/test_with_input.ipynb
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
| 8 |
+
"source": [
|
| 9 |
+
"# Install rdflib if not already installed\n",
|
| 10 |
+
"# !pip install rdflib\n",
|
| 11 |
+
"\n",
|
| 12 |
+
"from rdflib import Graph, Namespace"
|
| 13 |
+
]
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"cell_type": "code",
|
| 17 |
+
"execution_count": 3,
|
| 18 |
+
"metadata": {},
|
| 19 |
+
"outputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "stdout",
|
| 22 |
+
"output_type": "stream",
|
| 23 |
+
"text": [
|
| 24 |
+
"Loading ontology...\n",
|
| 25 |
+
"Ontology loaded successfully.\n",
|
| 26 |
+
"\n"
|
| 27 |
+
]
|
| 28 |
+
}
|
| 29 |
+
],
|
| 30 |
+
"source": [
|
| 31 |
+
"# Step 1: Load the Ontology\n",
|
| 32 |
+
"print(\"Loading ontology...\")\n",
|
| 33 |
+
"g = Graph()\n",
|
| 34 |
+
"g.parse(\"DrugInteraction.owl\", format=\"xml\") # Ensure your OWL file is named correctly and in the same directory\n",
|
| 35 |
+
"print(\"Ontology loaded successfully.\\n\")\n"
|
| 36 |
+
]
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"cell_type": "code",
|
| 40 |
+
"execution_count": 4,
|
| 41 |
+
"metadata": {},
|
| 42 |
+
"outputs": [],
|
| 43 |
+
"source": [
|
| 44 |
+
"# Query Templates\n",
|
| 45 |
+
"query_interactions = \"\"\"\n",
|
| 46 |
+
"PREFIX ns: <http://www.example.org/DrugInteraction.owl#>\n",
|
| 47 |
+
"SELECT ?drug1 ?drug2\n",
|
| 48 |
+
"WHERE {{\n",
|
| 49 |
+
" ?drug1 ns:hasInteraction ?drug2 .\n",
|
| 50 |
+
" FILTER (STR(?drug1) = \"http://www.example.org/DrugInteraction.owl#{drug}\" || \n",
|
| 51 |
+
" STR(?drug2) = \"http://www.example.org/DrugInteraction.owl#{drug}\")\n",
|
| 52 |
+
"}}\n",
|
| 53 |
+
"\"\"\""
|
| 54 |
+
]
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"cell_type": "code",
|
| 58 |
+
"execution_count": 5,
|
| 59 |
+
"metadata": {},
|
| 60 |
+
"outputs": [],
|
| 61 |
+
"source": [
|
| 62 |
+
"query_conflicts = \"\"\"\n",
|
| 63 |
+
"PREFIX ns: <http://www.example.org/DrugInteraction.owl#>\n",
|
| 64 |
+
"SELECT ?drug1 ?drug2\n",
|
| 65 |
+
"WHERE {{\n",
|
| 66 |
+
" ?drug1 ns:hasConflict ?drug2 .\n",
|
| 67 |
+
" FILTER (STR(?drug1) = \"http://www.example.org/DrugInteraction.owl#{drug}\" || \n",
|
| 68 |
+
" STR(?drug2) = \"http://www.example.org/DrugInteraction.owl#{drug}\")\n",
|
| 69 |
+
"}}\n",
|
| 70 |
+
"\"\"\""
|
| 71 |
+
]
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"cell_type": "code",
|
| 75 |
+
"execution_count": 6,
|
| 76 |
+
"metadata": {},
|
| 77 |
+
"outputs": [],
|
| 78 |
+
"source": [
|
| 79 |
+
"query_similarities = \"\"\"\n",
|
| 80 |
+
"PREFIX ns: <http://www.example.org/DrugInteraction.owl#>\n",
|
| 81 |
+
"SELECT ?drug1 ?drug2\n",
|
| 82 |
+
"WHERE {{\n",
|
| 83 |
+
" ?drug1 ns:hasSimilarity ?drug2 .\n",
|
| 84 |
+
" FILTER (STR(?drug1) = \"http://www.example.org/DrugInteraction.owl#{drug}\" || \n",
|
| 85 |
+
" STR(?drug2) = \"http://www.example.org/DrugInteraction.owl#{drug}\")\n",
|
| 86 |
+
"}}\n",
|
| 87 |
+
"\"\"\""
|
| 88 |
+
]
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"cell_type": "code",
|
| 92 |
+
"execution_count": 7,
|
| 93 |
+
"metadata": {},
|
| 94 |
+
"outputs": [],
|
| 95 |
+
"source": [
|
| 96 |
+
"query_alternatives = \"\"\"\n",
|
| 97 |
+
"PREFIX ns: <http://www.example.org/DrugInteraction.owl#>\n",
|
| 98 |
+
"SELECT ?drug1 ?drug2\n",
|
| 99 |
+
"WHERE {{\n",
|
| 100 |
+
" ?drug1 ns:hasAlternative ?drug2 .\n",
|
| 101 |
+
" FILTER (STR(?drug1) = \"http://www.example.org/DrugInteraction.owl#{drug}\" || \n",
|
| 102 |
+
" STR(?drug2) = \"http://www.example.org/DrugInteraction.owl#{drug}\")\n",
|
| 103 |
+
"}}\n",
|
| 104 |
+
"\"\"\""
|
| 105 |
+
]
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"cell_type": "code",
|
| 109 |
+
"execution_count": 8,
|
| 110 |
+
"metadata": {},
|
| 111 |
+
"outputs": [],
|
| 112 |
+
"source": [
|
| 113 |
+
"# Function to execute a query and print results\n",
|
| 114 |
+
"def run_query(query, description, drug_name):\n",
|
| 115 |
+
" print(f\"Results for {description} involving '{drug_name}':\")\n",
|
| 116 |
+
" results = g.query(query.format(drug=drug_name))\n",
|
| 117 |
+
" if len(results) == 0:\n",
|
| 118 |
+
" print(\" No results found.\\n\")\n",
|
| 119 |
+
" else:\n",
|
| 120 |
+
" for row in results:\n",
|
| 121 |
+
" drug1_label = row[0].split('#')[-1]\n",
|
| 122 |
+
" drug2_label = row[1].split('#')[-1]\n",
|
| 123 |
+
" print(f\" {drug1_label} → {drug2_label}\")\n",
|
| 124 |
+
" print(\"\\n\")\n"
|
| 125 |
+
]
|
| 126 |
+
},
|
| 127 |
+
{
|
| 128 |
+
"cell_type": "code",
|
| 129 |
+
"execution_count": 9,
|
| 130 |
+
"metadata": {},
|
| 131 |
+
"outputs": [],
|
| 132 |
+
"source": [
|
| 133 |
+
"# Step 2: Accept User Input for Drug Names\n",
|
| 134 |
+
"def main():\n",
|
| 135 |
+
" print(\"Enter drug names separated by commas (e.g., Aspirin, Warfarin):\")\n",
|
| 136 |
+
" user_input = input(\"Drugs: \")\n",
|
| 137 |
+
" drug_names = [drug.strip() for drug in user_input.split(\",\") if drug.strip()]\n",
|
| 138 |
+
"\n",
|
| 139 |
+
" if not drug_names:\n",
|
| 140 |
+
" print(\"No drug names provided. Exiting.\")\n",
|
| 141 |
+
" return\n",
|
| 142 |
+
"\n",
|
| 143 |
+
" # Step 3: Run Queries for Each Drug\n",
|
| 144 |
+
" for drug in drug_names:\n",
|
| 145 |
+
" print(f\"\\n--- Checking for {drug} ---\")\n",
|
| 146 |
+
" run_query(query_interactions, \"Drug Interactions\", drug)\n",
|
| 147 |
+
" run_query(query_conflicts, \"Conflicts\", drug)\n",
|
| 148 |
+
" run_query(query_similarities, \"Similarities\", drug)\n",
|
| 149 |
+
" run_query(query_alternatives, \"Alternative Drugs\", drug)\n"
|
| 150 |
+
]
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"cell_type": "code",
|
| 154 |
+
"execution_count": 10,
|
| 155 |
+
"metadata": {},
|
| 156 |
+
"outputs": [
|
| 157 |
+
{
|
| 158 |
+
"name": "stdout",
|
| 159 |
+
"output_type": "stream",
|
| 160 |
+
"text": [
|
| 161 |
+
"Enter drug names separated by commas (e.g., Aspirin, Warfarin):\n",
|
| 162 |
+
"\n",
|
| 163 |
+
"--- Checking for panadol ---\n",
|
| 164 |
+
"Results for Drug Interactions involving 'panadol':\n",
|
| 165 |
+
" No results found.\n",
|
| 166 |
+
"\n",
|
| 167 |
+
"Results for Conflicts involving 'panadol':\n",
|
| 168 |
+
" No results found.\n",
|
| 169 |
+
"\n",
|
| 170 |
+
"Results for Similarities involving 'panadol':\n",
|
| 171 |
+
" No results found.\n",
|
| 172 |
+
"\n",
|
| 173 |
+
"Results for Alternative Drugs involving 'panadol':\n",
|
| 174 |
+
" No results found.\n",
|
| 175 |
+
"\n"
|
| 176 |
+
]
|
| 177 |
+
}
|
| 178 |
+
],
|
| 179 |
+
"source": [
|
| 180 |
+
"# Run the main function\n",
|
| 181 |
+
"if __name__ == \"__main__\":\n",
|
| 182 |
+
" main()"
|
| 183 |
+
]
|
| 184 |
+
}
|
| 185 |
+
],
|
| 186 |
+
"metadata": {
|
| 187 |
+
"kernelspec": {
|
| 188 |
+
"display_name": "Python 3",
|
| 189 |
+
"language": "python",
|
| 190 |
+
"name": "python3"
|
| 191 |
+
},
|
| 192 |
+
"language_info": {
|
| 193 |
+
"codemirror_mode": {
|
| 194 |
+
"name": "ipython",
|
| 195 |
+
"version": 3
|
| 196 |
+
},
|
| 197 |
+
"file_extension": ".py",
|
| 198 |
+
"mimetype": "text/x-python",
|
| 199 |
+
"name": "python",
|
| 200 |
+
"nbconvert_exporter": "python",
|
| 201 |
+
"pygments_lexer": "ipython3",
|
| 202 |
+
"version": "3.12.3"
|
| 203 |
+
}
|
| 204 |
+
},
|
| 205 |
+
"nbformat": 4,
|
| 206 |
+
"nbformat_minor": 2
|
| 207 |
+
}
|
Notebooks/sparql.ipynb
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [
|
| 8 |
+
{
|
| 9 |
+
"name": "stdout",
|
| 10 |
+
"output_type": "stream",
|
| 11 |
+
"text": [
|
| 12 |
+
"Loading ontology...\n",
|
| 13 |
+
"Ontology loaded successfully.\n",
|
| 14 |
+
"\n"
|
| 15 |
+
]
|
| 16 |
+
}
|
| 17 |
+
],
|
| 18 |
+
"source": [
|
| 19 |
+
"# Install rdflib if not already installed\n",
|
| 20 |
+
"# !pip install rdflib\n",
|
| 21 |
+
"\n",
|
| 22 |
+
"from rdflib import Graph, Namespace\n",
|
| 23 |
+
"\n",
|
| 24 |
+
"# Step 1: Load the Ontology\n",
|
| 25 |
+
"print(\"Loading ontology...\")\n",
|
| 26 |
+
"g = Graph()\n",
|
| 27 |
+
"g.parse(\"DrugInteraction.owl\", format=\"xml\")\n",
|
| 28 |
+
"print(\"Ontology loaded successfully.\\n\")"
|
| 29 |
+
]
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"cell_type": "code",
|
| 33 |
+
"execution_count": 2,
|
| 34 |
+
"metadata": {},
|
| 35 |
+
"outputs": [],
|
| 36 |
+
"source": [
|
| 37 |
+
"# Define Namespace\n",
|
| 38 |
+
"ns = Namespace(\"http://www.example.org/DrugInteraction.owl#\")"
|
| 39 |
+
]
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"cell_type": "code",
|
| 43 |
+
"execution_count": 3,
|
| 44 |
+
"metadata": {},
|
| 45 |
+
"outputs": [],
|
| 46 |
+
"source": [
|
| 47 |
+
"# Query 1: Retrieve Drug Interactions\n",
|
| 48 |
+
"query_interactions = \"\"\"\n",
|
| 49 |
+
"PREFIX ns: <http://www.example.org/DrugInteraction.owl#>\n",
|
| 50 |
+
"SELECT ?interaction ?drug1 ?drug2\n",
|
| 51 |
+
"WHERE {\n",
|
| 52 |
+
" ?interaction a ns:Interaction .\n",
|
| 53 |
+
" ?interaction ns:causedBy ?drug1 .\n",
|
| 54 |
+
" ?interaction ns:causedBy ?drug2 .\n",
|
| 55 |
+
" FILTER (?drug1 != ?drug2)\n",
|
| 56 |
+
"}\n",
|
| 57 |
+
"\"\"\""
|
| 58 |
+
]
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"cell_type": "code",
|
| 62 |
+
"execution_count": 4,
|
| 63 |
+
"metadata": {},
|
| 64 |
+
"outputs": [],
|
| 65 |
+
"source": [
|
| 66 |
+
"# Query 2: Retrieve Conflicts\n",
|
| 67 |
+
"query_conflicts = \"\"\"\n",
|
| 68 |
+
"PREFIX ns: <http://www.example.org/DrugInteraction.owl#>\n",
|
| 69 |
+
"SELECT ?conflict ?drug1 ?drug2\n",
|
| 70 |
+
"WHERE {\n",
|
| 71 |
+
" ?conflict a ns:Conflict .\n",
|
| 72 |
+
" ?conflict ns:between ?drug1 .\n",
|
| 73 |
+
" ?conflict ns:between ?drug2 .\n",
|
| 74 |
+
" FILTER (?drug1 != ?drug2)\n",
|
| 75 |
+
"}\n",
|
| 76 |
+
"\"\"\"\n",
|
| 77 |
+
"\n",
|
| 78 |
+
"# Query 3: Retrieve Similarities\n",
|
| 79 |
+
"query_similarities = \"\"\"\n",
|
| 80 |
+
"PREFIX ns: <http://www.example.org/DrugInteraction.owl#>\n",
|
| 81 |
+
"SELECT ?similarity ?drug1 ?drug2\n",
|
| 82 |
+
"WHERE {\n",
|
| 83 |
+
" ?similarity a ns:Similarity .\n",
|
| 84 |
+
" ?similarity ns:relatedTo ?drug1 .\n",
|
| 85 |
+
" ?similarity ns:relatedTo ?drug2 .\n",
|
| 86 |
+
" FILTER (?drug1 != ?drug2)\n",
|
| 87 |
+
"}\n",
|
| 88 |
+
"\"\"\""
|
| 89 |
+
]
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"cell_type": "code",
|
| 93 |
+
"execution_count": 5,
|
| 94 |
+
"metadata": {},
|
| 95 |
+
"outputs": [],
|
| 96 |
+
"source": [
|
| 97 |
+
"# Function to run and print SPARQL query results\n",
|
| 98 |
+
"def run_query(query, description):\n",
|
| 99 |
+
" print(f\"Results for {description}:\")\n",
|
| 100 |
+
" results = g.query(query)\n",
|
| 101 |
+
" for row in results:\n",
|
| 102 |
+
" print(f\"{row[0]} | Drug 1: {row[1].split('#')[-1]} | Drug 2: {row[2].split('#')[-1]}\")\n",
|
| 103 |
+
" print(\"\\n\")\n"
|
| 104 |
+
]
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"cell_type": "code",
|
| 108 |
+
"execution_count": 6,
|
| 109 |
+
"metadata": {},
|
| 110 |
+
"outputs": [
|
| 111 |
+
{
|
| 112 |
+
"name": "stdout",
|
| 113 |
+
"output_type": "stream",
|
| 114 |
+
"text": [
|
| 115 |
+
"Results for Drug Interactions:\n",
|
| 116 |
+
"http://www.example.org/DrugInteraction.owl#Interaction1 | Drug 1: Warfarin | Drug 2: Aspirin\n",
|
| 117 |
+
"http://www.example.org/DrugInteraction.owl#Interaction1 | Drug 1: Aspirin | Drug 2: Warfarin\n",
|
| 118 |
+
"\n",
|
| 119 |
+
"\n",
|
| 120 |
+
"Results for Conflicts:\n",
|
| 121 |
+
"http://www.example.org/DrugInteraction.owl#Conflict1 | Drug 1: Sildenafil | Drug 2: Nitroglycerin\n",
|
| 122 |
+
"http://www.example.org/DrugInteraction.owl#Conflict1 | Drug 1: Nitroglycerin | Drug 2: Sildenafil\n",
|
| 123 |
+
"\n",
|
| 124 |
+
"\n",
|
| 125 |
+
"Results for Similarities:\n",
|
| 126 |
+
"http://www.example.org/DrugInteraction.owl#Similarity1 | Drug 1: Warfarin | Drug 2: Aspirin\n",
|
| 127 |
+
"http://www.example.org/DrugInteraction.owl#Similarity1 | Drug 1: Aspirin | Drug 2: Warfarin\n",
|
| 128 |
+
"\n",
|
| 129 |
+
"\n"
|
| 130 |
+
]
|
| 131 |
+
}
|
| 132 |
+
],
|
| 133 |
+
"source": [
|
| 134 |
+
"# Execute each query\n",
|
| 135 |
+
"run_query(query_interactions, \"Drug Interactions\")\n",
|
| 136 |
+
"run_query(query_conflicts, \"Conflicts\")\n",
|
| 137 |
+
"run_query(query_similarities, \"Similarities\")"
|
| 138 |
+
]
|
| 139 |
+
},
|
| 140 |
+
{
|
| 141 |
+
"cell_type": "code",
|
| 142 |
+
"execution_count": null,
|
| 143 |
+
"metadata": {},
|
| 144 |
+
"outputs": [],
|
| 145 |
+
"source": []
|
| 146 |
+
}
|
| 147 |
+
],
|
| 148 |
+
"metadata": {
|
| 149 |
+
"kernelspec": {
|
| 150 |
+
"display_name": "Python 3",
|
| 151 |
+
"language": "python",
|
| 152 |
+
"name": "python3"
|
| 153 |
+
},
|
| 154 |
+
"language_info": {
|
| 155 |
+
"codemirror_mode": {
|
| 156 |
+
"name": "ipython",
|
| 157 |
+
"version": 3
|
| 158 |
+
},
|
| 159 |
+
"file_extension": ".py",
|
| 160 |
+
"mimetype": "text/x-python",
|
| 161 |
+
"name": "python",
|
| 162 |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 3,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [],
|
| 8 |
+
"source": [
|
| 9 |
+
"# Install owlready2 if not installed\n",
|
| 10 |
+
"# !pip install owlready2\n",
|
| 11 |
+
"\n",
|
| 12 |
+
"# Import libraries\n",
|
| 13 |
+
"from owlready2 import *"
|
| 14 |
+
]
|
| 15 |
+
},
|
| 16 |
+
{
|
| 17 |
+
"cell_type": "code",
|
| 18 |
+
"execution_count": 4,
|
| 19 |
+
"metadata": {},
|
| 20 |
+
"outputs": [
|
| 21 |
+
{
|
| 22 |
+
"name": "stdout",
|
| 23 |
+
"output_type": "stream",
|
| 24 |
+
"text": [
|
| 25 |
+
"Loading ontology...\n",
|
| 26 |
+
"Ontology loaded successfully.\n",
|
| 27 |
+
"\n"
|
| 28 |
+
]
|
| 29 |
+
}
|
| 30 |
+
],
|
| 31 |
+
"source": [
|
| 32 |
+
"# Step 1: Load the Ontology\n",
|
| 33 |
+
"print(\"Loading ontology...\")\n",
|
| 34 |
+
"onto = get_ontology(\"DrugInteraction.owl\").load()\n",
|
| 35 |
+
"print(\"Ontology loaded successfully.\\n\")"
|
| 36 |
+
]
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"cell_type": "code",
|
| 40 |
+
"execution_count": 5,
|
| 41 |
+
"metadata": {},
|
| 42 |
+
"outputs": [
|
| 43 |
+
{
|
| 44 |
+
"name": "stdout",
|
| 45 |
+
"output_type": "stream",
|
| 46 |
+
"text": [
|
| 47 |
+
"Classes in the ontology:\n",
|
| 48 |
+
"DrugInteraction.TestProgram\n",
|
| 49 |
+
"DrugInteraction.Drug\n",
|
| 50 |
+
"DrugInteraction.Interaction\n",
|
| 51 |
+
"DrugInteraction.Conflict\n",
|
| 52 |
+
"DrugInteraction.Similarity\n",
|
| 53 |
+
"\n",
|
| 54 |
+
"Object Properties in the ontology:\n",
|
| 55 |
+
"DrugInteraction.causedBy\n",
|
| 56 |
+
"DrugInteraction.between\n",
|
| 57 |
+
"DrugInteraction.relatedTo\n",
|
| 58 |
+
"\n",
|
| 59 |
+
"Instances of classes:\n",
|
| 60 |
+
"DrugInteraction.Warfarin is an instance of DrugInteraction.Drug\n",
|
| 61 |
+
"DrugInteraction.Aspirin is an instance of DrugInteraction.Drug\n",
|
| 62 |
+
"DrugInteraction.Nitroglycerin is an instance of DrugInteraction.Drug\n",
|
| 63 |
+
"DrugInteraction.Sildenafil is an instance of DrugInteraction.Drug\n",
|
| 64 |
+
"DrugInteraction.Interaction1 is an instance of DrugInteraction.Interaction\n",
|
| 65 |
+
"DrugInteraction.Conflict1 is an instance of DrugInteraction.Conflict\n",
|
| 66 |
+
"DrugInteraction.Similarity1 is an instance of DrugInteraction.Similarity\n"
|
| 67 |
+
]
|
| 68 |
+
}
|
| 69 |
+
],
|
| 70 |
+
"source": [
|
| 71 |
+
"# Step 2: Explore Ontology Structure\n",
|
| 72 |
+
"print(\"Classes in the ontology:\")\n",
|
| 73 |
+
"for cls in onto.classes():\n",
|
| 74 |
+
" print(cls)\n",
|
| 75 |
+
"\n",
|
| 76 |
+
"print(\"\\nObject Properties in the ontology:\")\n",
|
| 77 |
+
"for prop in onto.object_properties():\n",
|
| 78 |
+
" print(prop)\n",
|
| 79 |
+
"\n",
|
| 80 |
+
"print(\"\\nInstances of classes:\")\n",
|
| 81 |
+
"for ind in onto.individuals():\n",
|
| 82 |
+
" print(f\"{ind} is an instance of {ind.is_a[0]}\")"
|
| 83 |
+
]
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"cell_type": "code",
|
| 87 |
+
"execution_count": 6,
|
| 88 |
+
"metadata": {},
|
| 89 |
+
"outputs": [
|
| 90 |
+
{
|
| 91 |
+
"name": "stdout",
|
| 92 |
+
"output_type": "stream",
|
| 93 |
+
"text": [
|
| 94 |
+
"\n",
|
| 95 |
+
"Querying Drug Interactions:\n",
|
| 96 |
+
"Interaction: Interaction1, Caused By: Warfarin, Aspirin\n"
|
| 97 |
+
]
|
| 98 |
+
}
|
| 99 |
+
],
|
| 100 |
+
"source": [
|
| 101 |
+
"# Step 3: Query Relationships\n",
|
| 102 |
+
"print(\"\\nQuerying Drug Interactions:\")\n",
|
| 103 |
+
"interaction_class = onto.search_one(iri=\"*Interaction\")\n",
|
| 104 |
+
"for interaction in interaction_class.instances():\n",
|
| 105 |
+
" caused_by_drugs = [drug.name for drug in interaction.causedBy]\n",
|
| 106 |
+
" print(f\"Interaction: {interaction.name}, Caused By: {', '.join(caused_by_drugs)}\")\n",
|
| 107 |
+
" \n"
|
| 108 |
+
]
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"cell_type": "code",
|
| 112 |
+
"execution_count": 7,
|
| 113 |
+
"metadata": {},
|
| 114 |
+
"outputs": [
|
| 115 |
+
{
|
| 116 |
+
"name": "stdout",
|
| 117 |
+
"output_type": "stream",
|
| 118 |
+
"text": [
|
| 119 |
+
"\n",
|
| 120 |
+
"Querying Conflicts:\n",
|
| 121 |
+
"Conflict: Conflict1, Between: [DrugInteraction.Sildenafil, DrugInteraction.Nitroglycerin]\n",
|
| 122 |
+
"Drug: DrugInteraction.Sildenafil\n",
|
| 123 |
+
"Drug: DrugInteraction.Nitroglycerin\n",
|
| 124 |
+
"Conflict: Conflict1, Involves Drugs: Sildenafil, Nitroglycerin\n"
|
| 125 |
+
]
|
| 126 |
+
}
|
| 127 |
+
],
|
| 128 |
+
"source": [
|
| 129 |
+
"print(\"\\nQuerying Conflicts:\") \n",
|
| 130 |
+
"conflict_class = onto.search_one(iri=\"*Conflict\") \n",
|
| 131 |
+
"for conflict in conflict_class.instances(): \n",
|
| 132 |
+
"\tprint(f\"Conflict: {conflict.name}, Between: {conflict.between}\") \n",
|
| 133 |
+
"\tinvolved_drugs = [] \n",
|
| 134 |
+
"\tfor drug in conflict.between: \n",
|
| 135 |
+
"\t\tprint(f\"Drug: {drug}\") # Print the drug to see its structure \n",
|
| 136 |
+
"\t\ttry: \n",
|
| 137 |
+
"\t\t\tinvolved_drugs.append(drug.name) \n",
|
| 138 |
+
"\t\texcept AttributeError: \n",
|
| 139 |
+
"\t\t\tprint(f\"Error: 'str' object has no attribute 'name'. Drug: {drug}\") \t\t\n",
|
| 140 |
+
"print(f\"Conflict: {conflict.name}, Involves Drugs: {', '.join(involved_drugs)}\")\n"
|
| 141 |
+
]
|
| 142 |
+
},
|
| 143 |
+
{
|
| 144 |
+
"cell_type": "code",
|
| 145 |
+
"execution_count": 8,
|
| 146 |
+
"metadata": {},
|
| 147 |
+
"outputs": [
|
| 148 |
+
{
|
| 149 |
+
"name": "stdout",
|
| 150 |
+
"output_type": "stream",
|
| 151 |
+
"text": [
|
| 152 |
+
"\n",
|
| 153 |
+
"Querying Similarities:\n",
|
| 154 |
+
"Similarity: Similarity1, Related Drugs: Warfarin, Aspirin\n"
|
| 155 |
+
]
|
| 156 |
+
}
|
| 157 |
+
],
|
| 158 |
+
"source": [
|
| 159 |
+
"# Querying Similarities with error handling\n",
|
| 160 |
+
"print(\"\\nQuerying Similarities:\")\n",
|
| 161 |
+
"similarity_class = onto.search_one(iri=\"*Similarity\")\n",
|
| 162 |
+
"\n",
|
| 163 |
+
"if similarity_class: # Ensure the class exists\n",
|
| 164 |
+
" for similarity in similarity_class.instances():\n",
|
| 165 |
+
" # Safely handle 'relatedTo' to avoid AttributeError\n",
|
| 166 |
+
" related_drugs = [\n",
|
| 167 |
+
" drug.name if isinstance(drug, Thing) else str(drug) \n",
|
| 168 |
+
" for drug in getattr(similarity, \"relatedTo\", [])\n",
|
| 169 |
+
" ]\n",
|
| 170 |
+
" print(f\"Similarity: {similarity.name}, Related Drugs: {', '.join(related_drugs)}\")\n",
|
| 171 |
+
"else:\n",
|
| 172 |
+
" print(\"Similarity class not found in the ontology.\")\n"
|
| 173 |
+
]
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"cell_type": "code",
|
| 177 |
+
"execution_count": 9,
|
| 178 |
+
"metadata": {},
|
| 179 |
+
"outputs": [
|
| 180 |
+
{
|
| 181 |
+
"name": "stderr",
|
| 182 |
+
"output_type": "stream",
|
| 183 |
+
"text": [
|
| 184 |
+
"* Owlready2 * Running HermiT...\n",
|
| 185 |
+
" java -Xmx2000M -cp /home/manith/.local/lib/python3.12/site-packages/owlready2/hermit:/home/manith/.local/lib/python3.12/site-packages/owlready2/hermit/HermiT.jar org.semanticweb.HermiT.cli.CommandLine -c -O -D -I file:////tmp/tmps4u6q73_\n"
|
| 186 |
+
]
|
| 187 |
+
},
|
| 188 |
+
{
|
| 189 |
+
"name": "stdout",
|
| 190 |
+
"output_type": "stream",
|
| 191 |
+
"text": [
|
| 192 |
+
"\n",
|
| 193 |
+
"Reasoning complete. Checking inferred facts...\n"
|
| 194 |
+
]
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"name": "stderr",
|
| 198 |
+
"output_type": "stream",
|
| 199 |
+
"text": [
|
| 200 |
+
"* Owlready2 * HermiT took 0.49095606803894043 seconds\n",
|
| 201 |
+
"* Owlready * (NB: only changes on entities loaded in Python are shown, other changes are done but not listed)\n"
|
| 202 |
+
]
|
| 203 |
+
}
|
| 204 |
+
],
|
| 205 |
+
"source": [
|
| 206 |
+
"# Step 4: Test Reasoning\n",
|
| 207 |
+
"# Add reasoning to infer new facts based on ontology\n",
|
| 208 |
+
"with onto:\n",
|
| 209 |
+
" sync_reasoner() # Runs the HermiT reasoner\n",
|
| 210 |
+
"print(\"\\nReasoning complete. Checking inferred facts...\")"
|
| 211 |
+
]
|
| 212 |
+
},
|
| 213 |
+
{
|
| 214 |
+
"cell_type": "code",
|
| 215 |
+
"execution_count": 10,
|
| 216 |
+
"metadata": {},
|
| 217 |
+
"outputs": [
|
| 218 |
+
{
|
| 219 |
+
"name": "stdout",
|
| 220 |
+
"output_type": "stream",
|
| 221 |
+
"text": [
|
| 222 |
+
"\n",
|
| 223 |
+
"Inferred Relationships for Interactions:\n",
|
| 224 |
+
"Interaction: Interaction1, Caused By: Warfarin, Aspirin\n"
|
| 225 |
+
]
|
| 226 |
+
}
|
| 227 |
+
],
|
| 228 |
+
"source": [
|
| 229 |
+
"# Re-query after reasoning\n",
|
| 230 |
+
"print(\"\\nInferred Relationships for Interactions:\")\n",
|
| 231 |
+
"for interaction in interaction_class.instances():\n",
|
| 232 |
+
" caused_by_drugs = [drug.name for drug in interaction.causedBy]\n",
|
| 233 |
+
" print(f\"Interaction: {interaction.name}, Caused By: {', '.join(caused_by_drugs)}\")"
|
| 234 |
+
]
|
| 235 |
+
},
|
| 236 |
+
{
|
| 237 |
+
"cell_type": "code",
|
| 238 |
+
"execution_count": 11,
|
| 239 |
+
"metadata": {},
|
| 240 |
+
"outputs": [
|
| 241 |
+
{
|
| 242 |
+
"name": "stdout",
|
| 243 |
+
"output_type": "stream",
|
| 244 |
+
"text": [
|
| 245 |
+
"\n",
|
| 246 |
+
"Custom Query: Find interactions involving 'Warfarin'\n",
|
| 247 |
+
"Interaction Found: Interaction1 caused by Warfarin\n"
|
| 248 |
+
]
|
| 249 |
+
}
|
| 250 |
+
],
|
| 251 |
+
"source": [
|
| 252 |
+
"# Step 5: Custom Queries and Testing\n",
|
| 253 |
+
"print(\"\\nCustom Query: Find interactions involving 'Warfarin'\")\n",
|
| 254 |
+
"warfarin = onto.search_one(iri=\"*Warfarin\")\n",
|
| 255 |
+
"for interaction in interaction_class.instances():\n",
|
| 256 |
+
" if warfarin in interaction.causedBy:\n",
|
| 257 |
+
" print(f\"Interaction Found: {interaction.name} caused by Warfarin\")"
|
| 258 |
+
]
|
| 259 |
+
},
|
| 260 |
+
{
|
| 261 |
+
"cell_type": "code",
|
| 262 |
+
"execution_count": 12,
|
| 263 |
+
"metadata": {},
|
| 264 |
+
"outputs": [
|
| 265 |
+
{
|
| 266 |
+
"name": "stdout",
|
| 267 |
+
"output_type": "stream",
|
| 268 |
+
"text": [
|
| 269 |
+
"\n",
|
| 270 |
+
"Custom Query: Find conflicts involving 'Nitroglycerin'\n",
|
| 271 |
+
"Conflict Found: Conflict1 involving Nitroglycerin\n"
|
| 272 |
+
]
|
| 273 |
+
}
|
| 274 |
+
],
|
| 275 |
+
"source": [
|
| 276 |
+
"print(\"\\nCustom Query: Find conflicts involving 'Nitroglycerin'\")\n",
|
| 277 |
+
"\n",
|
| 278 |
+
"# Dynamically find the Nitroglycerin individual\n",
|
| 279 |
+
"nitroglycerin = onto.search_one(iri=\"*Nitroglycerin\")\n",
|
| 280 |
+
"\n",
|
| 281 |
+
"if nitroglycerin:\n",
|
| 282 |
+
" # Query Conflicts and check 'between' property\n",
|
| 283 |
+
" for conflict in conflict_class.instances():\n",
|
| 284 |
+
" involved_drugs = getattr(conflict, \"between\", [])\n",
|
| 285 |
+
" if nitroglycerin in involved_drugs:\n",
|
| 286 |
+
" print(f\"Conflict Found: {conflict.name} involving Nitroglycerin\")\n",
|
| 287 |
+
"else:\n",
|
| 288 |
+
" print(\"Nitroglycerin not found in the ontology.\")\n"
|
| 289 |
+
]
|
| 290 |
+
},
|
| 291 |
+
{
|
| 292 |
+
"cell_type": "code",
|
| 293 |
+
"execution_count": null,
|
| 294 |
+
"metadata": {},
|
| 295 |
+
"outputs": [],
|
| 296 |
+
"source": []
|
| 297 |
+
}
|
| 298 |
+
],
|
| 299 |
+
"metadata": {
|
| 300 |
+
"kernelspec": {
|
| 301 |
+
"display_name": "Python 3",
|
| 302 |
+
"language": "python",
|
| 303 |
+
"name": "python3"
|
| 304 |
+
},
|
| 305 |
+
"language_info": {
|
| 306 |
+
"codemirror_mode": {
|
| 307 |
+
"name": "ipython",
|
| 308 |
+
"version": 3
|
| 309 |
+
},
|
| 310 |
+
"file_extension": ".py",
|
| 311 |
+
"mimetype": "text/x-python",
|
| 312 |
+
"name": "python",
|
| 313 |
+
"nbconvert_exporter": "python",
|
| 314 |
+
"pygments_lexer": "ipython3",
|
| 315 |
+
"version": "3.12.3"
|
| 316 |
+
}
|
| 317 |
+
},
|
| 318 |
+
"nbformat": 4,
|
| 319 |
+
"nbformat_minor": 2
|
| 320 |
+
}
|
agents/__init__.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .alternative_agent import AlternativeAgent
|
| 2 |
+
from .similarity_agent import SimilarityAgent
|
| 3 |
+
from .conflict_agent import ConflictAgent
|
| 4 |
+
from .interaction_agent import InteractionAgent
|
agents/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (386 Bytes). View file
|
|
|
agents/__pycache__/alternative_agent.cpython-312.pyc
ADDED
|
Binary file (1.78 kB). View file
|
|
|
agents/__pycache__/base_agent.cpython-312.pyc
ADDED
|
Binary file (1.83 kB). View file
|
|
|
agents/__pycache__/conflict_agent.cpython-312.pyc
ADDED
|
Binary file (1.75 kB). View file
|
|
|
agents/__pycache__/interaction_agent.cpython-312.pyc
ADDED
|
Binary file (1.78 kB). View file
|
|
|
agents/__pycache__/similarity_agent.cpython-312.pyc
ADDED
|
Binary file (1.77 kB). View file
|
|
|
agents/alternative_agent.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .base_agent import BaseAgent
|
| 2 |
+
from rdflib import Graph, Namespace
|
| 3 |
+
from typing import List, Dict
|
| 4 |
+
import logging
|
| 5 |
+
|
| 6 |
+
class AlternativeAgent(BaseAgent):
|
| 7 |
+
def __init__(self, rdf_graph: Graph, namespace: Namespace):
|
| 8 |
+
super().__init__(rdf_graph, namespace)
|
| 9 |
+
self.query_template = """
|
| 10 |
+
PREFIX ns: <http://www.example.org/DrugInteraction.owl#>
|
| 11 |
+
SELECT DISTINCT ?drug1 ?drug2
|
| 12 |
+
WHERE {{
|
| 13 |
+
?drug1 ns:hasAlternative ?drug2 .
|
| 14 |
+
FILTER(STRENDS(str(?drug1), "#{drug}") || STRENDS(str(?drug2), "#{drug}"))
|
| 15 |
+
}}
|
| 16 |
+
"""
|
| 17 |
+
logging.debug("AlternativeAgent initialized.")
|
| 18 |
+
|
| 19 |
+
def get_alternatives(self, drug_name: str) -> List[Dict[str, str]]:
|
| 20 |
+
query = self.query_template.format(drug=drug_name)
|
| 21 |
+
logging.info(f"Fetching alternatives for {drug_name}")
|
| 22 |
+
return self.query_ontology(query)
|
agents/base_agent.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from rdflib import Graph, Namespace, URIRef
|
| 2 |
+
from typing import List, Dict
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
class BaseAgent:
|
| 6 |
+
def __init__(self, rdf_graph: Graph, namespace: Namespace):
|
| 7 |
+
self.graph = rdf_graph
|
| 8 |
+
self.ns = namespace
|
| 9 |
+
logging.debug("BaseAgent initialized.")
|
| 10 |
+
|
| 11 |
+
def query_ontology(self, query: str) -> List[Dict[str, str]]:
|
| 12 |
+
"""Execute a SPARQL query and return results as a list of dictionaries."""
|
| 13 |
+
try:
|
| 14 |
+
results = self.graph.query(query)
|
| 15 |
+
logging.debug(f"Executing query: {query}")
|
| 16 |
+
return [
|
| 17 |
+
{"drug1": str(row[0]).split('#')[-1],
|
| 18 |
+
"drug2": str(row[1]).split('#')[-1]}
|
| 19 |
+
for row in results
|
| 20 |
+
]
|
| 21 |
+
except Exception as e:
|
| 22 |
+
logging.error(f"Error executing query: {e}")
|
| 23 |
+
return []
|
agents/conflict_agent.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .base_agent import BaseAgent
|
| 2 |
+
from rdflib import Graph, Namespace
|
| 3 |
+
from typing import List, Dict
|
| 4 |
+
import logging
|
| 5 |
+
|
| 6 |
+
class ConflictAgent(BaseAgent):
|
| 7 |
+
def __init__(self, rdf_graph: Graph, namespace: Namespace):
|
| 8 |
+
super().__init__(rdf_graph, namespace)
|
| 9 |
+
self.query_template = """
|
| 10 |
+
PREFIX ns: <http://www.example.org/DrugInteraction.owl#>
|
| 11 |
+
SELECT DISTINCT ?drug1 ?drug2
|
| 12 |
+
WHERE {{
|
| 13 |
+
?drug1 ns:hasConflict ?drug2 .
|
| 14 |
+
FILTER(STRENDS(str(?drug1), "#{drug}") || STRENDS(str(?drug2), "#{drug}"))
|
| 15 |
+
}}
|
| 16 |
+
"""
|
| 17 |
+
logging.debug("ConflictAgent initialized.")
|
| 18 |
+
|
| 19 |
+
def get_conflicts(self, drug_name: str) -> List[Dict[str, str]]:
|
| 20 |
+
query = self.query_template.format(drug=drug_name)
|
| 21 |
+
logging.info(f"Fetching conflicts for {drug_name}")
|
| 22 |
+
return self.query_ontology(query)
|
agents/interaction_agent.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .base_agent import BaseAgent
|
| 2 |
+
from rdflib import Graph, Namespace
|
| 3 |
+
from typing import List, Dict
|
| 4 |
+
import logging
|
| 5 |
+
|
| 6 |
+
class InteractionAgent(BaseAgent):
|
| 7 |
+
def __init__(self, rdf_graph: Graph, namespace: Namespace):
|
| 8 |
+
super().__init__(rdf_graph, namespace)
|
| 9 |
+
self.query_template = """
|
| 10 |
+
PREFIX ns: <http://www.example.org/DrugInteraction.owl#>
|
| 11 |
+
SELECT DISTINCT ?drug1 ?drug2
|
| 12 |
+
WHERE {{
|
| 13 |
+
?drug1 ns:hasInteraction ?drug2 .
|
| 14 |
+
FILTER(STRENDS(str(?drug1), "#{drug}") || STRENDS(str(?drug2), "#{drug}"))
|
| 15 |
+
}}
|
| 16 |
+
"""
|
| 17 |
+
logging.debug("InteractionAgent initialized.")
|
| 18 |
+
|
| 19 |
+
def get_interactions(self, drug_name: str) -> List[Dict[str, str]]:
|
| 20 |
+
query = self.query_template.format(drug=drug_name)
|
| 21 |
+
logging.info(f"Fetching interactions for {drug_name}")
|
| 22 |
+
return self.query_ontology(query)
|
agents/similarity_agent.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .base_agent import BaseAgent
|
| 2 |
+
from rdflib import Graph, Namespace
|
| 3 |
+
from typing import List, Dict
|
| 4 |
+
import logging
|
| 5 |
+
|
| 6 |
+
class SimilarityAgent(BaseAgent):
|
| 7 |
+
def __init__(self, rdf_graph: Graph, namespace: Namespace):
|
| 8 |
+
super().__init__(rdf_graph, namespace)
|
| 9 |
+
self.query_template = """
|
| 10 |
+
PREFIX ns: <http://www.example.org/DrugInteraction.owl#>
|
| 11 |
+
SELECT DISTINCT ?drug1 ?drug2
|
| 12 |
+
WHERE {{
|
| 13 |
+
?drug1 ns:hasSimilarity ?drug2 .
|
| 14 |
+
FILTER(STRENDS(str(?drug1), "#{drug}") || STRENDS(str(?drug2), "#{drug}"))
|
| 15 |
+
}}
|
| 16 |
+
"""
|
| 17 |
+
logging.debug("SimilarityAgent initialized.")
|
| 18 |
+
|
| 19 |
+
def get_similarities(self, drug_name: str) -> List[Dict[str, str]]:
|
| 20 |
+
query = self.query_template.format(drug=drug_name)
|
| 21 |
+
logging.info(f"Fetching similarities for {drug_name}")
|
| 22 |
+
return self.query_ontology(query)
|
analyzers/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from .drug_interaction_analyzer import DrugInteractionAnalyzer
|
analyzers/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (235 Bytes). View file
|
|
|
analyzers/__pycache__/drug_interaction_analyzer.cpython-312.pyc
ADDED
|
Binary file (5.22 kB). View file
|
|
|
analyzers/drug_interaction_analyzer.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Dict, List
|
| 2 |
+
import json
|
| 3 |
+
from agents import AlternativeAgent, SimilarityAgent, ConflictAgent, InteractionAgent
|
| 4 |
+
from rdflib import Graph, Namespace
|
| 5 |
+
import logging
|
| 6 |
+
|
| 7 |
+
class DrugInteractionAnalyzer:
|
| 8 |
+
"""
|
| 9 |
+
Analyzer class to handle drug interactions, alternatives, similarities, and conflicts using separate agents.
|
| 10 |
+
"""
|
| 11 |
+
def __init__(self, owl_file_path: str):
|
| 12 |
+
"""
|
| 13 |
+
Initialize the DrugInteractionAnalyzer with the ontology file and instantiate agents.
|
| 14 |
+
|
| 15 |
+
Args:
|
| 16 |
+
owl_file_path (str): Path to the RDF/XML ontology file.
|
| 17 |
+
"""
|
| 18 |
+
self.graph = Graph()
|
| 19 |
+
try:
|
| 20 |
+
self.graph.parse(owl_file_path, format="xml")
|
| 21 |
+
self.namespace = Namespace("http://www.example.org/DrugInteraction.owl#")
|
| 22 |
+
logging.info(f"Successfully loaded ontology from {owl_file_path}")
|
| 23 |
+
except Exception as e:
|
| 24 |
+
logging.error(f"Failed to load ontology file: {e}")
|
| 25 |
+
raise ValueError(f"Failed to load ontology file: {e}")
|
| 26 |
+
|
| 27 |
+
# Initialize agents
|
| 28 |
+
self.alternative_agent = AlternativeAgent(self.graph, self.namespace)
|
| 29 |
+
self.similarity_agent = SimilarityAgent(self.graph, self.namespace)
|
| 30 |
+
self.conflict_agent = ConflictAgent(self.graph, self.namespace)
|
| 31 |
+
self.interaction_agent = InteractionAgent(self.graph, self.namespace)
|
| 32 |
+
logging.info("Initialized all agents successfully.")
|
| 33 |
+
|
| 34 |
+
def analyze_drugs(self, drug_names: List[str]) -> Dict[str, Dict[str, List[Dict[str, str]]]]:
|
| 35 |
+
"""
|
| 36 |
+
Analyze multiple drugs using separate agents and return structured results.
|
| 37 |
+
|
| 38 |
+
Args:
|
| 39 |
+
drug_names (List[str]): List of drug names to analyze.
|
| 40 |
+
|
| 41 |
+
Returns:
|
| 42 |
+
Dict[str, Dict[str, List[Dict[str, str]]]]: Structured analysis results.
|
| 43 |
+
"""
|
| 44 |
+
results = {}
|
| 45 |
+
for drug in drug_names:
|
| 46 |
+
drug_results = {}
|
| 47 |
+
logging.info(f"Analyzing drug: {drug}")
|
| 48 |
+
|
| 49 |
+
# Alternatives
|
| 50 |
+
try:
|
| 51 |
+
alternatives = self.alternative_agent.get_alternatives(drug)
|
| 52 |
+
drug_results["alternatives"] = alternatives
|
| 53 |
+
logging.debug(f"Alternatives for {drug}: {alternatives}")
|
| 54 |
+
except Exception as e:
|
| 55 |
+
logging.warning(f"Failed to get alternatives for {drug}: {e}")
|
| 56 |
+
drug_results["alternatives"] = []
|
| 57 |
+
|
| 58 |
+
# Similarities
|
| 59 |
+
try:
|
| 60 |
+
similarities = self.similarity_agent.get_similarities(drug)
|
| 61 |
+
drug_results["similarities"] = similarities
|
| 62 |
+
logging.debug(f"Similarities for {drug}: {similarities}")
|
| 63 |
+
except Exception as e:
|
| 64 |
+
logging.warning(f"Failed to get similarities for {drug}: {e}")
|
| 65 |
+
drug_results["similarities"] = []
|
| 66 |
+
|
| 67 |
+
# Conflicts
|
| 68 |
+
try:
|
| 69 |
+
conflicts = self.conflict_agent.get_conflicts(drug)
|
| 70 |
+
drug_results["conflicts"] = conflicts
|
| 71 |
+
logging.debug(f"Conflicts for {drug}: {conflicts}")
|
| 72 |
+
except Exception as e:
|
| 73 |
+
logging.warning(f"Failed to get conflicts for {drug}: {e}")
|
| 74 |
+
drug_results["conflicts"] = []
|
| 75 |
+
|
| 76 |
+
# Interactions
|
| 77 |
+
try:
|
| 78 |
+
interactions = self.interaction_agent.get_interactions(drug)
|
| 79 |
+
drug_results["interactions"] = interactions
|
| 80 |
+
logging.debug(f"Interactions for {drug}: {interactions}")
|
| 81 |
+
except Exception as e:
|
| 82 |
+
logging.warning(f"Failed to get interactions for {drug}: {e}")
|
| 83 |
+
drug_results["interactions"] = []
|
| 84 |
+
|
| 85 |
+
results[drug] = drug_results
|
| 86 |
+
logging.info(f"Completed analysis for {drug}")
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from rdflib import Graph, Namespace, URIRef, Literal
|
| 3 |
+
from typing import Dict, List, Optional
|
| 4 |
+
from langgraph.graph import StateGraph
|
| 5 |
+
from langchain.prompts import ChatPromptTemplate
|
| 6 |
+
import json
|
| 7 |
+
from dotenv import load_dotenv
|
| 8 |
+
import os
|
| 9 |
+
from dataclasses import dataclass
|
| 10 |
+
from langchain_community.chat_models import ChatOllama
|
| 11 |
+
from langchain_groq import ChatGroq
|
| 12 |
+
import logging
|
| 13 |
+
from analyzers import DrugInteractionAnalyzer
|
| 14 |
+
import base64
|
| 15 |
+
|
| 16 |
+
# Load environment variables
|
| 17 |
+
load_dotenv()
|
| 18 |
+
|
| 19 |
+
# Configure logging
|
| 20 |
+
logging.basicConfig(
|
| 21 |
+
level=logging.INFO,
|
| 22 |
+
format='%(asctime)s [%(levelname)s] %(message)s',
|
| 23 |
+
handlers=[
|
| 24 |
+
logging.FileHandler("app.log"),
|
| 25 |
+
logging.StreamHandler()
|
| 26 |
+
]
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
# Validating API key
|
| 30 |
+
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 31 |
+
if not GROQ_API_KEY:
|
| 32 |
+
logging.error("GROQ_API_KEY not found in environment variables. Please add it to your .env file.")
|
| 33 |
+
raise ValueError("GROQ_API_KEY not found in environment variables. Please add it to your .env file.")
|
| 34 |
+
|
| 35 |
+
@dataclass
|
| 36 |
+
class GraphState:
|
| 37 |
+
"""State type for the graph."""
|
| 38 |
+
input: str
|
| 39 |
+
query: Optional[str] = None
|
| 40 |
+
ontology_results: Optional[str] = None
|
| 41 |
+
response: Optional[str] = None
|
| 42 |
+
|
| 43 |
+
class OntologyAgent:
|
| 44 |
+
def __init__(self, owl_file_path: str):
|
| 45 |
+
"""Initialize the OntologyAgent with an OWL file."""
|
| 46 |
+
self.g = Graph()
|
| 47 |
+
try:
|
| 48 |
+
self.g.parse(owl_file_path, format="xml")
|
| 49 |
+
self.ns = Namespace("http://www.example.org/DrugInteraction.owl#")
|
| 50 |
+
logging.info(f"Ontology loaded successfully from {owl_file_path}")
|
| 51 |
+
except Exception as e:
|
| 52 |
+
logging.error(f"Failed to load ontology file: {e}")
|
| 53 |
+
raise ValueError(f"Failed to load ontology file: {e}")
|
| 54 |
+
|
| 55 |
+
def create_agent_graph(owl_file_path: str) -> StateGraph:
|
| 56 |
+
"""Create a processing graph for drug interaction analysis using separate agents."""
|
| 57 |
+
analyzer = DrugInteractionAnalyzer(owl_file_path)
|
| 58 |
+
|
| 59 |
+
def user_input_node(state: GraphState) -> Dict[str, str]:
|
| 60 |
+
logging.info("Processing user input.")
|
| 61 |
+
return {"query": state.input}
|
| 62 |
+
|
| 63 |
+
def ontology_query_node(state: GraphState) -> Dict[str, str]:
|
| 64 |
+
try:
|
| 65 |
+
logging.info("Executing ontology queries.")
|
| 66 |
+
drug_names = [d.strip() for d in state.input.split(",")]
|
| 67 |
+
results = analyzer.analyze_drugs(drug_names)
|
| 68 |
+
logging.info(f"Ontology query results: {results}")
|
| 69 |
+
return {"ontology_results": json.dumps(results, indent=2)}
|
| 70 |
+
except Exception as e:
|
| 71 |
+
logging.warning(f"Ontology query failed: {e}")
|
| 72 |
+
return {"ontology_results": json.dumps({"error": str(e)})}
|
| 73 |
+
|
| 74 |
+
def llm_processing_node(state: GraphState) -> Dict[str, str]:
|
| 75 |
+
template = """
|
| 76 |
+
Based on the drug interaction analysis results:
|
| 77 |
+
{ontology_results}
|
| 78 |
+
|
| 79 |
+
Please provide a comprehensive summary of:
|
| 80 |
+
1. Direct interactions between the drugs
|
| 81 |
+
2. Potential conflicts
|
| 82 |
+
3. Similar drug alternatives
|
| 83 |
+
4. Recommended alternatives if conflicts exist
|
| 84 |
+
|
| 85 |
+
If no results were found, please indicate this clearly.
|
| 86 |
+
Format the response in a clear, structured manner.
|
| 87 |
+
"""
|
| 88 |
+
|
| 89 |
+
prompt = ChatPromptTemplate.from_template(template)
|
| 90 |
+
|
| 91 |
+
try:
|
| 92 |
+
llm = ChatGroq(
|
| 93 |
+
model_name="llama3-groq-70b-8192-tool-use-preview",
|
| 94 |
+
api_key=GROQ_API_KEY,
|
| 95 |
+
temperature=0.7
|
| 96 |
+
)
|
| 97 |
+
logging.info("LLM initialized successfully.")
|
| 98 |
+
except Exception as e:
|
| 99 |
+
logging.error(f"Error initializing LLM: {e}")
|
| 100 |
+
return {"response": f"Error initializing LLM: {str(e)}"}
|
| 101 |
+
|
| 102 |
+
chain = prompt | llm
|
| 103 |
+
|
| 104 |
+
try:
|
| 105 |
+
response = chain.invoke({
|
| 106 |
+
"ontology_results": state.ontology_results
|
| 107 |
+
})
|
| 108 |
+
|
| 109 |
+
logging.info("LLM processing completed successfully.")
|
| 110 |
+
return {"response": response.content}
|
| 111 |
+
except Exception as e:
|
| 112 |
+
logging.error(f"Error processing results with LLM: {e}")
|
| 113 |
+
return {"response": f"Error processing results: {str(e)}"}
|
| 114 |
+
|
| 115 |
+
workflow = StateGraph(GraphState)
|
| 116 |
+
|
| 117 |
+
workflow.add_node("input_processor", user_input_node)
|
| 118 |
+
workflow.add_node("ontology_query", ontology_query_node)
|
| 119 |
+
workflow.add_node("llm_processing", llm_processing_node)
|
| 120 |
+
|
| 121 |
+
workflow.add_edge("input_processor", "ontology_query")
|
| 122 |
+
workflow.add_edge("ontology_query", "llm_processing")
|
| 123 |
+
|
| 124 |
+
workflow.set_entry_point("input_processor")
|
| 125 |
+
|
| 126 |
+
logging.info("Agent graph created and configured successfully.")
|
| 127 |
+
|
| 128 |
+
return workflow.compile()
|
| 129 |
+
|
| 130 |
+
def main():
|
| 131 |
+
st.set_page_config(page_title="OntoGraph", page_icon="💊", layout="wide")
|
| 132 |
+
|
| 133 |
+
st.markdown("<h1 style='text-align: center;'>OntoGraph - Drug Interaction Analysis System</h1>", unsafe_allow_html=True)
|
| 134 |
+
|
| 135 |
+
st.markdown("<h3 style='text-align: center;'>{ 💊 ↔ 💊 = ❓}</h3><br>", unsafe_allow_html=True)
|
| 136 |
+
|
| 137 |
+
st.markdown("<h5 style='text-align: center; color: #8bacad;'>This application uses a combination of ontology-based reasoning and language models to analyze drug interactions.</h5>", unsafe_allow_html=True)
|
| 138 |
+
|
| 139 |
+
st.markdown("""
|
| 140 |
+
<style>
|
| 141 |
+
.centered {
|
| 142 |
+
display: flex;
|
| 143 |
+
flex-direction: column;
|
| 144 |
+
align-items: center;
|
| 145 |
+
justify-content: center;
|
| 146 |
+
text-align: center;
|
| 147 |
+
}
|
| 148 |
+
</style>
|
| 149 |
+
<div class="centered">
|
| 150 |
+
""", unsafe_allow_html=True)
|
| 151 |
+
|
| 152 |
+
def get_base64_image(img_path):
|
| 153 |
+
with open(img_path, "rb") as f:
|
| 154 |
+
encoded = base64.b64encode(f.read()).decode()
|
| 155 |
+
return f"data:image/webp;base64,{encoded}"
|
| 156 |
+
|
| 157 |
+
# Generate the image URL
|
| 158 |
+
image_url = get_base64_image("img/header-image.webp")
|
| 159 |
+
|
| 160 |
+
# Load custom CSS with the embedded image
|
| 161 |
+
st.markdown(f"""
|
| 162 |
+
<style>
|
| 163 |
+
.parallax {{
|
| 164 |
+
background-image: url("{image_url}");
|
| 165 |
+
min-height: 200px;
|
| 166 |
+
background-attachment: fixed;
|
| 167 |
+
background-position: center;
|
| 168 |
+
background-repeat: no-repeat;
|
| 169 |
+
background-size: cover;
|
| 170 |
+
opacity: 0.6;
|
| 171 |
+
}}
|
| 172 |
+
</style>
|
| 173 |
+
""", unsafe_allow_html=True)
|
| 174 |
+
|
| 175 |
+
st.markdown('<div class="parallax"></div>', unsafe_allow_html=True)
|
| 176 |
+
|
| 177 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 178 |
+
|
| 179 |
+
col1, col2 = st.columns([3,7])
|
| 180 |
+
|
| 181 |
+
with col1:
|
| 182 |
+
# Features
|
| 183 |
+
st.markdown("<h3 style='text-align: left; color: #5ac5c9;'>Features</h3>", unsafe_allow_html=True)
|
| 184 |
+
st.write("""
|
| 185 |
+
- Drug interaction detection
|
| 186 |
+
- Conflict identification
|
| 187 |
+
- Similar drug suggestions
|
| 188 |
+
- Alternative medication recommendations
|
| 189 |
+
""")
|
| 190 |
+
|
| 191 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 192 |
+
|
| 193 |
+
# Instructions
|
| 194 |
+
st.markdown("<h3 style='text-align: left; color: #d46c6c;'>Instructions</h3>", unsafe_allow_html=True)
|
| 195 |
+
st.write("""
|
| 196 |
+
1. Enter the drug names separated by commas.
|
| 197 |
+
2. Click on the 'Analyze' button.
|
| 198 |
+
3. Wait for the analysis to complete.
|
| 199 |
+
4. View the results below.
|
| 200 |
+
""")
|
| 201 |
+
|
| 202 |
+
with col2:
|
| 203 |
+
# Input
|
| 204 |
+
st.markdown('<h3 class="big-font">Enter drug names separated by commas:</h3>', unsafe_allow_html=True)
|
| 205 |
+
user_input = st.text_input("", value="", key="drug_input", placeholder="e.g., Aspirin, Warfarin")
|
| 206 |
+
st.markdown('<style>div[data-testid="stTextInput"] input { font-size: 16px;}</style>', unsafe_allow_html=True)
|
| 207 |
+
|
| 208 |
+
if st.button("Analyze",type="primary"):
|
| 209 |
+
if not user_input.strip():
|
| 210 |
+
st.warning("Please enter at least one drug name.")
|
| 211 |
+
return
|
| 212 |
+
|
| 213 |
+
owl_file_path = os.path.join("ontology", "DrugInteraction.owl")
|
| 214 |
+
if not os.path.exists(owl_file_path):
|
| 215 |
+
logging.error(f"Ontology file not found: {owl_file_path}")
|
| 216 |
+
st.error(f"Ontology file not found: {owl_file_path}")
|
| 217 |
+
return
|
| 218 |
+
|
| 219 |
+
try:
|
| 220 |
+
with st.spinner("Analyzing drug interactions..."):
|
| 221 |
+
agent_graph = create_agent_graph(owl_file_path)
|
| 222 |
+
result = agent_graph.invoke(GraphState(input=user_input))
|
| 223 |
+
|
| 224 |
+
st.subheader("Analysis Results:")
|
| 225 |
+
st.markdown(result["response"])
|
| 226 |
+
|
| 227 |
+
logging.info("Analysis completed and results displayed.")
|
| 228 |
+
except Exception as e:
|
| 229 |
+
logging.error(f"An error occurred: {str(e)}")
|
| 230 |
+
st.error(f"An error occurred: {str(e)}")
|
| 231 |
+
|
| 232 |
+
st.markdown("<hr>", unsafe_allow_html=True)
|
| 233 |
+
|
| 234 |
+
# Disclaimer
|
| 235 |
+
st.write("""
|
| 236 |
+
<div style='text-align: center;'>
|
| 237 |
+
<p style='text-align: left; color: #d46c6c;'>Disclaimer: </p><p style='text-align: left; color: #707377;'>This application is intended for informational purposes only and does not replace professional medical advice, diagnosis, or treatment. The analysis provided is based on the data available in the ontology and may not account for all possible drug interactions. Users are strongly advised to consult a licensed healthcare provider before making any decisions based on the analysis results. The creators of this application are not responsible for any decisions made or actions taken based on the information provided.</p>
|
| 238 |
+
</div>
|
| 239 |
+
""", unsafe_allow_html=True)
|
| 240 |
+
|
| 241 |
+
if __name__ == "__main__":
|
| 242 |
+
main()
|
appcli.py
ADDED
|
@@ -0,0 +1,171 @@
|
|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
|
|
|
| 1 |
+
|
| 2 |
+
from rdflib import Graph, Namespace, URIRef, Literal
|
| 3 |
+
from typing import Dict, List, Optional
|
| 4 |
+
from langgraph.graph import StateGraph
|
| 5 |
+
from langchain.prompts import ChatPromptTemplate
|
| 6 |
+
import json
|
| 7 |
+
from dotenv import load_dotenv
|
| 8 |
+
import os
|
| 9 |
+
from dataclasses import dataclass
|
| 10 |
+
from langchain_community.chat_models import ChatOllama
|
| 11 |
+
from langchain_groq import ChatGroq
|
| 12 |
+
import logging
|
| 13 |
+
# Import the DrugInteractionAnalyzer
|
| 14 |
+
from analyzers import DrugInteractionAnalyzer
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# Load environment variables
|
| 18 |
+
load_dotenv()
|
| 19 |
+
|
| 20 |
+
# Configure logging
|
| 21 |
+
logging.basicConfig(
|
| 22 |
+
level=logging.INFO,
|
| 23 |
+
format='%(asctime)s [%(levelname)s] %(message)s',
|
| 24 |
+
handlers=[
|
| 25 |
+
logging.FileHandler("app.log"),
|
| 26 |
+
logging.StreamHandler()
|
| 27 |
+
]
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
# Validating API key
|
| 31 |
+
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 32 |
+
if not GROQ_API_KEY:
|
| 33 |
+
logging.error("GROQ_API_KEY not found in environment variables. Please add it to your .env file.")
|
| 34 |
+
raise ValueError("GROQ_API_KEY not found in environment variables. Please add it to your .env file.")
|
| 35 |
+
|
| 36 |
+
@dataclass
|
| 37 |
+
class GraphState:
|
| 38 |
+
"""State type for the graph."""
|
| 39 |
+
input: str
|
| 40 |
+
query: Optional[str] = None
|
| 41 |
+
ontology_results: Optional[str] = None
|
| 42 |
+
response: Optional[str] = None
|
| 43 |
+
|
| 44 |
+
class OntologyAgent:
|
| 45 |
+
def __init__(self, owl_file_path: str):
|
| 46 |
+
"""Initialize the OntologyAgent with an OWL file."""
|
| 47 |
+
|
| 48 |
+
self.g = Graph()
|
| 49 |
+
try:
|
| 50 |
+
self.g.parse(owl_file_path, format="xml")
|
| 51 |
+
self.ns = Namespace("http://www.example.org/DrugInteraction.owl#")
|
| 52 |
+
logging.info(f"Ontology loaded successfully from {owl_file_path}")
|
| 53 |
+
except Exception as e:
|
| 54 |
+
logging.error(f"Failed to load ontology file: {e}")
|
| 55 |
+
raise ValueError(f"Failed to load ontology file: {e}")
|
| 56 |
+
|
| 57 |
+
def create_agent_graph(owl_file_path: str) -> StateGraph:
|
| 58 |
+
"""Create a processing graph for drug interaction analysis using separate agents."""
|
| 59 |
+
analyzer = DrugInteractionAnalyzer(owl_file_path)
|
| 60 |
+
|
| 61 |
+
def user_input_node(state: GraphState) -> Dict[str, str]:
|
| 62 |
+
logging.info("Processing user input.")
|
| 63 |
+
|
| 64 |
+
return {"query": state.input}
|
| 65 |
+
|
| 66 |
+
def ontology_query_node(state: GraphState) -> Dict[str, str]:
|
| 67 |
+
try:
|
| 68 |
+
logging.info("Executing ontology queries.")
|
| 69 |
+
drug_names = [d.strip() for d in state.input.split(",")]
|
| 70 |
+
results = analyzer.analyze_drugs(drug_names)
|
| 71 |
+
logging.info(f"Ontology query results: {results}")
|
| 72 |
+
return {"ontology_results": json.dumps(results, indent=2)}
|
| 73 |
+
except Exception as e:
|
| 74 |
+
logging.warning(f"Ontology query failed: {e}")
|
| 75 |
+
|
| 76 |
+
return {"ontology_results": json.dumps({"error": str(e)})}
|
| 77 |
+
|
| 78 |
+
def llm_processing_node(state: GraphState) -> Dict[str, str]:
|
| 79 |
+
template = """
|
| 80 |
+
Based on the drug interaction analysis results:
|
| 81 |
+
{ontology_results}
|
| 82 |
+
|
| 83 |
+
Please provide a comprehensive summary of:
|
| 84 |
+
1. Direct interactions between the drugs
|
| 85 |
+
2. Potential conflicts
|
| 86 |
+
3. Similar drug alternatives
|
| 87 |
+
4. Recommended alternatives if conflicts exist
|
| 88 |
+
|
| 89 |
+
If no results were found, please indicate this clearly.
|
| 90 |
+
Format the response in a clear, structured manner.
|
| 91 |
+
"""
|
| 92 |
+
|
| 93 |
+
prompt = ChatPromptTemplate.from_template(template)
|
| 94 |
+
|
| 95 |
+
try:
|
| 96 |
+
llm = ChatGroq(
|
| 97 |
+
model_name="llama3-groq-70b-8192-tool-use-preview",
|
| 98 |
+
api_key=GROQ_API_KEY,
|
| 99 |
+
temperature=0.7
|
| 100 |
+
)
|
| 101 |
+
logging.info("LLM initialized successfully.")
|
| 102 |
+
except Exception as e:
|
| 103 |
+
logging.error(f"Error initializing LLM: {e}")
|
| 104 |
+
return {"response": f"Error initializing LLM: {str(e)}"}
|
| 105 |
+
|
| 106 |
+
chain = prompt | llm
|
| 107 |
+
|
| 108 |
+
try:
|
| 109 |
+
response = chain.invoke({
|
| 110 |
+
"ontology_results": state.ontology_results
|
| 111 |
+
})
|
| 112 |
+
|
| 113 |
+
logging.info("LLM processing completed successfully.")
|
| 114 |
+
return {"response": response.content}
|
| 115 |
+
except Exception as e:
|
| 116 |
+
logging.error(f"Error processing results with LLM: {e}")
|
| 117 |
+
return {"response": f"Error processing results: {str(e)}"}
|
| 118 |
+
|
| 119 |
+
# Create and configure the graph
|
| 120 |
+
workflow = StateGraph(GraphState)
|
| 121 |
+
|
| 122 |
+
workflow.add_node("input_processor", user_input_node)
|
| 123 |
+
workflow.add_node("ontology_query", ontology_query_node)
|
| 124 |
+
workflow.add_node("llm_processing", llm_processing_node)
|
| 125 |
+
|
| 126 |
+
workflow.add_edge("input_processor", "ontology_query")
|
| 127 |
+
workflow.add_edge("ontology_query", "llm_processing")
|
| 128 |
+
|
| 129 |
+
workflow.set_entry_point("input_processor")
|
| 130 |
+
|
| 131 |
+
logging.info("Agent graph created and configured successfully.")
|
| 132 |
+
|
| 133 |
+
return workflow.compile()
|
| 134 |
+
|
| 135 |
+
def main():
|
| 136 |
+
"""Main function to run the drug interaction analysis."""
|
| 137 |
+
try:
|
| 138 |
+
logging.info("Starting Drug Interaction Analysis System.")
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
print("Drug Interaction Analysis System")
|
| 142 |
+
print("Enter drug names separated by commas (e.g., Aspirin, Warfarin):")
|
| 143 |
+
user_input = input("Drugs: ").strip()
|
| 144 |
+
|
| 145 |
+
if not user_input:
|
| 146 |
+
logging.warning("No drug names provided. Exiting.")
|
| 147 |
+
print("No drug names provided. Exiting.")
|
| 148 |
+
return
|
| 149 |
+
|
| 150 |
+
owl_file_path = os.path.join("ontology", "DrugInteraction.owl")
|
| 151 |
+
if not os.path.exists(owl_file_path):
|
| 152 |
+
logging.error(f"Ontology file not found: {owl_file_path}")
|
| 153 |
+
|
| 154 |
+
raise FileNotFoundError(f"Ontology file not found: {owl_file_path}")
|
| 155 |
+
|
| 156 |
+
agent_graph = create_agent_graph(owl_file_path)
|
| 157 |
+
result = agent_graph.invoke(GraphState(input=user_input))
|
| 158 |
+
|
| 159 |
+
print("\nAnalysis Results:")
|
| 160 |
+
print(result["response"])
|
| 161 |
+
|
| 162 |
+
logging.info("Analysis completed and results displayed.")
|
| 163 |
+
|
| 164 |
+
except Exception as e:
|
| 165 |
+
logging.error(f"An error occurred: {str(e)}")
|
| 166 |
+
print(f"An error occurred: {str(e)}")
|
| 167 |
+
print("Please check your input and try again.")
|
| 168 |
+
|
| 169 |
+
if __name__ == "__main__":
|
| 170 |
+
main()
|
| 171 |
+
|
img/header-image.webp
ADDED
|
img/header_image.webp
ADDED
|
img/img.png
ADDED
|
ontology/DrugInteraction.owl
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<rdf:RDF
|
| 3 |
+
xmlns="http://www.example.org/DrugInteraction.owl#"
|
| 4 |
+
xmlns:owl="http://www.w3.org/2002/07/owl#"
|
| 5 |
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
| 6 |
+
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
| 7 |
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
|
| 8 |
+
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
|
| 9 |
+
|
| 10 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#">
|
| 11 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/>
|
| 12 |
+
<rdfs:comment>
|
| 13 |
+
Ontology capturing Drug Interactions, Alternatives, Conflicts, and Similarities.
|
| 14 |
+
</rdfs:comment>
|
| 15 |
+
</rdf:Description>
|
| 16 |
+
<!-- -->
|
| 17 |
+
<!-- -->
|
| 18 |
+
<!-- ################################################################# -->
|
| 19 |
+
<!-- # -->
|
| 20 |
+
<!-- # Object Properties -->
|
| 21 |
+
<!-- # -->
|
| 22 |
+
<!-- ################################################################# -->
|
| 23 |
+
<!-- -->
|
| 24 |
+
<!-- -->
|
| 25 |
+
<!-- http://www.example.org/DrugInteraction.owl#hasAlternative -->
|
| 26 |
+
|
| 27 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#hasAlternative">
|
| 28 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
|
| 29 |
+
<rdfs:domain rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 30 |
+
<rdfs:range rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 31 |
+
<rdfs:label>hasAlternative</rdfs:label>
|
| 32 |
+
</rdf:Description>
|
| 33 |
+
<!-- -->
|
| 34 |
+
<!-- http://www.example.org/DrugInteraction.owl#hasConflict -->
|
| 35 |
+
|
| 36 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#hasConflict">
|
| 37 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
|
| 38 |
+
<rdfs:domain rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 39 |
+
<rdfs:range rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 40 |
+
<rdfs:label>hasConflict</rdfs:label>
|
| 41 |
+
</rdf:Description>
|
| 42 |
+
<!-- -->
|
| 43 |
+
<!-- http://www.example.org/DrugInteraction.owl#hasInteraction -->
|
| 44 |
+
|
| 45 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#hasInteraction">
|
| 46 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
|
| 47 |
+
<rdfs:domain rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 48 |
+
<rdfs:range rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 49 |
+
<rdfs:label>hasInteraction</rdfs:label>
|
| 50 |
+
</rdf:Description>
|
| 51 |
+
<!-- -->
|
| 52 |
+
<!-- http://www.example.org/DrugInteraction.owl#hasSimilarity -->
|
| 53 |
+
|
| 54 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#hasSimilarity">
|
| 55 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
|
| 56 |
+
<rdfs:domain rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 57 |
+
<rdfs:range rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 58 |
+
<rdfs:label>hasSimilarity</rdfs:label>
|
| 59 |
+
</rdf:Description>
|
| 60 |
+
<!-- -->
|
| 61 |
+
<!-- -->
|
| 62 |
+
<!-- -->
|
| 63 |
+
<!-- ################################################################# -->
|
| 64 |
+
<!-- # -->
|
| 65 |
+
<!-- # Classes -->
|
| 66 |
+
<!-- # -->
|
| 67 |
+
<!-- ################################################################# -->
|
| 68 |
+
<!-- -->
|
| 69 |
+
<!-- -->
|
| 70 |
+
<!-- http://www.example.org/DrugInteraction.owl#AlternativeDrug -->
|
| 71 |
+
|
| 72 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#AlternativeDrug">
|
| 73 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 74 |
+
<rdfs:label>AlternativeDrug</rdfs:label>
|
| 75 |
+
</rdf:Description>
|
| 76 |
+
<!-- -->
|
| 77 |
+
<!-- http://www.example.org/DrugInteraction.owl#Conflict -->
|
| 78 |
+
|
| 79 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Conflict">
|
| 80 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 81 |
+
<rdfs:label>Conflict</rdfs:label>
|
| 82 |
+
</rdf:Description>
|
| 83 |
+
<!-- -->
|
| 84 |
+
<!-- http://www.example.org/DrugInteraction.owl#Consumable -->
|
| 85 |
+
|
| 86 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Consumable">
|
| 87 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 88 |
+
<rdfs:comment>consumables</rdfs:comment>
|
| 89 |
+
</rdf:Description>
|
| 90 |
+
<!-- -->
|
| 91 |
+
<!-- http://www.example.org/DrugInteraction.owl#Drug -->
|
| 92 |
+
|
| 93 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Drug">
|
| 94 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 95 |
+
<rdfs:label>Drug</rdfs:label>
|
| 96 |
+
</rdf:Description>
|
| 97 |
+
<!-- -->
|
| 98 |
+
<!-- http://www.example.org/DrugInteraction.owl#DrugInteraction -->
|
| 99 |
+
|
| 100 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#DrugInteraction">
|
| 101 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 102 |
+
<rdfs:label>DrugInteraction</rdfs:label>
|
| 103 |
+
</rdf:Description>
|
| 104 |
+
<!-- -->
|
| 105 |
+
<!-- http://www.example.org/DrugInteraction.owl#Similarity -->
|
| 106 |
+
|
| 107 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Similarity">
|
| 108 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
|
| 109 |
+
<rdfs:label>Similarity</rdfs:label>
|
| 110 |
+
</rdf:Description>
|
| 111 |
+
<!-- -->
|
| 112 |
+
<!-- -->
|
| 113 |
+
<!-- -->
|
| 114 |
+
<!-- ################################################################# -->
|
| 115 |
+
<!-- # -->
|
| 116 |
+
<!-- # Individuals -->
|
| 117 |
+
<!-- # -->
|
| 118 |
+
<!-- ################################################################# -->
|
| 119 |
+
<!-- -->
|
| 120 |
+
<!-- -->
|
| 121 |
+
<!-- http://www.example.org/DrugInteraction.owl#Alcohol -->
|
| 122 |
+
|
| 123 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Alcohol">
|
| 124 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 125 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 126 |
+
<rdfs:label>Alcohol</rdfs:label>
|
| 127 |
+
</rdf:Description>
|
| 128 |
+
<!-- -->
|
| 129 |
+
<!-- http://www.example.org/DrugInteraction.owl#Amlodipine -->
|
| 130 |
+
|
| 131 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Amlodipine">
|
| 132 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 133 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 134 |
+
<hasSimilarity rdf:resource="http://www.example.org/DrugInteraction.owl#Nifedipine"/>
|
| 135 |
+
<rdfs:label>Amlodipine</rdfs:label>
|
| 136 |
+
</rdf:Description>
|
| 137 |
+
<!-- -->
|
| 138 |
+
<!-- http://www.example.org/DrugInteraction.owl#Apixaban -->
|
| 139 |
+
|
| 140 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Apixaban">
|
| 141 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 142 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 143 |
+
<rdfs:label>Apixaban</rdfs:label>
|
| 144 |
+
</rdf:Description>
|
| 145 |
+
<!-- -->
|
| 146 |
+
<!-- http://www.example.org/DrugInteraction.owl#Aspirin -->
|
| 147 |
+
|
| 148 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Aspirin">
|
| 149 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 150 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 151 |
+
<rdfs:label>Aspirin</rdfs:label>
|
| 152 |
+
</rdf:Description>
|
| 153 |
+
<!-- -->
|
| 154 |
+
<!-- http://www.example.org/DrugInteraction.owl#Atorvastatin -->
|
| 155 |
+
|
| 156 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Atorvastatin">
|
| 157 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 158 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 159 |
+
<hasConflict rdf:resource="http://www.example.org/DrugInteraction.owl#grapefruitJuice"/>
|
| 160 |
+
<rdfs:label>Atorvastatin</rdfs:label>
|
| 161 |
+
</rdf:Description>
|
| 162 |
+
<!-- -->
|
| 163 |
+
<!-- http://www.example.org/DrugInteraction.owl#Caffeine -->
|
| 164 |
+
|
| 165 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Caffeine">
|
| 166 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 167 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 168 |
+
<rdfs:label>Caffeine</rdfs:label>
|
| 169 |
+
</rdf:Description>
|
| 170 |
+
<!-- -->
|
| 171 |
+
<!-- http://www.example.org/DrugInteraction.owl#Ciprofloxacin -->
|
| 172 |
+
|
| 173 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Ciprofloxacin">
|
| 174 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 175 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 176 |
+
<rdfs:label>Ciprofloxacin</rdfs:label>
|
| 177 |
+
</rdf:Description>
|
| 178 |
+
<!-- -->
|
| 179 |
+
<!-- http://www.example.org/DrugInteraction.owl#Clopidogrel -->
|
| 180 |
+
|
| 181 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Clopidogrel">
|
| 182 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 183 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 184 |
+
<hasInteraction rdf:resource="http://www.example.org/DrugInteraction.owl#Omeprazole"/>
|
| 185 |
+
<rdfs:label>Clopidogrel</rdfs:label>
|
| 186 |
+
</rdf:Description>
|
| 187 |
+
<!-- -->
|
| 188 |
+
<!-- http://www.example.org/DrugInteraction.owl#Empagliflozin -->
|
| 189 |
+
|
| 190 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Empagliflozin">
|
| 191 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 192 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 193 |
+
<rdfs:label>Empagliflozin</rdfs:label>
|
| 194 |
+
</rdf:Description>
|
| 195 |
+
<!-- -->
|
| 196 |
+
<!-- http://www.example.org/DrugInteraction.owl#Erythromycin -->
|
| 197 |
+
|
| 198 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Erythromycin">
|
| 199 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 200 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 201 |
+
<rdfs:label>Erythromycin</rdfs:label>
|
| 202 |
+
</rdf:Description>
|
| 203 |
+
<!-- -->
|
| 204 |
+
<!-- http://www.example.org/DrugInteraction.owl#Esomeprazole -->
|
| 205 |
+
|
| 206 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Esomeprazole">
|
| 207 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 208 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 209 |
+
<rdfs:label>Esomeprazole</rdfs:label>
|
| 210 |
+
</rdf:Description>
|
| 211 |
+
<!-- -->
|
| 212 |
+
<!-- http://www.example.org/DrugInteraction.owl#Fluoxetine -->
|
| 213 |
+
|
| 214 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Fluoxetine">
|
| 215 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 216 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 217 |
+
<rdfs:label>Fluoxetine</rdfs:label>
|
| 218 |
+
</rdf:Description>
|
| 219 |
+
<!-- -->
|
| 220 |
+
<!-- http://www.example.org/DrugInteraction.owl#Glucophage -->
|
| 221 |
+
|
| 222 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Glucophage">
|
| 223 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 224 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 225 |
+
<rdfs:label>Glucophage</rdfs:label>
|
| 226 |
+
</rdf:Description>
|
| 227 |
+
<!-- -->
|
| 228 |
+
<!-- http://www.example.org/DrugInteraction.owl#Ibuprofen -->
|
| 229 |
+
|
| 230 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Ibuprofen">
|
| 231 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 232 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 233 |
+
<hasSimilarity rdf:resource="http://www.example.org/DrugInteraction.owl#Naproxen"/>
|
| 234 |
+
<rdfs:label>Ibuprofen</rdfs:label>
|
| 235 |
+
</rdf:Description>
|
| 236 |
+
<!-- -->
|
| 237 |
+
<!-- http://www.example.org/DrugInteraction.owl#Lisinopril -->
|
| 238 |
+
|
| 239 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Lisinopril">
|
| 240 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 241 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 242 |
+
<hasAlternative rdf:resource="http://www.example.org/DrugInteraction.owl#Losartan"/>
|
| 243 |
+
<hasInteraction rdf:resource="http://www.example.org/DrugInteraction.owl#Spironolactone"/>
|
| 244 |
+
<rdfs:label>Lisinopril</rdfs:label>
|
| 245 |
+
</rdf:Description>
|
| 246 |
+
<!-- -->
|
| 247 |
+
<!-- http://www.example.org/DrugInteraction.owl#Losartan -->
|
| 248 |
+
|
| 249 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Losartan">
|
| 250 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 251 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 252 |
+
<rdfs:label>Losartan</rdfs:label>
|
| 253 |
+
</rdf:Description>
|
| 254 |
+
<!-- -->
|
| 255 |
+
<!-- http://www.example.org/DrugInteraction.owl#Metformin -->
|
| 256 |
+
|
| 257 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Metformin">
|
| 258 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 259 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 260 |
+
<hasAlternative rdf:resource="http://www.example.org/DrugInteraction.owl#Empagliflozin"/>
|
| 261 |
+
<hasInteraction rdf:resource="http://www.example.org/DrugInteraction.owl#Ciprofloxacin"/>
|
| 262 |
+
<hasSimilarity rdf:resource="http://www.example.org/DrugInteraction.owl#Glucophage"/>
|
| 263 |
+
<rdfs:label>Metformin</rdfs:label>
|
| 264 |
+
</rdf:Description>
|
| 265 |
+
<!-- -->
|
| 266 |
+
<!-- http://www.example.org/DrugInteraction.owl#Metronidazole -->
|
| 267 |
+
|
| 268 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Metronidazole">
|
| 269 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 270 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 271 |
+
<hasConflict rdf:resource="http://www.example.org/DrugInteraction.owl#Alcohol"/>
|
| 272 |
+
<rdfs:label>Metronidazole</rdfs:label>
|
| 273 |
+
</rdf:Description>
|
| 274 |
+
<!-- -->
|
| 275 |
+
<!-- http://www.example.org/DrugInteraction.owl#Naproxen -->
|
| 276 |
+
|
| 277 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Naproxen">
|
| 278 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 279 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 280 |
+
<rdfs:label>Naproxen</rdfs:label>
|
| 281 |
+
</rdf:Description>
|
| 282 |
+
<!-- -->
|
| 283 |
+
<!-- http://www.example.org/DrugInteraction.owl#Nifedipine -->
|
| 284 |
+
|
| 285 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Nifedipine">
|
| 286 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 287 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 288 |
+
<rdfs:label>Nifedipine</rdfs:label>
|
| 289 |
+
</rdf:Description>
|
| 290 |
+
<!-- -->
|
| 291 |
+
<!-- http://www.example.org/DrugInteraction.owl#Omeprazole -->
|
| 292 |
+
|
| 293 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Omeprazole">
|
| 294 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 295 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 296 |
+
<hasAlternative rdf:resource="http://www.example.org/DrugInteraction.owl#Pantoprazole"/>
|
| 297 |
+
<hasSimilarity rdf:resource="http://www.example.org/DrugInteraction.owl#Esomeprazole"/>
|
| 298 |
+
<rdfs:label>Omeprazole</rdfs:label>
|
| 299 |
+
</rdf:Description>
|
| 300 |
+
<!-- -->
|
| 301 |
+
<!-- http://www.example.org/DrugInteraction.owl#Pantoprazole -->
|
| 302 |
+
|
| 303 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Pantoprazole">
|
| 304 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 305 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 306 |
+
<rdfs:label>Pantoprazole</rdfs:label>
|
| 307 |
+
</rdf:Description>
|
| 308 |
+
<!-- -->
|
| 309 |
+
<!-- http://www.example.org/DrugInteraction.owl#Phenelzine -->
|
| 310 |
+
|
| 311 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Phenelzine">
|
| 312 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 313 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 314 |
+
<hasConflict rdf:resource="http://www.example.org/DrugInteraction.owl#tyramineFoods"/>
|
| 315 |
+
<rdfs:label>Phenelzine</rdfs:label>
|
| 316 |
+
</rdf:Description>
|
| 317 |
+
<!-- -->
|
| 318 |
+
<!-- http://www.example.org/DrugInteraction.owl#Rosuvastatin -->
|
| 319 |
+
|
| 320 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Rosuvastatin">
|
| 321 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 322 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 323 |
+
<rdfs:label>Rosuvastatin</rdfs:label>
|
| 324 |
+
</rdf:Description>
|
| 325 |
+
<!-- -->
|
| 326 |
+
<!-- http://www.example.org/DrugInteraction.owl#Sertraline -->
|
| 327 |
+
|
| 328 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Sertraline">
|
| 329 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 330 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 331 |
+
<hasSimilarity rdf:resource="http://www.example.org/DrugInteraction.owl#Fluoxetine"/>
|
| 332 |
+
<rdfs:label>Sertraline</rdfs:label>
|
| 333 |
+
</rdf:Description>
|
| 334 |
+
<!-- -->
|
| 335 |
+
<!-- http://www.example.org/DrugInteraction.owl#Simvastatin -->
|
| 336 |
+
|
| 337 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Simvastatin">
|
| 338 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 339 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 340 |
+
<hasAlternative rdf:resource="http://www.example.org/DrugInteraction.owl#Rosuvastatin"/>
|
| 341 |
+
<hasInteraction rdf:resource="http://www.example.org/DrugInteraction.owl#Erythromycin"/>
|
| 342 |
+
<rdfs:label>Simvastatin</rdfs:label>
|
| 343 |
+
</rdf:Description>
|
| 344 |
+
<!-- -->
|
| 345 |
+
<!-- http://www.example.org/DrugInteraction.owl#Spironolactone -->
|
| 346 |
+
|
| 347 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Spironolactone">
|
| 348 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 349 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 350 |
+
<rdfs:label>Spironolactone</rdfs:label>
|
| 351 |
+
</rdf:Description>
|
| 352 |
+
<!-- -->
|
| 353 |
+
<!-- http://www.example.org/DrugInteraction.owl#Theophylline -->
|
| 354 |
+
|
| 355 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Theophylline">
|
| 356 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 357 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 358 |
+
<hasConflict rdf:resource="http://www.example.org/DrugInteraction.owl#Caffeine"/>
|
| 359 |
+
<rdfs:label>Theophylline</rdfs:label>
|
| 360 |
+
</rdf:Description>
|
| 361 |
+
<!-- -->
|
| 362 |
+
<!-- http://www.example.org/DrugInteraction.owl#Warfarin -->
|
| 363 |
+
|
| 364 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#Warfarin">
|
| 365 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 366 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Drug"/>
|
| 367 |
+
<hasAlternative rdf:resource="http://www.example.org/DrugInteraction.owl#Apixaban"/>
|
| 368 |
+
<hasConflict rdf:resource="http://www.example.org/DrugInteraction.owl#greenLeafyVegetables"/>
|
| 369 |
+
<hasInteraction rdf:resource="http://www.example.org/DrugInteraction.owl#Aspirin"/>
|
| 370 |
+
<rdfs:label>Warfarin</rdfs:label>
|
| 371 |
+
</rdf:Description>
|
| 372 |
+
<!-- -->
|
| 373 |
+
<!-- http://www.example.org/DrugInteraction.owl#grapefruitJuice -->
|
| 374 |
+
|
| 375 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#grapefruitJuice">
|
| 376 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 377 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 378 |
+
<rdfs:label>GrapefruitJuice</rdfs:label>
|
| 379 |
+
</rdf:Description>
|
| 380 |
+
<!-- -->
|
| 381 |
+
<!-- http://www.example.org/DrugInteraction.owl#greenLeafyVegetables -->
|
| 382 |
+
|
| 383 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#greenLeafyVegetables">
|
| 384 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 385 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 386 |
+
<rdfs:label>GreenLeafyVegetables</rdfs:label>
|
| 387 |
+
</rdf:Description>
|
| 388 |
+
<!-- -->
|
| 389 |
+
<!-- http://www.example.org/DrugInteraction.owl#tyramineFoods -->
|
| 390 |
+
|
| 391 |
+
<rdf:Description rdf:about="http://www.example.org/DrugInteraction.owl#tyramineFoods">
|
| 392 |
+
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
|
| 393 |
+
<rdf:type rdf:resource="http://www.example.org/DrugInteraction.owl#Consumable"/>
|
| 394 |
+
<rdfs:label>TyramineFoods</rdfs:label>
|
| 395 |
+
</rdf:Description>
|
| 396 |
+
<!-- -->
|
| 397 |
+
<!-- Generated by the OWL API (version 4.5.29.2024-05-13T12:11:03Z) https://github.com/owlcs/owlapi -->
|
| 398 |
+
|
| 399 |
+
</rdf:RDF>
|
requirements.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
rdflib
|
| 2 |
+
langchain
|
| 3 |
+
python-dotenv
|
| 4 |
+
langchain-community
|
| 5 |
+
langchain-groq
|
| 6 |
+
langgraph
|
| 7 |
+
streamlit
|