Skip to content

Commit

Permalink
Merge pull request #79 from rcsb/dev-dwp
Browse files Browse the repository at this point in the history
V1.26 Add support for accessing target cofactor data from MongoDB
  • Loading branch information
piehld authored Aug 20, 2024
2 parents 7ac58da + 919d08d commit b890f54
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 48 deletions.
1 change: 1 addition & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,4 @@
13-May-2024 - V1.24 Update requirements
25-Jul-2024 - V1.25 Update ligand neighbor calculations and populate them into polymer entity instance features;
Remove NeighborInteractionProvider from DictMethodResourceProvider, since will now be calculating interactions on the fly
20-Aug-2024 - V1.26 Add support for accessing target cofactor data from MongoDB
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:
- template: azure-template-tox-job.yml
parameters: { tox: "lint_pylint", python: "3.9", os: "linux" }
- template: azure-template-tox-job.yml
parameters: { tox: "test_coverage", python: "3.9", os: "linux" }
parameters: { tox: "test_coverage", python: "3.9", os: "linux", fixtures: 'mongodb' }
#
- template: azure-template-tox-job.yml
parameters: { tox: "py39", python: "3.9", os: "linux" }
parameters: { tox: "py39", python: "3.9", os: "linux", fixtures: 'mongodb' }
#
- template: azure-template-tox-job.yml
parameters: { tox: "py39", python: "3.9", os: "macos" }
parameters: { tox: "py39", python: "3.9", os: "macos", fixtures: 'mongodb' }
#
#- template: azure-template-publish-job.yml
# parameters: {tox: 'py39', python: '3.9', os: 'macos'}
Expand Down
25 changes: 20 additions & 5 deletions azure-template-tox-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
displayName: "Install bison"
- script: which bison
displayName: "Check bison"
- script: brew install mariadb
displayName: "Install mariadb"
# ----------------------------------------------
- ${{ if startsWith(parameters.os, 'linux') }}:
- script: lsb_release -a
Expand Down Expand Up @@ -110,15 +112,15 @@ jobs:
displayName: "Start and configure mysql ..."
# -----
- ? ${{ if and(contains(parameters.fixtures, 'mongodb'), startsWith(parameters.os, 'linux')) }}
: # Mongo install
# Mongo install
- ${{ if and(contains(parameters.fixtures, 'mongodb'), startsWith(parameters.os, 'linux')) }}:
- script: |
sudo apt-get install gnupg wget
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add -
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
sudo apt list --installed | grep mongodb
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
# echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
# echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo apt list --installed | grep mongo
Expand All @@ -129,6 +131,19 @@ jobs:
sudo ss -tulpn
displayName: "Start Mongo service"
#
- ${{ if and(contains(parameters.fixtures, 'mongodb'), startsWith(parameters.os, 'macos')) }}:
- script: |
brew tap mongodb/brew
brew update
brew install [email protected]
displayName: "Installing mongodb"
#
- script: brew services start [email protected]
displayName: "Start Mongo service"
#
- script: brew services list
displayName: "Check mongodb service"
#
#
- script: 'python -c "import sys; print(sys.version); print(sys.executable)"'
displayName: show python information
Expand Down
37 changes: 22 additions & 15 deletions rcsb/utils/dictionary/DictMethodEntityHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# 12-Sep-2023 dwp RO-4033: When using SIFTS alignment data, don't mix and match segments from different chains of the same entity
# 2-Nov-2023 dwp Only populate rcsb_entity_feature_summary for features that are present
# 18-Mar-2024 dwp Separate out gathering of entity reference sequence alignments from assignment step
# 20-Aug-2024 dwp Add support for accessing target cofactor data from MongoDB
##
"""
Helper class implements methods supporting entity-level item and category methods in the RCSB dictionary extension.
Expand Down Expand Up @@ -82,9 +83,9 @@ def __init__(self, **kwargs):
self.__cardP = rP.getResource("CARDTargetAnnotationProvider instance") if rP else None
self.__imgtP = rP.getResource("IMGTTargetFeatureProvider instance") if rP else None
self.__sabdabP = rP.getResource("SAbDabTargetFeatureProvider instance") if rP else None
self.__chemblP = rP.getResource("ChEMBLTargetCofactorProvider instance") if rP else None
self.__dbP = rP.getResource("DrugBankTargetCofactorProvider instance") if rP else None
self.__phP = rP.getResource("PharosTargetCofactorProvider instance") if rP else None
self.__chemblA = rP.getResource("ChEMBLTargetCofactorAccessor instance") if rP else None
self.__dbA = rP.getResource("DrugBankTargetCofactorAccessor instance") if rP else None
self.__phA = rP.getResource("PharosTargetCofactorAccessor instance") if rP else None
#
logger.debug("Dictionary entity method helper init")

Expand Down Expand Up @@ -2040,6 +2041,9 @@ def buildRelatedTargetReferences(self, dataContainer, catName, **kwargs):
if not dataContainer.exists("entry"):
return False
#
if dataContainer.exists("ma_data"):
return False
#
# Create the new target category
if not dataContainer.exists(catName):
dataContainer.append(DataCategory(catName, attributeNameList=self.__dApi.getAttributeNameList(catName)))
Expand All @@ -2052,12 +2056,12 @@ def buildRelatedTargetReferences(self, dataContainer, catName, **kwargs):
ii = cObj.getRowCount()
#
# --- ChEMBL
if self.__chemblP:
if self.__chemblA:
for entityId, eType in eTypeD.items():
if eType not in ["polymer", "branched"]:
continue
eId = entryId + "_" + entityId
tDL = self.__chemblP.getTargets(eId)
tDL = self.__chemblA.getTargets(eId)
dupD = {}
for tD in tDL:
if tD["query_id"] in dupD:
Expand All @@ -2083,12 +2087,12 @@ def buildRelatedTargetReferences(self, dataContainer, catName, **kwargs):
#
ii += 1
#
if self.__dbP:
if self.__dbA:
for entityId, eType in eTypeD.items():
if eType not in ["polymer", "branched"]:
continue
eId = entryId + "_" + entityId
tDL = self.__dbP.getTargets(eId)
tDL = self.__dbA.getTargets(eId)
dupD = {}
for tD in tDL:
if tD["query_id"] in dupD:
Expand All @@ -2113,12 +2117,12 @@ def buildRelatedTargetReferences(self, dataContainer, catName, **kwargs):
#
ii += 1
#
if self.__phP:
if self.__phA:
for entityId, eType in eTypeD.items():
if eType not in ["polymer", "branched"]:
continue
eId = entryId + "_" + entityId
tDL = self.__phP.getTargets(eId)
tDL = self.__phA.getTargets(eId)
dupD = {}
for tD in tDL:
if tD["query_id"] in dupD:
Expand Down Expand Up @@ -2257,6 +2261,9 @@ def buildTargetCofactors(self, dataContainer, catName, **kwargs):
if not dataContainer.exists("entry"):
return False
#
if dataContainer.exists("ma_data"):
return False
#
# Create the new target category
if not dataContainer.exists(catName):
dataContainer.append(DataCategory(catName, attributeNameList=self.__dApi.getAttributeNameList(catName)))
Expand All @@ -2270,12 +2277,12 @@ def buildTargetCofactors(self, dataContainer, catName, **kwargs):
#
# JDW "cofactor_id" -> 'cofactor_resource_id': 'DB14031', 'target_resource_id': 'P06276',
# --- ChEMBL
if self.__chemblP:
if self.__chemblA:
for entityId, eType in eTypeD.items():
if eType not in ["polymer", "branched"]:
continue
eId = entryId + "_" + entityId
tDL = self.__chemblP.getTargets(eId)
tDL = self.__chemblA.getTargets(eId)
# --
dupD = {}
# --
Expand Down Expand Up @@ -2313,12 +2320,12 @@ def buildTargetCofactors(self, dataContainer, catName, **kwargs):
#
ii += 1
#
if self.__dbP:
if self.__dbA:
for entityId, eType in eTypeD.items():
if eType not in ["polymer", "branched"]:
continue
eId = entryId + "_" + entityId
tDL = self.__dbP.getTargets(eId)
tDL = self.__dbA.getTargets(eId)
# --
dupD = {}
# --
Expand Down Expand Up @@ -2348,12 +2355,12 @@ def buildTargetCofactors(self, dataContainer, catName, **kwargs):
#
ii += 1

if self.__phP:
if self.__phA:
for entityId, eType in eTypeD.items():
if eType not in ["polymer", "branched"]:
continue
eId = entryId + "_" + entityId
tDL = self.__phP.getTargets(eId)
tDL = self.__phA.getTargets(eId)
# --
dupD = {}
# --
Expand Down
37 changes: 22 additions & 15 deletions rcsb/utils/dictionary/DictMethodResourceProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# loading of unnecessary resources for each dataset (via providerTypeExcludeL)
# 9-May-2024 dwp Change providerTypeExclude to be a list, 'providerTypeExcludeL'
# 25-Jul-2024 dwp Remove NeighborInteractionProvider from provider list (since calculating on the fly from now on)
# 20-Aug-2024 dwp Add support for accessing target cofactor data from MongoDB
##
"""
Resource provider for dictionary method runner and DictMethodHelper tools.
Expand Down Expand Up @@ -81,10 +82,10 @@
# ---
from rcsb.utils.targets.CARDTargetAnnotationProvider import CARDTargetAnnotationProvider
from rcsb.utils.targets.CARDTargetOntologyProvider import CARDTargetOntologyProvider
from rcsb.utils.targets.ChEMBLTargetCofactorProvider import ChEMBLTargetCofactorProvider
from rcsb.utils.targets.DrugBankTargetCofactorProvider import DrugBankTargetCofactorProvider
from rcsb.utils.targets.ChEMBLTargetCofactorProvider import ChEMBLTargetCofactorAccessor
from rcsb.utils.targets.DrugBankTargetCofactorProvider import DrugBankTargetCofactorAccessor
from rcsb.utils.targets.IMGTTargetFeatureProvider import IMGTTargetFeatureProvider
from rcsb.utils.targets.PharosTargetCofactorProvider import PharosTargetCofactorProvider
from rcsb.utils.targets.PharosTargetCofactorProvider import PharosTargetCofactorAccessor
from rcsb.utils.targets.SAbDabTargetFeatureProvider import SAbDabTargetFeatureProvider

