rcsb.exdb 1.31__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. rcsb/__init__.py +1 -0
  2. rcsb/exdb/__init__.py +1 -0
  3. rcsb/exdb/branch/BranchedEntityExtractor.py +82 -0
  4. rcsb/exdb/branch/GlycanProvider.py +116 -0
  5. rcsb/exdb/branch/GlycanUtils.py +114 -0
  6. rcsb/exdb/branch/__init__.py +0 -0
  7. rcsb/exdb/chemref/ChemRefEtlWorker.py +118 -0
  8. rcsb/exdb/chemref/ChemRefExtractor.py +70 -0
  9. rcsb/exdb/chemref/ChemRefMappingProvider.py +139 -0
  10. rcsb/exdb/chemref/PubChemDataCacheProvider.py +372 -0
  11. rcsb/exdb/chemref/PubChemEtlWrapper.py +280 -0
  12. rcsb/exdb/chemref/PubChemIndexCacheProvider.py +638 -0
  13. rcsb/exdb/chemref/__init__.py +0 -0
  14. rcsb/exdb/citation/CitationAdapter.py +91 -0
  15. rcsb/exdb/citation/CitationExtractor.py +190 -0
  16. rcsb/exdb/citation/CitationUtils.py +51 -0
  17. rcsb/exdb/citation/__init__.py +0 -0
  18. rcsb/exdb/cli/__init__.py +0 -0
  19. rcsb/exdb/entry/EntryInfoProvider.py +148 -0
  20. rcsb/exdb/entry/__init__.py +0 -0
  21. rcsb/exdb/examples-seq/EntityInstanceExtractor.py +557 -0
  22. rcsb/exdb/examples-seq/EntityPolymerExtractor.py +544 -0
  23. rcsb/exdb/examples-seq/EntityPolymerExtractorFullTests.py +176 -0
  24. rcsb/exdb/examples-seq/ReferenceSequenceAssignmentUpdater.py +449 -0
  25. rcsb/exdb/examples-seq/ReferenceSequenceUtils.py +123 -0
  26. rcsb/exdb/examples-seq/ReferenceSequenceUtilsTests.py +109 -0
  27. rcsb/exdb/examples-seq/exampleObjectExtractor.py +109 -0
  28. rcsb/exdb/examples-seq/fixtureEntityPolymerExtractor.py +85 -0
  29. rcsb/exdb/examples-seq/testEntityInstanceExtractor.py +170 -0
  30. rcsb/exdb/examples-seq/testEntityPolymerExtractor.py +171 -0
  31. rcsb/exdb/examples-seq/testReferenceSequenceAssignmentUpdater.py +79 -0
  32. rcsb/exdb/examples-seq/testReferenceSequenceUtils.py +108 -0
  33. rcsb/exdb/seq/AnnotationExtractor.py +76 -0
  34. rcsb/exdb/seq/LigandNeighborMappingExtractor.py +84 -0
  35. rcsb/exdb/seq/LigandNeighborMappingProvider.py +106 -0
  36. rcsb/exdb/seq/PolymerEntityExtractor.py +328 -0
  37. rcsb/exdb/seq/ReferenceSequenceAnnotationAdapter.py +598 -0
  38. rcsb/exdb/seq/ReferenceSequenceAnnotationProvider.py +228 -0
  39. rcsb/exdb/seq/ReferenceSequenceAssignmentAdapter.py +534 -0
  40. rcsb/exdb/seq/ReferenceSequenceAssignmentProvider.py +388 -0
  41. rcsb/exdb/seq/ReferenceSequenceCacheProvider.py +397 -0
  42. rcsb/exdb/seq/TaxonomyExtractor.py +69 -0
  43. rcsb/exdb/seq/UniProtCoreEtlWorker.py +177 -0
  44. rcsb/exdb/seq/UniProtExtractor.py +80 -0
  45. rcsb/exdb/seq/__init__.py +0 -0
  46. rcsb/exdb/tests/TEST-EXDB-CLI-EXEC.sh +19 -0
  47. rcsb/exdb/tests/TEST-EXDB-CLI-REFSEQ-EXEC.sh +12 -0
  48. rcsb/exdb/tests/__init__.py +0 -0
  49. rcsb/exdb/tests/fixtureDictMethodResourceProvider.py +104 -0
  50. rcsb/exdb/tests/fixturePdbxLoader.py +298 -0
  51. rcsb/exdb/tests/test-data/components-abbrev.cif +2739 -0
  52. rcsb/exdb/tests/test-data/prdcc-abbrev.cif +9171 -0
  53. rcsb/exdb/tests/testAnnotationExtractor.py +79 -0
  54. rcsb/exdb/tests/testBranchedEntityExtractor.py +81 -0
  55. rcsb/exdb/tests/testChemRefLoader.py +106 -0
  56. rcsb/exdb/tests/testChemRefMappingProvider.py +95 -0
  57. rcsb/exdb/tests/testCitationAdapter.py +97 -0
  58. rcsb/exdb/tests/testCitationExtractor.py +93 -0
  59. rcsb/exdb/tests/testCitationUtils.py +92 -0
  60. rcsb/exdb/tests/testEntryInfoEtlWorkflow.py +70 -0
  61. rcsb/exdb/tests/testEntryInfoProvider.py +97 -0
  62. rcsb/exdb/tests/testGlycanEtlWorkflow.py +70 -0
  63. rcsb/exdb/tests/testGlycanProvider.py +98 -0
  64. rcsb/exdb/tests/testGlycanUtils.py +64 -0
  65. rcsb/exdb/tests/testLigandNeighborMappingProvider.py +90 -0
  66. rcsb/exdb/tests/testObjectExtractor.py +342 -0
  67. rcsb/exdb/tests/testObjectTransformer.py +83 -0
  68. rcsb/exdb/tests/testObjectUpdater.py +120 -0
  69. rcsb/exdb/tests/testPolymerEntityExtractor.py +93 -0
  70. rcsb/exdb/tests/testPubChemDataCacheProvider.py +124 -0
  71. rcsb/exdb/tests/testPubChemEtlWorkflow.py +134 -0
  72. rcsb/exdb/tests/testPubChemEtlWrapper.py +155 -0
  73. rcsb/exdb/tests/testPubChemIndexCacheProvider.py +123 -0
  74. rcsb/exdb/tests/testReferenceSequenceAnnotationAdapter.py +106 -0
  75. rcsb/exdb/tests/testReferenceSequenceAssignmentAdapter.py +121 -0
  76. rcsb/exdb/tests/testReferenceSequenceAssignmentAdapterValidate.py +122 -0
  77. rcsb/exdb/tests/testReferenceSequenceAssignmentProvider.py +117 -0
  78. rcsb/exdb/tests/testReferenceSequenceCacheProvider.py +94 -0
  79. rcsb/exdb/tests/testTaxonomyExtractor.py +75 -0
  80. rcsb/exdb/tests/testTreeNodeListWorker.py +111 -0
  81. rcsb/exdb/tests/testUniProtCoreEtlWorker.py +99 -0
  82. rcsb/exdb/tests/testUniProtExtractor.py +77 -0
  83. rcsb/exdb/tree/TreeNodeListWorker.py +228 -0
  84. rcsb/exdb/tree/__init__.py +0 -0
  85. rcsb/exdb/utils/ObjectAdapterBase.py +22 -0
  86. rcsb/exdb/utils/ObjectExtractor.py +286 -0
  87. rcsb/exdb/utils/ObjectTransformer.py +124 -0
  88. rcsb/exdb/utils/ObjectUpdater.py +121 -0
  89. rcsb/exdb/utils/ObjectValidator.py +160 -0
  90. rcsb/exdb/utils/__init__.py +0 -0
  91. rcsb/exdb/wf/EntryInfoEtlWorkflow.py +71 -0
  92. rcsb/exdb/wf/GlycanEtlWorkflow.py +76 -0
  93. rcsb/exdb/wf/PubChemEtlWorkflow.py +240 -0
  94. rcsb/exdb/wf/__init__.py +0 -0
  95. rcsb_exdb-1.31.dist-info/METADATA +103 -0
  96. rcsb_exdb-1.31.dist-info/RECORD +98 -0
  97. rcsb_exdb-1.31.dist-info/WHEEL +4 -0
  98. rcsb_exdb-1.31.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,70 @@
