def createContactMap(fileName): rules = extractRulesfromBNGL(fileName) transformationCenter = [] transformationContext = [] transformationProduct = [] actionNames = [] atomicArray = [] for idx, rule in enumerate(rules): tatomicArray, ttransformationCenter, ttransformationContext, tproductElements, tactionNames, tlabelArray = extractAtomic.extractTransformations( [rule] ) transformationCenter.append(ttransformationCenter) transformationContext.append(ttransformationContext) actionNames.append(tactionNames) atomicArray.append(tatomicArray) transformationProduct.append(tproductElements) # tatomicArray, ttransformationCenter, ttransformationContext, \ # tproductElements,tactionNames,tlabelArray = extractAtomic.extractTransformations(rules) redundantDict, patternDictList = contextAnalyzer.extractRedundantContext( rules, transformationCenter, transformationContext ) reverseRedundantDict = reverseLookup(redundantDict) for idx in range(0, len(rules)): redundantPattern = [] if idx in reverseRedundantDict: for key in reverseRedundantDict[idx]: redundantPattern.append(patternDictList[key[0]][key[1]]) redundantPatternCounter = dictionaryToCounter(redundantPattern) createMap(rules[idx], transformationProduct[idx], redundantPatternCounter, "conImg/contatMap{0}".format(idx))
def createBipartiteGraph(fileName): rules = extractRulesfromBNGL(fileName) transformationCenter, transformationContext, transformationProduct, atomicArray, actionNames = extractCenterContext( rules ) redundantDict, patternDictList = contextAnalyzer.extractRedundantContext( rules, transformationCenter, transformationContext ) reverseRedundantDict = reverseLookup(redundantDict) idx = 0 for rule, center, context, product, action, atom in zip( rules, transformationCenter, transformationContext, transformationProduct, actionNames, atomicArray ): redundantPattern = [] if idx in reverseRedundantDict: for key in reverseRedundantDict[idx]: redundantPattern.append(patternDictList[key[0]][key[1]]) redundantPatternCounter = dictionaryToCounter(redundantPattern) createRuleBiPartite( rule, center, context, product, action, atom, "img/bipartite{0}".format(idx), redundantPatternCounter ) idx += 1
def cooperativityAnalysis2(fileName): species, rules, par = extractRulesfromBNGL(fileName) transformationCenter, transformationContext, transformationProduct, atomicArray, actionNames = extractCenterContext( rules ) # group by reaction center redundantDict, patternDictList = contextAnalyzer.extractRedundantContext( rules, transformationCenter, transformationContext ) totalProcesses = 0 groupedProcesses = 0 redundantProcesses = 0 reverseRedundantDict = reverseLookup(redundantDict) totalSpaceCovered = [] both = hetero = h**o = 0 for center in redundantDict: processCount = [] reactionInCenter = len([y for x in redundantDict[center] for y in redundantDict[center][x]]) if reactionInCenter > 1 and len([x for x in center if x not in ["Add", "Delete"]]) > 1: totalSpace = analyzeSpace(center, species) totalSpaceCovered.append((totalSpace, reactionInCenter)) for rateKey in redundantDict[center]: if len([x for x in center if x not in ["Add", "Delete"]]) > 1: processCount.append(len(redundantDict[center][rateKey])) totalProcesses += len(redundantDict[center][rateKey]) if len(processCount) > 1 and any([x > 1 for x in processCount]): both += sum(processCount) elif len(processCount) > 1: hetero += sum(processCount) elif sum(processCount) > 1: h**o += sum(processCount) # totalhetero = hetero*1.0/totalProcesses if totalProcesses > 0 else 0 # totalhomo = h**o*1.0/totalProcesses if totalProcesses > 0 else 0 # totalboth = both*1.0/totalProcesses if totalProcesses > 0 else 0 # totalall = (hetero+h**o+both)*1.0/totalProcesses if totalProcesses > 0 else 0 return hetero, h**o, both, totalProcesses, totalSpaceCovered