-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from ranking-agent/shadowfax
Shadowfax
- Loading branch information
Showing
7 changed files
with
616 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"message": { | ||
"query_graph": { | ||
"nodes": { | ||
"n0": { | ||
"ids": [ | ||
"PUBCHEM.COMPOUND:5291" | ||
], | ||
"name": "imatinib" | ||
}, | ||
"n1": { | ||
"ids": [ | ||
"MONDO:0004979" | ||
], | ||
"name": "asthma" | ||
}, | ||
"un": { | ||
"categories": [ | ||
"biolink:NamedThing" | ||
] | ||
} | ||
}, | ||
"edges": { | ||
"e0": { | ||
"subject": "n0", | ||
"object": "n1", | ||
"predicates": [ | ||
"biolink:related_to" | ||
], | ||
"knowledge_type": "inferred" | ||
}, | ||
"e1": { | ||
"subject": "n0", | ||
"object": "un", | ||
"predicates": [ | ||
"biolink:related_to" | ||
], | ||
"knowledge_type": "inferred" | ||
}, | ||
"e2": { | ||
"subject": "n1", | ||
"object": "un", | ||
"predicates": [ | ||
"biolink:related_to" | ||
], | ||
"knowledge_type": "inferred" | ||
} | ||
} | ||
}, | ||
"knowledge_graph": { | ||
"nodes": {}, | ||
"edges": {} | ||
}, | ||
"results": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"""Get more than pairwise literature cooccurence for a given list of curies.""" | ||
import json | ||
import gzip | ||
import os | ||
import redis | ||
import time | ||
from typing import List | ||
|
||
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost") | ||
REDIS_PORT = os.environ.get("REDIS_PORT", 6379) | ||
PMIDS_DB = os.environ.get("PMIDS_DB", 1) | ||
CURIES_DB = os.environ.get("CURIES_DB", 2) | ||
REDIS_PASSWORD = os.environ.get("REDIS_PASSWORD") | ||
|
||
def get_the_pmids(curies: List[str]): | ||
r = redis.Redis( | ||
host=REDIS_HOST, | ||
port=REDIS_PORT, | ||
db=PMIDS_DB, | ||
password=REDIS_PASSWORD | ||
) | ||
curie_pmids = [] | ||
for curie in curies: | ||
pmids = r.get(curie) | ||
if pmids is None: | ||
pmids = [] | ||
else: | ||
pmids = json.loads(gzip.decompress(pmids)) | ||
curie_pmids.append(pmids) | ||
answer = list(set.intersection(*map(set, curie_pmids))) | ||
return answer | ||
|
||
def get_the_curies(pmid: str): | ||
r = redis.Redis( | ||
host=REDIS_HOST, | ||
port=REDIS_PORT, | ||
db=CURIES_DB, | ||
password=REDIS_PASSWORD | ||
) | ||
curies = r.get(pmid) | ||
if curies is None: | ||
curies = [] | ||
else: | ||
curies = json.loads(gzip.decompress(curies)) | ||
answer = list(curies) | ||
return answer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.