Uploaded from GitHub
Browse files- .gitattributes +36 -35
- DrugInteraction.owl +399 -0
- LICENSE +201 -0
- Notebooks/DrugInteraction.owl +72 -0
- Notebooks/Final/test_with_input.ipynb +207 -0
- Notebooks/sparql.ipynb +169 -0
- Notebooks/testOnto.ipynb +320 -0
- README.md +13 -13
- 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 +159 -0
- appcli.py +171 -0
- img/img.png +3 -0
- ontology/DrugInteraction.owl +399 -0
- requirements.txt +7 -0
.gitattributes
CHANGED
|
@@ -1,35 +1,36 @@
|
|
| 1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge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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>
|
LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [2024] [Manith Jayaba, Ramith, Shakya, Tharindu, Hasitha]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
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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
+
"# !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 |
+
"nbconvert_exporter": "python",
|
| 163 |
+
"pygments_lexer": "ipython3",
|
| 164 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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 |
+
}
|
README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Drug Interaction Analysis System
|
| 3 |
-
emoji: 🏆
|
| 4 |
-
colorFrom: green
|
| 5 |
-
colorTo: pink
|
| 6 |
-
sdk: streamlit
|
| 7 |
-
sdk_version: 1.43.2
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
short_description: 'Using Ontograph, Langgraph, Semantic Web Ontology, LLMs '
|
| 11 |
-
---
|
| 12 |
-
|
| 13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Drug Interaction Analysis System
|
| 3 |
+
emoji: 🏆
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: pink
|
| 6 |
+
sdk: streamlit
|
| 7 |
+
sdk_version: 1.43.2
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
short_description: 'Using Ontograph, Langgraph, Semantic Web Ontology, LLMs '
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
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}")
|
| 87 |
+
|
| 88 |
+
logging.info("Completed analysis for all drugs.")
|
| 89 |
+
return results
|
app.py
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 15 |
+
# Load environment variables
|
| 16 |
+
load_dotenv()
|
| 17 |
+
|
| 18 |
+
# Configure logging
|
| 19 |
+
logging.basicConfig(
|
| 20 |
+
level=logging.INFO,
|
| 21 |
+
format='%(asctime)s [%(levelname)s] %(message)s',
|
| 22 |
+
handlers=[
|
| 23 |
+
logging.FileHandler("app.log"),
|
| 24 |
+
logging.StreamHandler()
|
| 25 |
+
]
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Validating API key
|
| 29 |
+
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 30 |
+
if not GROQ_API_KEY:
|
| 31 |
+
logging.error("GROQ_API_KEY not found in environment variables. Please add it to your .env file.")
|
| 32 |
+
raise ValueError("GROQ_API_KEY not found in environment variables. Please add it to your .env file.")
|
| 33 |
+
|
| 34 |
+
@dataclass
|
| 35 |
+
class GraphState:
|
| 36 |
+
"""State type for the graph."""
|
| 37 |
+
input: str
|
| 38 |
+
query: Optional[str] = None
|
| 39 |
+
ontology_results: Optional[str] = None
|
| 40 |
+
response: Optional[str] = None
|
| 41 |
+
|
| 42 |
+
class OntologyAgent:
|
| 43 |
+
def __init__(self, owl_file_path: str):
|
| 44 |
+
"""Initialize the OntologyAgent with an OWL file."""
|
| 45 |
+
self.g = Graph()
|
| 46 |
+
try:
|
| 47 |
+
self.g.parse(owl_file_path, format="xml")
|
| 48 |
+
self.ns = Namespace("http://www.example.org/DrugInteraction.owl#")
|
| 49 |
+
logging.info(f"Ontology loaded successfully from {owl_file_path}")
|
| 50 |
+
except Exception as e:
|
| 51 |
+
logging.error(f"Failed to load ontology file: {e}")
|
| 52 |
+
raise ValueError(f"Failed to load ontology file: {e}")
|
| 53 |
+
|
| 54 |
+
def create_agent_graph(owl_file_path: str) -> StateGraph:
|
| 55 |
+
"""Create a processing graph for drug interaction analysis using separate agents."""
|
| 56 |
+
analyzer = DrugInteractionAnalyzer(owl_file_path)
|
| 57 |
+
|
| 58 |
+
def user_input_node(state: GraphState) -> Dict[str, str]:
|
| 59 |
+
logging.info("Processing user input.")
|
| 60 |
+
return {"query": state.input}
|
| 61 |
+
|
| 62 |
+
def ontology_query_node(state: GraphState) -> Dict[str, str]:
|
| 63 |
+
try:
|
| 64 |
+
logging.info("Executing ontology queries.")
|
| 65 |
+
drug_names = [d.strip() for d in state.input.split(",")]
|
| 66 |
+
results = analyzer.analyze_drugs(drug_names)
|
| 67 |
+
logging.info(f"Ontology query results: {results}")
|
| 68 |
+
return {"ontology_results": json.dumps(results, indent=2)}
|
| 69 |
+
except Exception as e:
|
| 70 |
+
logging.warning(f"Ontology query failed: {e}")
|
| 71 |
+
return {"ontology_results": json.dumps({"error": str(e)})}
|
| 72 |
+
|
| 73 |
+
def llm_processing_node(state: GraphState) -> Dict[str, str]:
|
| 74 |
+
template = """
|
| 75 |
+
Based on the drug interaction analysis results:
|
| 76 |
+
{ontology_results}
|
| 77 |
+
|
| 78 |
+
Please provide a comprehensive summary of:
|
| 79 |
+
1. Direct interactions between the drugs
|
| 80 |
+
2. Potential conflicts
|
| 81 |
+
3. Similar drug alternatives
|
| 82 |
+
4. Recommended alternatives if conflicts exist
|
| 83 |
+
|
| 84 |
+
If no results were found, please indicate this clearly.
|
| 85 |
+
Format the response in a clear, structured manner.
|
| 86 |
+
"""
|
| 87 |
+
|
| 88 |
+
prompt = ChatPromptTemplate.from_template(template)
|
| 89 |
+
|
| 90 |
+
try:
|
| 91 |
+
llm = ChatGroq(
|
| 92 |
+
model_name="llama3-groq-70b-8192-tool-use-preview",
|
| 93 |
+
api_key=GROQ_API_KEY,
|
| 94 |
+
temperature=0.7
|
| 95 |
+
)
|
| 96 |
+
logging.info("LLM initialized successfully.")
|
| 97 |
+
except Exception as e:
|
| 98 |
+
logging.error(f"Error initializing LLM: {e}")
|
| 99 |
+
return {"response": f"Error initializing LLM: {str(e)}"}
|
| 100 |
+
|
| 101 |
+
chain = prompt | llm
|
| 102 |
+
|
| 103 |
+
try:
|
| 104 |
+
response = chain.invoke({
|
| 105 |
+
"ontology_results": state.ontology_results
|
| 106 |
+
})
|
| 107 |
+
|
| 108 |
+
logging.info("LLM processing completed successfully.")
|
| 109 |
+
return {"response": response.content}
|
| 110 |
+
except Exception as e:
|
| 111 |
+
logging.error(f"Error processing results with LLM: {e}")
|
| 112 |
+
return {"response": f"Error processing results: {str(e)}"}
|
| 113 |
+
|
| 114 |
+
workflow = StateGraph(GraphState)
|
| 115 |
+
|
| 116 |
+
workflow.add_node("input_processor", user_input_node)
|
| 117 |
+
workflow.add_node("ontology_query", ontology_query_node)
|
| 118 |
+
workflow.add_node("llm_processing", llm_processing_node)
|
| 119 |
+
|
| 120 |
+
workflow.add_edge("input_processor", "ontology_query")
|
| 121 |
+
workflow.add_edge("ontology_query", "llm_processing")
|
| 122 |
+
|
| 123 |
+
workflow.set_entry_point("input_processor")
|
| 124 |
+
|
| 125 |
+
logging.info("Agent graph created and configured successfully.")
|
| 126 |
+
|
| 127 |
+
return workflow.compile()
|
| 128 |
+
|
| 129 |
+
def main():
|
| 130 |
+
st.title("Drug Interaction Analysis System")
|
| 131 |
+
|
| 132 |
+
user_input = st.text_input("Enter drug names separated by commas (e.g., Aspirin, Warfarin):", value="")
|
| 133 |
+
|
| 134 |
+
if st.button("Analyze"):
|
| 135 |
+
if not user_input.strip():
|
| 136 |
+
st.warning("Please enter at least one drug name.")
|
| 137 |
+
return
|
| 138 |
+
|
| 139 |
+
owl_file_path = os.path.join("ontology", "DrugInteraction.owl")
|
| 140 |
+
if not os.path.exists(owl_file_path):
|
| 141 |
+
logging.error(f"Ontology file not found: {owl_file_path}")
|
| 142 |
+
st.error(f"Ontology file not found: {owl_file_path}")
|
| 143 |
+
return
|
| 144 |
+
|
| 145 |
+
try:
|
| 146 |
+
with st.spinner("Analyzing drug interactions..."):
|
| 147 |
+
agent_graph = create_agent_graph(owl_file_path)
|
| 148 |
+
result = agent_graph.invoke(GraphState(input=user_input))
|
| 149 |
+
|
| 150 |
+
st.subheader("Analysis Results:")
|
| 151 |
+
st.markdown(result["response"])
|
| 152 |
+
|
| 153 |
+
logging.info("Analysis completed and results displayed.")
|
| 154 |
+
except Exception as e:
|
| 155 |
+
logging.error(f"An error occurred: {str(e)}")
|
| 156 |
+
st.error(f"An error occurred: {str(e)}")
|
| 157 |
+
|
| 158 |
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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/img.png
ADDED
|
Git LFS Details
|
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
|