示例#1
0
    def testGetAdjacentCategories(self):
        """Test case -"""

        try:
            myIo = IoAdapter(raiseExceptions=True)
            self.__containerList = myIo.readFile(inputFilePath=self.__pathPdbxDictionary)
            dApi = DictionaryApi(containerList=self.__containerList, consolidate=True, verbose=self.__verbose)
            cList = dApi.getCategoryList()
            cI = {}
            for cV in cList:
                chL = dApi.getChildCategories(cV)
                pL = dApi.getParentCategories(cV)
                for ch in chL:
                    if (ch, cV) not in cI:
                        cI[(ch, cV)] = 1
                    else:
                        cI[(ch, cV)] += 1
                for pV in pL:
                    if (cV, pV) not in cI:
                        cI[(cV, pV)] = 1
                    else:
                        cI[(cV, pV)] += 1
            linkL = []
            for tup in cI:
                dD = {"source": tup[0], "target": tup[1], "type": "link"}
                linkL.append(dD)

            if self.__verbose:
                print(json.dumps(linkL, sort_keys=True, indent=4, separators=(",", ": ")))
            self.assertGreater(len(linkL), 50)

        except Exception as e:
            logger.exception("Failing with %s", str(e))
            self.fail()
示例#2
0
    def test_get_adjacent_categories(self, api_paths):
        myIo = IoAdapter(raiseExceptions=True)
        containerList = myIo.readFile(
            inputFilePath=str(api_paths['pathPdbxDictionary']))
        dApi = DictionaryApi(containerList=containerList, consolidate=True)

        cList = dApi.getCategoryList()
        cI = {}
        for c in cList:
            chL = dApi.getChildCategories(c)
            pL = dApi.getParentCategories(c)
            for ch in chL:
                if (ch, c) not in cI:
                    cI[(ch, c)] = 1
                else:
                    cI[(ch, c)] += 1
            for p in pL:
                if (c, p) not in cI:
                    cI[(c, p)] = 1
                else:
                    cI[(c, p)] += 1
        linkL = []
        for s, t in cI.keys():
            d = {'source': s, 'target': t, 'type': 'link'}
            linkL.append(d)

        assert len(linkL) > 50