diff --git a/src/pathfinder/get_cooccurrence.py b/src/pathfinder/get_cooccurrence.py index 829048e..f24da98 100644 --- a/src/pathfinder/get_cooccurrence.py +++ b/src/pathfinder/get_cooccurrence.py @@ -1,16 +1,23 @@ """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="localhost", - port=6379, - db=0 + host=REDIS_HOST, + port=REDIS_PORT, + db=PMIDS_DB, + password=REDIS_PASSWORD ) curie_pmids = [] for curie in curies: @@ -25,9 +32,10 @@ def get_the_pmids(curies: List[str]): def get_the_curies(pmid: str): r = redis.Redis( - host="localhost", - port=6379, - db=1 + host=REDIS_HOST, + port=REDIS_PORT, + db=CURIES_DB, + password=REDIS_PASSWORD ) curies = r.get(pmid) if curies is None: