def toStringOfSuperTypesNoEdges(self): string = '' superTypeDictionary = tp.SuperTypeDictionary() for i in range(0, len(self.edges)): string += superTypeDictionary.getSuperTypeFromType(utils.getNodeType(self.nodes[i], self.graph)) + ', ' # string += utils.getEdgeType(self.edges[i], self.graph) + ', ' string += superTypeDictionary.getSuperTypeFromType(utils.getNodeType(self.nodes[len(self.nodes) - 1], self.graph)) return string
def getSuperDistanceFromOtherPath(self, other): distance = 0 superTypeDictionary = tp.SuperTypeDictionary() # for i in range(0, len(self.edges)): # if not utils.getEdgeType(self.edges[i], self.graph) == utils.getEdgeType(other.edges[i], self.graph): # distance += 1 for i in range(0, len(self.nodes)): if not superTypeDictionary.getSuperTypeFromType(utils.getNodeType(self.nodes[i], self.graph)) \ == superTypeDictionary.getSuperTypeFromType(utils.getNodeType(other.nodes[i], self.graph)): distance += 1 return distance
def isSameSuperType(self, other): if (not len(self.nodes) == len(other.nodes)) or (not len(self.edges) == len(other.edges)): return False for i in range(0, len(self.edges)): if not utils.getEdgeType(self.edges[i], self.graph) == utils.getEdgeType(other.edges[i], self.graph): return False superTypeDictionary = tp.SuperTypeDictionary() for i in range(0, len(self.nodes)): if not superTypeDictionary.getSuperTypeFromType(utils.getNodeType(self.nodes[i], self.graph))\ == superTypeDictionary.getSuperTypeFromType(utils.getNodeType(other.nodes[i], self.graph)): return False return True
""" Example using the SuperTypeDictionary object. This finds a list of all nodes in the super types YAC and GAC. It then computes the percent completeness for all of these nodes. """ from tulip import * from tulipgui import * import tulippaths as tp graphFile = '../data/514_4hops.tlp' graph = tlp.loadGraph(graphFile) completeness = tp.utils.getApproximateAnnotationCompleteness(graph) superTypeDictionary = tp.SuperTypeDictionary() nodeTypes = superTypeDictionary.getTypesFromSuperTypes(['YAC', 'GAC']) nodes = tp.utils.getNodesByTypes(nodeTypes, graph) for node in nodes: print((str(tp.utils.getNodeId(node, graph)) + ', ' + str(completeness[node])))
def test_getSuperTypeFromType(self): superTypes = tp.SuperTypeDictionary() self.assertTrue(superTypes.getSuperTypeFromType('CBb4w') == 'CBb') self.assertTrue(superTypes.getSuperTypeFromType('AC') == 'YAC') self.assertFalse(superTypes.getSuperTypeFromType('CBb3m') == 'AC')
def test_getDictionary(self): superTypes = tp.SuperTypeDictionary() self.assertTrue(len(superTypes.getDictionary()) == 11)
def test_isTypeInSuperTypes(self): superTypes = tp.SuperTypeDictionary() self.assertTrue(superTypes.isTypeInSuperTypes('CBb4w', ['CBb', 'CBa'])) self.assertTrue(superTypes.isTypeInSuperTypes('AC', ['CBb', 'YAC']))
def test_isTypeInSuperType(self): superTypes = tp.SuperTypeDictionary() self.assertTrue(superTypes.isTypeInSuperType('CBb4w', 'CBb')) self.assertFalse(superTypes.isTypeInSuperType('AC', 'CBb'))
def test_getTypesFromSuperTypes(self): superTypes = tp.SuperTypeDictionary() self.assertTrue( len(superTypes.getTypesFromSuperTypes(['YAC', 'CBb'])) == 47)
def test_getTypesFromSuperType(self): superTypes = tp.SuperTypeDictionary() self.assertTrue(len(superTypes.getTypesFromSuperType('CBb')) == 26)