# --
Expand Down Expand Up @@ -301,24 +302,30 @@ def __init__(self, cfgOb, **kwargs):
"buildable": True,
"providerType": "optional",
},
"DrugBankTargetCofactorProvider instance": {
"class": DrugBankTargetCofactorProvider,
"configArgMap": {},
"stashable": True,
"DrugBankTargetCofactorAccessor instance": {
"class": DrugBankTargetCofactorAccessor,
"configArgMap": {
"cfgOb": (self.__cfgOb, "value"),
},
"stashable": False,
"buildable": False,
"providerType": "optional",
},
"ChEMBLTargetCofactorProvider instance": {
"class": ChEMBLTargetCofactorProvider,
"configArgMap": {},
"stashable": True,
"ChEMBLTargetCofactorAccessor instance": {
"class": ChEMBLTargetCofactorAccessor,
"configArgMap": {
"cfgOb": (self.__cfgOb, "value"),
},
"stashable": False,
"buildable": False,
"providerType": "optional",
},
"PharosTargetCofactorProvider instance": {
"class": PharosTargetCofactorProvider,
"configArgMap": {},
"stashable": True,
"PharosTargetCofactorAccessor instance": {
"class": PharosTargetCofactorAccessor,
"configArgMap": {
"cfgOb": (self.__cfgOb, "value"),
},
"stashable": False,
"buildable": False,
"providerType": "optional",
},
Expand Down
2 changes: 1 addition & 1 deletion rcsb/utils/dictionary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
__author__ = "John Westbrook"
__email__ = "[email protected]"
__license__ = "Apache 2.0"
__version__ = "1.25"
__version__ = "1.26"
5 changes: 3 additions & 2 deletions rcsb/utils/tests-dictionary/testDictMethodResourceProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ class DictmethodResourceProviderTests(unittest.TestCase):
buildTestingCache = False

def setUp(self):
isMac = platform.system() == "Darwin"
self.__excludeTypeL = None if isMac else ["optional"]
# isMac = platform.system() == "Darwin"
# self.__excludeTypeL = None if isMac else ["optional"]
self.__excludeTypeL = ["optional"]
self.__mockTopPath = os.path.join(TOPDIR, "rcsb", "mock-data")
self.__cachePath = os.path.join(HERE, "test-output", "CACHE")
self.__configPath = os.path.join(self.__mockTopPath, "config", "dbload-setup-example.yml")
Expand Down
6 changes: 4 additions & 2 deletions rcsb/utils/tests-dictionary/testDictMethodRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@

class DictMethodRunnerTests(unittest.TestCase):
def setUp(self):
self.__isMac = platform.system() == "Darwin"
self.__excludeTypeL = None if self.__isMac else ["optional"]
# self.__isMac = platform.system() == "Darwin"
# self.__excludeTypeL = None if self.__isMac else ["optional"]
self.__isMac = False
self.__excludeTypeL = ["optional"]
self.__export = True
self.__numProc = 2
mockTopPath = os.path.join(TOPDIR, "rcsb", "mock-data")
Expand Down
5 changes: 3 additions & 2 deletions rcsb/utils/tests-dictionary/testDictMethodRunnerModels.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class DictMethodRunnerModelsTests(unittest.TestCase):
#
def setUp(self):

self.__isMac = platform.system() == "Darwin"
self.__excludeTypeL = None if self.__isMac else ["optional"]
# self.__isMac = platform.system() == "Darwin"
# self.__excludeTypeL = None if self.__isMac else ["optional"]
self.__excludeTypeL = ["optional"]
self.__export = True
self.__numProc = 2
self.__fileLimit = 5
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ rcsb.utils.chemref >= 0.91
rcsb.utils.citation >= 0.22
rcsb.utils.config >= 0.40
rcsb.utils.ec >= 0.25
rcsb.utils.io >= 1.46
rcsb.utils.io >= 1.48
rcsb.utils.multiproc >= 0.19
rcsb.utils.repository >= 0.43
rcsb.utils.seq >= 0.79
rcsb.utils.seq >= 0.82
rcsb.utils.struct >= 0.47
rcsb.utils.targets >= 0.77
rcsb.utils.targets >= 0.80
rcsb.utils.taxonomy >= 0.43
rcsb.utils.validation >= 0.31
rcsb.utils.insilico3d >= 0.38

0 comments on commit b890f54

Please sign in to comment.