1
+ ##
2
+ # File: EntryInfoEtlWorkflowTests.py
3
+ # Author: J. Westbrook
4
+ # Date: 22-Sep-2021
5
+ #
6
+ # Updates:
7
+ #
8
+ ##
9
+ """
10
+ Tests for entry information extraction ETL workflow methods
11
+ """
12
+
13
+ __docformat__ = "google en"
14
+ __author__ = "John Westbrook"
15
+ __email__ = "jwest@rcsb.rutgers.edu"
16
+ __license__ = "Apache 2.0"
17
+
18
+ import logging
19
+ import os
20
+ import platform
21
+ import resource
22
+ import time
23
+ import unittest
24
+
25
+ from rcsb.exdb.wf.EntryInfoEtlWorkflow import EntryInfoEtlWorkflow
26
+
27
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s]-%(module)s.%(funcName)s: %(message)s")
28
+ logger = logging.getLogger()
29
+
30
+ HERE = os.path.abspath(os.path.dirname(__file__))
31
+ TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
32
+
33
+
34
+ class EntryInfoEtlWorkflowTests(unittest.TestCase):
35
+ def setUp(self):
36
+ #
37
+ self.__cachePath = os.path.join(HERE, "test-output", "CACHE")
38
+ self.__configPath = os.path.join(TOPDIR, "rcsb", "mock-data", "config", "dbload-setup-example.yml")
39
+ self.__configName = "site_info_configuration"
40
+ #
41
+ self.__startTime = time.time()
42
+ logger.debug("Starting %s at %s", self.id(), time.strftime("%Y %m %d %H:%M:%S", time.localtime()))
43
+
44
+ def tearDown(self):
45
+ unitS = "MB" if platform.system() == "Darwin" else "GB"
46
+ rusageMax = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
47
+ logger.info("Maximum resident memory size %.4f %s", rusageMax / 10 ** 6, unitS)
48
+ endTime = time.time()
49
+ logger.info("Completed %s at %s (%.4f seconds)", self.id(), time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - self.__startTime)
50
+
51
+ def testUpdateEntryInfo(self):
52
+ """Test case - update extracted entry-level annotations."""
53
+ try:
54
+ eiP = EntryInfoEtlWorkflow(configPath=self.__configPath, configName=self.__configName, cachePath=self.__cachePath)
55
+ ok = eiP.update(backup=False)
56
+ self.assertTrue(ok)
57
+ except Exception as e:
58
+ logger.exception("Failing with %s", str(e))
59
+ self.fail()
60
+
61
+
62
+ def entryInfoEtlWorkflowSuite():
63
+ suiteSelect = unittest.TestSuite()
64
+ suiteSelect.addTest(EntryInfoEtlWorkflowTests("testUpdateEntryInfo"))
65
+ return suiteSelect
66
+
67
+
68
+ if __name__ == "__main__":
69
+ mySuite = entryInfoEtlWorkflowSuite()
70
+ unittest.TextTestRunner(verbosity=2).run(mySuite)
@@ -0,0 +1,97 @@
1
+ ##
2
+ # File: EntryInfoProviderTests.py
3
+ # Author: J. Westbrook
4
+ # Date: 22-Sep-2021
5
+ #
6
+ # Update:
7
+ #
8
+ #
9
+ ##
10
+ """
11
+ Tests for accessors entry-level annotations.
12
+
13
+ """
14
+
15
+ __docformat__ = "google en"
16
+ __author__ = "John Westbrook"
17
+ __email__ = "jwest@rcsb.rutgers.edu"
18
+ __license__ = "Apache 2.0"
19
+
20
+ import logging
21
+ import os
22
+ import unittest
23
+
24
+ from rcsb.exdb.entry.EntryInfoProvider import EntryInfoProvider
25
+ from rcsb.utils.config.ConfigUtil import ConfigUtil
26
+
27
+ HERE = os.path.abspath(os.path.dirname(__file__))
28
+ TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
29
+
30
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s]-%(module)s.%(funcName)s: %(message)s")
31
+ logger = logging.getLogger()
32
+
33
+
34
+ class EntryInfoProviderTests(unittest.TestCase):
35
+ doInternal = False
36
+
37
+ def setUp(self):
38
+ self.__cachePath = os.path.join(HERE, "test-output", "CACHE")
39
+ #
40
+ self.__mockTopPath = os.path.join(TOPDIR, "rcsb", "mock-data")
41
+ self.__configPath = os.path.join(TOPDIR, "rcsb", "mock-data", "config", "dbload-setup-example.yml")
42
+ configName = "site_info_configuration"
43
+ self.__cfgOb = ConfigUtil(configPath=self.__configPath, defaultSectionName=configName, mockTopPath=self.__mockTopPath)
44
+ #
45
+
46
+ def tearDown(self):
47
+ pass
48
+
49
+ def testGetEntryInfo(self):
50
+ minCount = 12
51
+ eiP = EntryInfoProvider(cachePath=self.__cachePath, useCache=False)
52
+ ok = eiP.testCache(minCount=0)
53
+ self.assertTrue(ok)
54
+ ok = eiP.update(self.__cfgOb, fmt="json", indent=3)
55
+ self.assertTrue(ok)
56
+ riD = eiP.getEntryInfo("4en8")
57
+ logger.info("riD (%d) %r", len(riD), riD)
58
+ rL = eiP.getEntriesByPolymerEntityCount(count=2)
59
+ self.assertGreaterEqual(len(rL), 5)
60
+ ok = eiP.testCache(minCount=minCount)
61
+ self.assertTrue(ok)
62
+ eiP = EntryInfoProvider(cachePath=self.__cachePath, useCache=True)
63
+ ok = eiP.testCache(minCount=minCount)
64
+ self.assertTrue(ok)
65
+
66
+ @unittest.skipUnless(doInternal, "Internal full test")
67
+ def testEntryInfoRemote(self):
68
+ minCount = 182000
69
+ configName = "site_info_remote_configuration"
70
+ cfgOb = ConfigUtil(configPath=self.__configPath, defaultSectionName=configName, mockTopPath=self.__mockTopPath)
71
+ eiP = EntryInfoProvider(cachePath=self.__cachePath, useCache=True)
72
+ ok = eiP.testCache(minCount=minCount)
73
+ ok = eiP.update(cfgOb, fmt="json", indent=3)
74
+ self.assertTrue(ok)
75
+ riD = eiP.getEntryInfo("1kip")
76
+ logger.info("riD (%d)", len(riD))
77
+ self.assertGreaterEqual(len(riD), 1)
78
+ configName = "site_info_configuration"
79
+ cfgOb = ConfigUtil(configPath=self.__configPath, defaultSectionName=configName, mockTopPath=self.__mockTopPath)
80
+ ok = eiP.backup(cfgOb, configName, useStash=False, useGit=True)
81
+ self.assertTrue(ok)
82
+ ok = eiP.restore(cfgOb, configName, useStash=False, useGit=True)
83
+ self.assertTrue(ok)
84
+ eiP = EntryInfoProvider(cachePath=self.__cachePath, useCache=True)
85
+ ok = eiP.testCache(minCount=minCount)
86
+
87
+
88
+ def entryInfoSuite():
89
+ suiteSelect = unittest.TestSuite()
90
+ suiteSelect.addTest(EntryInfoProviderTests("testGetEntryInfo"))
91
+ return suiteSelect
92
+
93
+
94
+ if __name__ == "__main__":
95
+
96
+ mySuite = entryInfoSuite()
97
+ unittest.TextTestRunner(verbosity=2).run(mySuite)
@@ -0,0 +1,70 @@
1
+ ##
2
+ # File: GlycanEtlWorkflowTests.py
3
+ # Author: J. Westbrook
4
+ # Date: 30-Jun-2021
5
+ #
6
+ # Updates:
7
+ #
8
+ ##
9
+ """
10
+ Tests for Glycan ETL workflow methods
11
+ """
12
+
13
+ __docformat__ = "google en"
14
+ __author__ = "John Westbrook"
15
+ __email__ = "jwest@rcsb.rutgers.edu"
16
+ __license__ = "Apache 2.0"
17
+
18
+ import logging
19
+ import os
20
+ import platform
21
+ import resource
22
+ import time
23
+ import unittest
24
+
25
+ from rcsb.exdb.wf.GlycanEtlWorkflow import GlycanEtlWorkflow
26
+
27
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s]-%(module)s.%(funcName)s: %(message)s")
28
+ logger = logging.getLogger()
29
+
30
+ HERE = os.path.abspath(os.path.dirname(__file__))
31
+ TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
32
+
33
+
34
+ class GlycanEtlWorkflowTests(unittest.TestCase):
35
+ def setUp(self):
36
+ #
37
+ self.__cachePath = os.path.join(HERE, "test-output", "CACHE")
38
+ self.__configPath = os.path.join(TOPDIR, "rcsb", "mock-data", "config", "dbload-setup-example.yml")
39
+ self.__configName = "site_info_configuration"
40
+ #
41
+ self.__startTime = time.time()
42
+ logger.debug("Starting %s at %s", self.id(), time.strftime("%Y %m %d %H:%M:%S", time.localtime()))
43
+
44
+ def tearDown(self):
45
+ unitS = "MB" if platform.system() == "Darwin" else "GB"
46
+ rusageMax = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
47
+ logger.info("Maximum resident memory size %.4f %s", rusageMax / 10 ** 6, unitS)
48
+ endTime = time.time()
49
+ logger.info("Completed %s at %s (%.4f seconds)", self.id(), time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - self.__startTime)
50
+
51
+ def testUpdateIndex(self):
52
+ """Test case - update the glycan corrrespondence index."""
53
+ try:
54
+ gP = GlycanEtlWorkflow(configPath=self.__configPath, configName=self.__configName, cachePath=self.__cachePath)
55
+ ok = gP.updateMatchedIndex(backup=False)
56
+ self.assertTrue(ok)
57
+ except Exception as e:
58
+ logger.exception("Failing with %s", str(e))
59
+ self.fail()
60
+
61
+
62
+ def glycanEtlWorkflowSuite():
63
+ suiteSelect = unittest.TestSuite()
64
+ suiteSelect.addTest(GlycanEtlWorkflowTests("testUpdateIndex"))
65
+ return suiteSelect
66
+
67
+
68
+ if __name__ == "__main__":
69
+ mySuite = glycanEtlWorkflowSuite()
70
+ unittest.TextTestRunner(verbosity=2).run(mySuite)
@@ -0,0 +1,98 @@
1
+ ##
2
+ # File: GlycanProviderTests.py
3
+ # Author: J. Westbrook
4
+ # Date: 24-May-2021
5
+ #
6
+ # Update:
7
+ #
8
+ #
9
+ ##
10
+ """
11
+ Tests for accessors for managing Glycan extracted annotations.
12
+
13
+ """
14
+
15
+ __docformat__ = "google en"
16
+ __author__ = "John Westbrook"
17
+ __email__ = "jwest@rcsb.rutgers.edu"
18
+ __license__ = "Apache 2.0"
19
+
20
+ import logging
21
+ import os
22
+ import unittest
23
+
24
+ from rcsb.exdb.branch.GlycanProvider import GlycanProvider
25
+ from rcsb.utils.config.ConfigUtil import ConfigUtil
26
+ from rcsb.utils.io.MarshalUtil import MarshalUtil
27
+
28
+ HERE = os.path.abspath(os.path.dirname(__file__))
29
+ TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
30
+
31
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s]-%(module)s.%(funcName)s: %(message)s")
32
+ logger = logging.getLogger()
33
+
34
+
35
+ class GlycanProviderTests(unittest.TestCase):
36
+ def setUp(self):
37
+ self.__cachePath = os.path.join(HERE, "test-output", "CACHE")
38
+ self.__dataPath = os.path.join(HERE, "test-data")
39
+ self.__mU = MarshalUtil(workPath=self.__cachePath)
40
+ #
41
+ self.__mockTopPath = os.path.join(TOPDIR, "rcsb", "mock-data")
42
+ self.__configPath = os.path.join(TOPDIR, "rcsb", "mock-data", "config", "dbload-setup-example.yml")
43
+ configName = "site_info_configuration"
44
+ self.__cfgOb = ConfigUtil(configPath=self.__configPath, defaultSectionName=configName, mockTopPath=self.__mockTopPath)
45
+ #
46
+ self.__stashUrl = None
47
+ self.__stashRemotePath = os.path.join(self.__cachePath, "stash-remote")
48
+
49
+ def tearDown(self):
50
+ pass
51
+
52
+ def testGlycanMapping(self):
53
+ minCount = 12
54
+ gP = GlycanProvider(cachePath=self.__cachePath, useCache=False)
55
+ ok = gP.testCache(minCount=0)
56
+ self.assertTrue(ok)
57
+ ok = gP.update(self.__cfgOb, fmt="json", indent=3)
58
+ self.assertTrue(ok)
59
+ riD = gP.getIdentifiers()
60
+ logger.info("riD (%d)", len(riD))
61
+ ok = gP.testCache(minCount=minCount)
62
+ self.assertTrue(ok)
63
+ gP = GlycanProvider(cachePath=self.__cachePath, useCache=True)
64
+ ok = gP.testCache(minCount=minCount)
65
+ self.assertTrue(ok)
66
+
67
+ @unittest.skip("Internal test")
68
+ def testGlycanStashRemote(self):
69
+ minCount = 12
70
+ configName = "site_info_remote_configuration"
71
+ cfgOb = ConfigUtil(configPath=self.__configPath, defaultSectionName=configName, mockTopPath=self.__mockTopPath)
72
+ gP = GlycanProvider(cachePath=self.__cachePath, useCache=True)
73
+ ok = gP.testCache(minCount=minCount)
74
+ ok = gP.update(cfgOb, fmt="json", indent=3)
75
+ self.assertTrue(ok)
76
+ riD = gP.getIdentifiers()
77
+ logger.info("riD (%d)", len(riD))
78
+ self.assertTrue(ok)
79
+ ok = gP.backup(cfgOb, configName)
80
+ self.assertTrue(ok)
81
+ ok = gP.restore(cfgOb, configName)
82
+ self.assertTrue(ok)
83
+ #
84
+ ok = gP.update(cfgOb, fmt="json", indent=3)
85
+ self.assertTrue(ok)
86
+ #
87
+
88
+
89
+ def glycanMappingSuite():
90
+ suiteSelect = unittest.TestSuite()
91
+ suiteSelect.addTest(GlycanProviderTests("testGlycanMapping"))
92
+ return suiteSelect
93
+
94
+
95
+ if __name__ == "__main__":
96
+
97
+ mySuite = glycanMappingSuite()
98
+ unittest.TextTestRunner(verbosity=2).run(mySuite)
@@ -0,0 +1,64 @@
1
+ ##
2
+ # File: GlycanUtilsTests.py
3
+ # Author: J. Westbrook
4
+ # Date: 25-May-2021
5
+ #
6
+ # Update:
7
+ # 9-Feb-2023 aae Fix TOPDIR path
8
+ ##
9
+ """
10
+ Tests for creating glycan accession mapping details.
11
+ """
12
+
13
+ __docformat__ = "google en"
14
+ __author__ = "John Westbrook"
15
+ __email__ = "jwest@rcsb.rutgers.edu"
16
+ __license__ = "Apache 2.0"
17
+
18
+ import logging
19
+ import os
20
+ import unittest
21
+
22
+ from rcsb.exdb.branch.GlycanUtils import GlycanUtils
23
+ from rcsb.utils.config.ConfigUtil import ConfigUtil
24
+
25
+ HERE = os.path.abspath(os.path.dirname(__file__))
26
+ TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
27
+
28
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s]-%(module)s.%(funcName)s: %(message)s")
29
+ logger = logging.getLogger()
30
+
31
+
32
+ class GlycanUtilsTests(unittest.TestCase):
33
+ def setUp(self):
34
+ self.__dirPath = os.path.join(HERE, "test-output", "CACHE", "glycan")
35
+ #
36
+ self.__mockTopPath = os.path.join(TOPDIR, "rcsb", "mock-data")
37
+ configPath = os.path.join(TOPDIR, "rcsb", "mock-data", "config", "dbload-setup-example.yml")
38
+ configName = "site_info_configuration"
39
+ self.__cfgOb = ConfigUtil(configPath=configPath, defaultSectionName=configName, mockTopPath=self.__mockTopPath)
40
+ #
41
+
42
+ def tearDown(self):
43
+ pass
44
+
45
+ def testGlycanMapping(self):
46
+ gU = GlycanUtils(self.__cfgOb, self.__dirPath)
47
+ beD = gU.getBranchedEntityDetails()
48
+ self.assertGreaterEqual(len(beD), 1)
49
+ logger.info("branched entity descriptor details (%d)", len(beD))
50
+ eaD = gU.updateEntityAccessionMap()
51
+ logger.info("updated entity accession map length (%d)", len(eaD))
52
+ self.assertGreaterEqual(len(eaD), 12)
53
+
54
+
55
+ def glycanMappingSuite():
56
+ suiteSelect = unittest.TestSuite()
57
+ suiteSelect.addTest(GlycanUtilsTests("testGlycanMapping"))
58
+ return suiteSelect
59
+
60
+
61
+ if __name__ == "__main__":
62
+
63
+ mySuite = glycanMappingSuite()
64
+ unittest.TextTestRunner(verbosity=2).run(mySuite)
@@ -0,0 +1,90 @@
1
+ ##
2
+ # File: LigandNeighborMappingProviderTests.py
3
+ # Author: J. Westbrook
4
+ # Date: 28-Jun-2021
5
+ #
6
+ # Updates:
7
+ #
8
+ ##
9
+ """
10
+ Tests for
11
+
12
+ """
13
+
14
+ __docformat__ = "google en"
15
+ __author__ = "John Westbrook"
16
+ __email__ = "jwest@rcsb.rutgers.edu"
17
+ __license__ = "Apache 2.0"
18
+
19
+
20
+ import logging
21
+ import os
22
+ import platform
23
+ import resource
24
+ import time
25
+ import unittest
26
+
27
+ from rcsb.exdb.seq.LigandNeighborMappingProvider import LigandNeighborMappingProvider
28
+
29
+ from rcsb.utils.config.ConfigUtil import ConfigUtil
30
+
31
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s]-%(module)s.%(funcName)s: %(message)s")
32
+ logger = logging.getLogger()
33
+
34
+ HERE = os.path.abspath(os.path.dirname(__file__))
35
+ TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
36
+
37
+
38
+ class LigandNeighborMappingProviderTests(unittest.TestCase):
39
+ def __init__(self, methodName="runTest"):
40
+ super(LigandNeighborMappingProviderTests, self).__init__(methodName)
41
+ self.__verbose = True
42
+
43
+ def setUp(self):
44
+ self.__mockTopPath = os.path.join(TOPDIR, "rcsb", "mock-data")
45
+ configPath = os.path.join(TOPDIR, "rcsb", "mock-data", "config", "dbload-setup-example.yml")
46
+ configName = "site_info_configuration"
47
+ self.__cfgOb = ConfigUtil(configPath=configPath, defaultSectionName=configName, mockTopPath=self.__mockTopPath)
48
+ self.__cachePath = os.path.join(TOPDIR, "CACHE")
49
+ self.__startTime = time.time()
50
+ logger.debug("Starting %s at %s", self.id(), time.strftime("%Y %m %d %H:%M:%S", time.localtime()))
51
+
52
+ def tearDown(self):
53
+ unitS = "MB" if platform.system() == "Darwin" else "GB"
54
+ rusageMax = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
55
+ logger.info("Maximum resident memory size %.4f %s", rusageMax / 10 ** 6, unitS)
56
+ endTime = time.time()
57
+ logger.info("Completed %s at %s (%.4f seconds)", self.id(), time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - self.__startTime)
58
+
59
+ def testLigandNeighborMapping(self):
60
+ """Test case - load and access ligand neighbor mapping cache"""
61
+ try:
62
+ crmP = LigandNeighborMappingProvider(self.__cachePath, useCache=True)
63
+ ok = crmP.testCache()
64
+ self.assertTrue(ok)
65
+ #
66
+ ok = crmP.fetchLigandNeighborMapping(self.__cfgOb)
67
+ self.assertTrue(ok)
68
+ crmP = LigandNeighborMappingProvider(self.__cachePath, useCache=True)
69
+ ok = crmP.testCache(minCount=2)
70
+ self.assertTrue(ok)
71
+ nL = crmP.getLigandNeighbors("3VFJ_2")
72
+ logger.info("ligand neighbor list nL %r", nL)
73
+ self.assertGreaterEqual(len(nL), 4)
74
+ self.assertGreater(len(nL[0]), 1)
75
+ #
76
+ except Exception as e:
77
+ logger.exception("Failing with %s", str(e))
78
+ self.fail()
79
+
80
+
81
+ def ligandNeighborMappingSuite():
82
+ suiteSelect = unittest.TestSuite()
83
+ suiteSelect.addTest(LigandNeighborMappingProviderTests("testLigandNeighborMapping"))
84
+ return suiteSelect
85
+
86
+
87
+ if __name__ == "__main__":
88
+ #
89
+ mySuite = ligandNeighborMappingSuite()
90
+ unittest.TextTestRunner(verbosity=2).run(mySuite)