def testAccessEntityPolymerReadCache(self):
     """Test case - access cached entity polymer info from test cache"""
     try:
         epe = EntityPolymerExtractor(self.__cfgOb,
                                      exdbDirPath=self.__exdbCacheDirPath,
                                      useCache=False,
                                      cacheKwargs=self.__cacheKwargs)
         logger.info("Cache entry count %d", epe.getEntryCount())
         cD = epe.countRefSeqAccessions("UNP")
         self.assertGreaterEqual(len(cD), 2)
         logger.info("UNP reference sequences per entity %r",
                     dict(sorted(cD.items())))
         logger.info("Reference sequences per entity %r",
                     dict(sorted(epe.countRefSeqAccessionAny().items())))
         logger.info("Reference sequences per ref db %r",
                     dict(sorted(epe.countRefSeqAccessionDbType().items())))
         #
         ok = epe.checkRefSeqAlignRange("UNP")
         self.assertTrue(ok)
         unpL = epe.getRefSeqAccessions("UNP")
         logger.info("Unique UNP reference sequences %d", len(unpL))
         self.assertTrue(ok)
         tD = epe.getUniqueTaxons()
         logger.info("Unique taxons %d", len(tD))
         tD = epe.countRefSeqAccessionByTaxon("UNP")
         logger.info("Unique taxons %d", len(tD))
         #
     except Exception as e:
         logger.exception("Failing with %s", str(e))
         self.fail()
 def testTaxonomyEntityPolymerReadCache(self):
     """Test case - evaluate taxonomy - from full cache"""
     try:
         taxIdList = [562, 9606, 3701]
         for taxId in taxIdList:
             tU = TaxonomyUtils(taxDirPath=self.__workPath)
             tL = tU.getLineage(taxId)
             logger.info("Taxonomy lineage for %d %r", taxId, tL)
             #
             #
             epe = EntityPolymerExtractor(
                 self.__cfgOb,
                 saveCachePath=self.__fullEntitySaveCachePath,
                 useCache=True,
                 saveCacheKwargs=self.__fullCacheKwargs)
             logger.info("Cache entry count %d", epe.getEntryCount())
             logger.info(
                 "Reference sequences per ref db %r",
                 dict(sorted(epe.countRefSeqAccessionDbType().items())))
             rD = epe.countRefSeqAccessionByTaxon(dbNameList=["UNP"])
             logger.info("Unique taxons %d", len(list(rD.keys())))
             #
             numT = 0
             for tId, aL in rD.items():
                 tL = tU.getLineage(tId)
                 if taxId in tL:
                     tc = len(set(aL))
                     logger.info("Matched %5d %s (%r)", tc,
                                 tU.getScientificName(tId), tId)
                     numT += tc
             logger.info("Total matched accessions %d ", numT)
     except Exception as e:
         logger.exception("Failing with %s", str(e))
         self.fail()