def main(fileName,outputfilename):
    molecules,rules,_ = parseXML(fileName)
    #print '---',rules
    #createBiPartite(rules,None,'simple', 
    #                       reactionCenter=True, context=True, products=True)
    #              
    createCollapsedContact(rules,molecules,[1],outputfilename)         
示例#2
0
def processBNGL(bngl,center,context,product):
    #xml = createXML(bngl)
    xml = bngl
    _,rules = parseXML(xml)
    
    createBiPartite(rules,None,bngl, 
                           reactionCenter=center, context=context, products=product)
示例#3
0
def main2():
    number = 19
    species,rules,parameterDict,observableList= readBNGXML.parseXML('output{0}.xml'.format(number))
    graph = nx.Graph()

    simpleGraph(graph,species,observableList,number)
    nx.write_gml(graph,'graph_{0}.gml'.format(number))
示例#4
0
def main(fileName, outputfilename):
    molecules, rules, _ = parseXML(fileName)
    #print '---',rules
    #createBiPartite(rules,None,'simple',
    #                       reactionCenter=True, context=True, products=True)
    #
    createCollapsedContact(rules, molecules, [1], outputfilename)
示例#5
0
def getGraph(fileName):
    molecules, rules, _ = parseXML(fileName)
    extendedInformation = getContext(fileName)
    return collapsedContactMap.createCollapsedContact(rules, molecules, [1],
                                                      "",
                                                      extendedInformation[0],
                                                      True, True, False)
示例#6
0
def main():
    fileName = 'complex/output19.bngl'
    console.bngl2xml(fileName)
    species, rules, par = readBNGXML.parseXML('output19.xml')
    #print rules

    transformationCenter = []
    transformationContext = []

    #extract the context of such reactions
    for idx, rule in enumerate(rules):
        tatomicArray, ttransformationCenter, ttransformationContext, \
                tproductElements,tactionNames,tlabelArray = extractAtomic.extractTransformations([rule])
        #atomicArray.append(tatomicArray)
        transformationCenter.append(ttransformationCenter)
        transformationContext.append(ttransformationContext)
    redundantDict, patternDictList = extractRedundantContext(
        rules, transformationCenter, transformationContext)
    #print redundantDict
    #construct rule based patterns based on the reaction patterns they have to match and
    #the ones they  have to discriminate

    for center in patternDictList:
        for rate in patternDictList[center]:
            match = patternDictList[center][rate]
            notContext = []
            for cRate in [x for x in patternDictList[center] if x != rate]:
                notContext.append([
                    transformationContext[x]
                    for x in redundantDict[center][cRate]
                ])
            ruleSet = [rules[x] for x in redundantDict[center][rate]]
            createMetaRule(ruleSet, match)

    newRules = range(0, len(rules))
    for center in redundantDict:
        for context in redundantDict[center]:
            for element in range(1, len(redundantDict[center][context])):
                newRules.remove(redundantDict[center][context][element])

    #for element in newRules:
    #    print str(rules[element][0])

    newRulesArray = []
    for element in newRules:
        newRulesArray.append('{0}\n'.format(str(rules[element][0])))
    lines = readFile(fileName)
    startR = lines.index('begin reaction rules\n')
    endR = lines.index('end reaction rules\n')
    startP = lines.index('begin parameters\n')
    endP = lines.index('end parameters\n')

    newPar = findNewParameters(lines[startP + 1:endP], par)
    newLines = lines[0:endP] + newPar + lines[
        endP:startR + 1] + newRulesArray + lines[endR:len(lines)]

    f = open(fileName + 'reduced.bngl', 'w')
    f.writelines(newLines)
    '''
def main2():
    number = 48
    species, rules, parameterDict, observableList = readBNGXML.parseXML(
        'output{0}.xml'.format(number))
    graph = nx.Graph()

    simpleGraph(graph, species, observableList, number)
    nx.write_gml(graph, 'graph_{0}.gml'.format(number))
示例#8
0
def reactionBasedAtomizationFile(xml):
    ratomizationList = []
    ratomizationDict = defaultdict(dict)
    ratomizationListm10 = []
    ratomizationListl10 = []
    largeUseless = []
    syndelArray = []
    syndel = 0
    totalRatomizedProcesses = 0
    totalReactions = 0
    totalProcesses = 0
    validFiles = 0
    atomizedDistro = []
    nonAtomizedDistro = []
    interesting = []

    try:
        # console.bngl2xml('complex/output{0}.bngl'.format(element),timeout=10)
        try:

            _, rules, _ = readBNGXML.parseXML(xml)
        except:
            print xml
        atomizedProcesses, weight = reactionBasedAtomization(rules)
        ato, nonato = stoichiometryAnalysis(rules)
        atomizedDistro.extend(ato)
        nonAtomizedDistro.extend(nonato)
        # if (2,1) in nonato:
        #    interesting.append(element)
        score = atomizedProcesses * 1.0 / weight if weight != 0 else 0
        totalRatomizedProcesses += atomizedProcesses
        totalReactions += len(rules)
        totalProcesses += weight
        ratomizationDict[xml]["score"] = score
        ratomizationDict[xml]["weight"] = weight
        ratomizationDict[xml]["length"] = len(rules)
        if len(rules) == 0:
            ruleslen0 += 1
        syndelArray.append((len(rules) - weight) * 1.0 / len(rules))
        if score == -1:
            syndel += 1
            # ratomizationList.append([0,0,len(rules)])
        ratomizationList.append([score, weight, len(rules)])
        if len(rules) > 10:
            if weight * 1.0 / len(rules) >= 0.1 and score < 0.1:
                largeUseless.append(xml)
            ratomizationListm10.append([score, weight, len(rules)])
        else:
            ratomizationListl10.append([score, weight, len(rules)])
        # print xml,ratomizationList[-1]
        validFiles += 1
    # except (IndexError,ZeroDivisionError):
    #    syndel += 1
    #    print 'iz'
    #    continue
    except IOError:
        print "io"
    return ratomizationDict
示例#9
0
def main():
    fileName = 'complex/output19.bngl'
    console.bngl2xml(fileName)
    species,rules,par= readBNGXML.parseXML('output19.xml')
    #print rules
    
    
    transformationCenter = []
    transformationContext = []

    #extract the context of such reactions
    for idx,rule in enumerate(rules):
        tatomicArray, ttransformationCenter, ttransformationContext, \
                tproductElements,tactionNames,tlabelArray = extractAtomic.extractTransformations([rule])
    #atomicArray.append(tatomicArray)
        transformationCenter.append(ttransformationCenter)
        transformationContext.append(ttransformationContext)
    print transformationCenter[6]
    redundantDict,patternDictList = extractRedundantContext(rules,transformationCenter,transformationContext)
    print redundantDict[(('Prot(iMod~U)',), ('Prot(egfr)', 'EGFR(prot)'))]
    #print redundantDict
    #construct rule based patterns based on the reaction patterns they have to match and
    #the ones they  have to discriminate
    
    for center in patternDictList:
        for rate in patternDictList[center]:
            match = patternDictList[center][rate]
            notContext = []
            for cRate in [x for x in patternDictList[center] if x != rate]:
                notContext.append([transformationContext[x] for x in redundantDict[center][cRate]])
            ruleSet = [rules[x] for x in redundantDict[center][rate]]
            createMetaRule(ruleSet,match)
    
    
    newRules = range(0,len(rules))
    for center in redundantDict:
        for context in redundantDict[center]:
            for element in range(1,len(redundantDict[center][context])):
                newRules.remove(redundantDict[center][context][element])
    
    #for element in newRules:
    #    print str(rules[element][0])
       
    newRulesArray = []
    for element in newRules:
        newRulesArray.append('{0}\n'.format(str(rules[element][0])))
    lines = readFile(fileName)
    startR = lines.index('begin reaction rules\n')
    endR = lines.index('end reaction rules\n')
    startP = lines.index('begin parameters\n')
    endP = lines.index('end parameters\n')
    
    newPar = findNewParameters(lines[startP+1:endP],par)
    newLines = lines[0:endP] + newPar + lines[endP:startR+1] + newRulesArray + lines[endR:len(lines)]
    
    f = open(fileName + 'reduced.bngl','w')
    f.writelines(newLines)
    '''
示例#10
0
def main(fileName, outputfilename, extendedInformation, contextOnlyFlag, nullContextFlag, separateGraphsFlag, motifFlag, bipartiteFlag):
    molecules, rules, _ = parseXML(fileName)
    graph, graphDictionary = createCollapsedContact(rules, molecules, [1], outputfilename, extendedInformation,
                                                    contextOnlyFlag, nullContextFlag, separateGraphsFlag, motifFlag, bipartiteFlag)

    if separateGraphsFlag:
        for graphObject in graphDictionary:
            nx.write_gml(graphDictionary[graphObject], '{0}_{1}.gml'.format(fileName.split('.')[0], graphObject))
    else:
        nx.write_gml(graph, outputfilename)
示例#11
0
def processBNGL(bngl, center, context, product):
    #xml = createXML(bngl)
    xml = bngl
    _, rules = parseXML(xml)

    createBiPartite(rules,
                    None,
                    bngl,
                    reactionCenter=center,
                    context=context,
                    products=product)
示例#12
0
def getAtomizedRules(bngxml):
	'''
	input an xml file, return atomized rules
	'''
	_,rules = readBNGXML.parseXML(bngxml)

	print "\nChopping and atomizing rules..."
	atomizedrules = []
	for idx, [reactants, products, actions, mappings, nameDict] in enumerate(rules):
		choppedrule = chopRule(reactants, products, actions, mappings, nameDict)
		atomizedrules.append(AtomizedRule(choppedrule,reactants,products))
	print len(atomizedrules), "rules atomized."
	return atomizedrules
示例#13
0
def main(fileName):
    _,rules = parseXML(fileName)
    #createBiPartite(rules,[x for x in range(1,25)],'simple', 
    #                       reactionCenter=True, context=True, products=True)
    
    for element in range(1,20):
        print element
        try:
            createBiPartite(rules, [element], 'simple%i' % element, 
                            reactionCenter=True, context=True, products=True)
            
        except:
            print 'xxx'
            continue
示例#14
0
def addAnnotations(fileName):
    bngl2xml('{0}.bngl'.format(fileName))
    _,rules = parseXML('{0}.xml'.format(fileName))
    totalAtomic = {}
    totalCenter = []
    totalContext = []
    totalProduct = []
    for rule in rules:
        atomicArray, transformationCenter, transformationContext, \
            productElements,actionNames,labelArray = extractTransformations([rule])
        totalAtomic.update(atomicArray)
        totalCenter.append(transformationCenter)
        totalContext.append(transformationContext)
        totalProduct.append(productElements)
示例#15
0
def addAnnotations(fileName):
    bngl2xml('{0}.bngl'.format(fileName))
    _, rules = parseXML('{0}.xml'.format(fileName))
    totalAtomic = {}
    totalCenter = []
    totalContext = []
    totalProduct = []
    for rule in rules:
        atomicArray, transformationCenter, transformationContext, \
            productElements,actionNames,labelArray = extractTransformations([rule])
        totalAtomic.update(atomicArray)
        totalCenter.append(transformationCenter)
        totalContext.append(transformationContext)
        totalProduct.append(productElements)
示例#16
0
def createDataStructures(bnglContent):
    """
    create an atomized biomodels in a temporary file to obtain relevant
    bng information
    """

    pointer = tempfile.mkstemp(suffix=".bngl", text=True)
    with open(pointer[1], "w") as f:
        f.write(bnglContent)
    retval = os.getcwd()
    os.chdir(tempfile.tempdir)
    consoleCommands.bngl2xml(pointer[1])
    xmlfilename = ".".join(pointer[1].split(".")[0:-1]) + ".xml"
    os.chdir(retval)
    return readBNGXML.parseXML(xmlfilename)
示例#17
0
def main(fileName, outputfilename, extendedInformation, contextOnlyFlag,
         nullContextFlag, separateGraphsFlag, motifFlag, bipartiteFlag):
    molecules, rules, _ = parseXML(fileName)
    graph, graphDictionary = createCollapsedContact(
        rules, molecules, [1], outputfilename, extendedInformation,
        contextOnlyFlag, nullContextFlag, separateGraphsFlag, motifFlag,
        bipartiteFlag)

    if separateGraphsFlag:
        for graphObject in graphDictionary:
            nx.write_gml(
                graphDictionary[graphObject],
                '{0}_{1}.gml'.format(fileName.split('.')[0], graphObject))
    else:
        nx.write_gml(graph, outputfilename)
示例#18
0
def createDataStructures(bnglContent):
    '''
    create an atomized biomodels in a temporary file to obtain relevant 
    bng information
    '''    
    
    pointer = tempfile.mkstemp(suffix='.bngl',text=True)
    with open(pointer[1],'w') as f:
        f.write(bnglContent)    
    retval = os.getcwd()
    os.chdir(tempfile.tempdir)
    consoleCommands.bngl2xml(pointer[1])
    xmlfilename = '.'.join(pointer[1].split('.')[0:-1]) + '.xml'
    os.chdir(retval)
    return readBNGXML.parseXML(xmlfilename)
示例#19
0
def createDataStructures(bnglContent):
    '''
    create an atomized biomodels in a temporary file to obtain relevant 
    bng information
    '''

    pointer = tempfile.mkstemp(suffix='.bngl', text=True)
    with open(pointer[1], 'w') as f:
        f.write(bnglContent)
    retval = os.getcwd()
    os.chdir(tempfile.tempdir)
    consoleCommands.bngl2xml(pointer[1])
    xmlfilename = '.'.join(pointer[1].split('.')[0:-1]) + '.xml'
    os.chdir(retval)
    return readBNGXML.parseXML(xmlfilename)
示例#20
0
def main(fileName):
    _,rules = parseXML(fileName)
    #print '---',rules
    #createBiPartite(rules,None,'simple', 
    #                       reactionCenter=True, context=True, products=True)
    
    for element in [2]:
        print element
        createBiPartite(rules, [element], 'simple%i' % element, 
                    reactionCenter=True, context=True, products=True)

        try:
            createBiPartite(rules, [element], 'simple%i' % element, 
                            reactionCenter=True, context=True, products=True)
            
        except:
            print 'xxx'
            continue
示例#21
0
def reactionBasedAtomizationFile(xmlFile, outputDataFrame, options):
    """
    get atomization metrics from a bng-xml file
    """
    ratomizationDict = {}

    try:
        # console.bngl2xml('complex/output{0}.bngl'.format(element),timeout=10)
        molecules, reactions, _ = readBNGXML.parseXML(xmlFile)

        atomizedProcesses = 0
        trueProcessesCounter = 0
        for reaction in reactions:
            if '0' in  [str(x) for x in reaction[0].reactants] or '0' in \
                    [str(x) for x in reaction[0].products]:
                continue
            trueProcessesCounter += 1
            # if len([x for x in action.action if x in ['Add','Delete']]) == 0:
            #    atomizedProcesses +=1

            for action in reaction[0].actions:
                if action.action in [
                        'AddBond', 'DeleteBond', 'StateChange',
                        'ChangeCompartment'
                ]:
                    atomizedProcesses += 1
                    break

        #ato, nonato = stoichiometryAnalysis(rules)
        #atomizedDistro.extend(ato)
        #nonAtomizedDistro.extend(nonato)
        score = atomizedProcesses * 1.0 / trueProcessesCounter if trueProcessesCounter != 0 else 0

        #outputDataFrame = outputDataFrame.set_value(xmlFile,'score',score)
        #outputDataFrame = outputDataFrame.set_value(xmlFile,'lenght',len(rules))
        ccompression = len(molecules) * 1.0 / readBNGXML.getNumObservablesXML(
            xmlFile) if readBNGXML.getNumObservablesXML(xmlFile) > 0 else 1
        return xmlFile, score, len(reactions), ccompression
        #ratomizationDict['score'] = score
        #ratomizationDict['weight'] = weight
        #ratomizationDict['length'] = len(rules)
    except IOError:
        print 'io', xmlFile
示例#22
0
def reactionBasedAtomizationFile(xmlFile,outputDataFrame,options):
    """
    get atomization metrics from a bng-xml file
    """
    ratomizationDict = {}

    try:
            # console.bngl2xml('complex/output{0}.bngl'.format(element),timeout=10)
        molecules, reactions, _ = readBNGXML.parseXML(xmlFile)

        atomizedProcesses = 0
        trueProcessesCounter = 0
        for reaction in reactions:
            if '0' in  [str(x) for x in reaction[0].reactants] or '0' in \
                    [str(x) for x in reaction[0].products]:
                continue
            trueProcessesCounter += 1
            # if len([x for x in action.action if x in ['Add','Delete']]) == 0:
            #    atomizedProcesses +=1

            for action in reaction[0].actions:
                if action.action in ['AddBond', 'DeleteBond', 'StateChange', 'ChangeCompartment']:
                    atomizedProcesses += 1
                    break


        #ato, nonato = stoichiometryAnalysis(rules)
        #atomizedDistro.extend(ato)
        #nonAtomizedDistro.extend(nonato)
        score = atomizedProcesses * 1.0 / trueProcessesCounter if trueProcessesCounter != 0 else 0

        #outputDataFrame = outputDataFrame.set_value(xmlFile,'score',score)
        #outputDataFrame = outputDataFrame.set_value(xmlFile,'lenght',len(rules))
        ccompression = len(molecules)*1.0/readBNGXML.getNumObservablesXML(xmlFile) if readBNGXML.getNumObservablesXML(xmlFile) > 0 else 1
        return xmlFile,score,len(reactions),ccompression
        #ratomizationDict['score'] = score
        #ratomizationDict['weight'] = weight
        #ratomizationDict['length'] = len(rules)
    except IOError:
        print 'io',xmlFile
示例#23
0
def spaceCoveredCDF():
    spaceCoveredArray = []
    atomizationDict = {}
    with open("sortedD.dump", "rb") as f:
        atomizationStats = pickle.load(f)
    for element in atomizationStats:
        try:
            atomizationDict[element["index"]] = element["atomization"]
        except:
            continue

    for element in range(1, 491):
        try:
            if element in atomizationDict and atomizationDict[element] > 0:
                console.bngl2xml("complex/output{0}.bngl".format(element), timeout=10)
                species, _, _ = readBNGXML.parseXML("output{0}.xml".format(element))
                observablesLen = readBNGXML.getNumObservablesXML("output{0}.xml".format(element))
                try:
                    spaceCoveredArray.append([atomizationDict[element], spaceCovered(species, observablesLen)])
                    print element, spaceCoveredArray[-1]
                except CycleError:
                    spaceCoveredArray.append([atomizationDict[element], 0])
                    print element, -1

        except (IOError, IndexError):
            print
            continue

    with open("spaceCovered.dump", "wb") as f:
        pickle.dump(spaceCoveredArray, f)
    atomization, space = zip(*spaceCoveredArray)
    heatmap, xedges, yedges = np.histogram2d(space, atomization, bins=8)
    extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
    plt.clf()
    plt.imshow(heatmap, extent=extent)
    plt.xlabel("space")
    plt.ylabel("atomization")
    plt.show()

    plt.savefig("spaceCovered.png")
示例#24
0
def main(fileName):
    _, rules = parseXML(fileName)
    #print '---',rules
    #createBiPartite(rules,None,'simple',
    #                       reactionCenter=True, context=True, products=True)

    for element in [2]:
        print element
        createBiPartite(rules, [element],
                        'simple%i' % element,
                        reactionCenter=True,
                        context=True,
                        products=True)

        try:
            createBiPartite(rules, [element],
                            'simple%i' % element,
                            reactionCenter=True,
                            context=True,
                            products=True)

        except:
            print 'xxx'
            continue
示例#25
0
	bpg1.add_argument('--omit-products',help='Omit product relationships on the bipartite graph',action='store_true',dest='no_p')
	bpg1.add_argument('--omit-contexts',help='Omit context relationships on the bipartite graph',action='store_true',dest='no_c')
	bpg_parser.add_argument('--use-annot',help='Use annotations instead of code',action='store_true',dest='use_annot')
	bpg_parser.add_argument('--filter',help='Textfile with list of patterns',required=False,dest='filter')
	bpg_parser.add_argument('--level',help='Depth to filter pattern list',required=False,dest='level',type=int)
	

	g1 = parser.add_argument_group('required arguments')
	g1.add_argument('-xml',dest='xml',required=True)
	
	args = parser.parse_args()
	
	
	if(os.path.isfile(args.xml)):
		# This generates all the pattern and transformation arrays and dictionaries
		_,rules = parseXML(args.xml)
		
		
		#rewrite required here:
		atomicArray = extractAtomicArray(rules)

			
		atomicArray, transformationCenter, transformationContext, productElements,actionName,label = extractTransformations(rules)
		
		
			
		
		patternDict,transformationDict = createDictionaries(atomicArray,transformationCenter,productElements)
		

		# This lets you create new empty annotation files
示例#26
0
def getGraph(fileName):
    molecules, rules, _ = parseXML(fileName)
    extendedInformation = getContext(fileName)
    return collapsedContactMap.createCollapsedContact(
        rules, molecules, [1], "", extendedInformation[0], True, True, False
    )
示例#27
0
def readXML(fileName):
    #consoleCommands.bngl2xml(fileName)
    fileName = '.'.join(fileName.split('.')[:-1]) + '.xml'
    return readBNGXML.parseXML(fileName)
示例#28
0
def reactionBasedAtomizationDistro(directory):
    """
    calculates a rection atomization based metric:
    ration of atomized reactions (non syndeg) in a model
    """
    ratomizationList = []
    ratomizationDict = defaultdict(dict)
    ratomizationListm10 = []
    ratomizationListl10 = []
    largeUseless = []
    syndelArray = []
    syndel = 0
    totalRatomizedProcesses = 0
    totalReactions = 0
    totalProcesses = 0
    validFiles = 0
    atomizedDistro = []
    nonAtomizedDistro = []
    interesting = []

    bnglFiles = getValidFiles(directory, "bngl")
    """
    print 'converting bnglfiles'
    progress = progressbar.ProgressBar()
    for i in progress(range(len(bnglFiles))):
        console.bngl2xml(bnglFiles[i],timeout=10)
    """

    print "moving xml files"
    files = glob.iglob(os.path.join(".", "*.xml"))
    for xmlfile in files:
        if os.path.isfile(xmlfile):
            shutil.move(xmlfile, directory)

    print "reading files"
    xmlFiles = getValidFiles(directory, "xml")

    print "analyzing {0} xml files".format(len(xmlFiles))
    progress = progressbar.ProgressBar()
    ruleslen0 = 0
    for i in progress(range(len(xmlFiles))):

        xml = xmlFiles[i]
        # for xml in xmlFiles:
        try:
            # console.bngl2xml('complex/output{0}.bngl'.format(element),timeout=10)
            try:

                _, rules, _ = readBNGXML.parseXML(xml)
            except:
                print xml
                continue
            atomizedProcesses, weight = reactionBasedAtomization(rules)
            ato, nonato = stoichiometryAnalysis(rules)
            atomizedDistro.extend(ato)
            nonAtomizedDistro.extend(nonato)
            # if (2,1) in nonato:
            #    interesting.append(element)
            score = atomizedProcesses * 1.0 / weight if weight != 0 else 0
            totalRatomizedProcesses += atomizedProcesses
            totalReactions += len(rules)
            totalProcesses += weight
            ratomizationDict[xml]["score"] = score
            ratomizationDict[xml]["weight"] = weight
            ratomizationDict[xml]["length"] = len(rules)
            if len(rules) == 0:
                ruleslen0 += 1
                continue
            syndelArray.append((len(rules) - weight) * 1.0 / len(rules))
            if score == -1:
                syndel += 1
                # ratomizationList.append([0,0,len(rules)])
                continue
            ratomizationList.append([score, weight, len(rules)])
            if len(rules) > 10:
                if weight * 1.0 / len(rules) >= 0.1 and score < 0.1:
                    largeUseless.append(xml)
                ratomizationListm10.append([score, weight, len(rules)])
            else:
                ratomizationListl10.append([score, weight, len(rules)])
            # print xml,ratomizationList[-1]
            validFiles += 1
        # except (IndexError,ZeroDivisionError):
        #    syndel += 1
        #    print 'iz'
        #    continue
        except IOError:
            print "io"
            continue
    with open("ratomizationp2m.dump", "wb") as f:
        pickle.dump(ratomizationDict, f)

    print "{0} models with 0 rules".format(ruleslen0)
    print "generating figures for {0} models".format(len(ratomizationList))
    print "-----"
    print "atomized", Counter(atomizedDistro)
    print "nonatomized", Counter(nonAtomizedDistro)
    print "models with 2->1 non atomized reactions", interesting
    with open("nonatomizedreactions.dump", "wb") as f:
        pickle.dump(generalSignature, f)
    ratomization, weights, length = zip(*ratomizationList)

    ratomizationm10, weightsm10, lengthm10 = zip(*ratomizationListm10)
    ratomizationl10, weightsl10, lengthl10 = zip(*ratomizationListl10)

    constructHistogram(
        syndelArray,
        "syndelHist",
        "Fraction of synthesis and degradation reactions",
        np.ones(len(syndelArray)),
        normed=False,
    )
    constructHistogram(
        ratomization,
        "ratomizationHist",
        "Reaction atomization level ({0} models)".format(len(ratomization)),
        np.ones(len(ratomization)),
        normed=False,
    )
    constructHistogram(
        ratomizationm10,
        "ratomizationwHist_m10",
        "Reaction atomization level ({0} models)".format(len(ratomizationm10)),
        lengthm10,
        normed=True,
    )
    weights = np.array(weights)
    length = np.array(length)
    tmp = weights * 1.0 / length

    # ratomizationWP1 = [x for x,y in zip(ratomization,tmp) if y < 0.1]
    # ratomizationWP10 = [x for x,y,z in zip(ratomization,tmp,length) if y >= 0.1 and z<10]
    # ratomizationWP11 = [x for x,y,z in zip(ratomization,tmp,length) if y >= 0.1 and z>=10]

    # constructHistogram(ratomizationWP1,'ratomizationWP1','Reaction atomization level',np.ones(len(ratomizationWP1)),normed=False)
    # constructHistogram(ratomizationWP10,'ratomizationWP10','Reaction atomization level',np.ones(len(ratomizationWP10)),normed=False)
    # constructHistogram(ratomizationWP11,'ratomizationWP11','Reaction atomization level',np.ones(len(ratomizationWP11)),normed=False)

    print "process={0}, rprocess={1}, reactions = {2},syndel={3},valid={4}".format(
        totalProcesses, totalRatomizedProcesses, totalReactions, syndel, validFiles
    )

    tmp2 = zip(ratomization, tmp)
    tmp2.sort(key=lambda x: x[0])

    # heatmap showing histogram of atomization vs non syn-deg
    heatmap, xedges, yedges = np.histogram2d(tmp, ratomization, bins=6)
    heatmap = np.log2(heatmap)

    extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
    heatmap[heatmap < 0] = 0
    plt.clf()
    plt.imshow(heatmap, extent=extent, aspect="auto", origin="lower", interpolation="nearest")
    plt.xlabel("Atomization level")
    plt.ylabel("Percentage of non syn-del reactions")
    cb = plt.colorbar()
    cb.set_label("log2(Number of models)")
    plt.show()
    plt.savefig("atomizationHeatMap.png")

    plt.clf()
    plt.scatter(tmp, ratomization)
    plt.ylabel("Atomization level", fontsize=24)
    plt.xlabel("Percentage of non syn=del reactions", fontsize=24)
    plt.savefig("atomizationScatterplot.png")

    # heatmap showing average atomization of %syn-def vs model size
    ratomizationHeatmapCounter = defaultdict(lambda: defaultdict(list))
    _, bin_edges = np.histogram(length, 4)
    digitizedLength = np.digitize(length, bin_edges)
    _, bin_edges2 = np.histogram(tmp, 4)
    digitizedSynDeg = np.digitize(tmp, bin_edges2)
    for rat, wei, leng in zip(ratomization, digitizedLength, digitizedSynDeg):
        ratomizationHeatmapCounter[wei][leng].append(rat)
    ratomizationHeatmap = np.zeros([5, 5])
    for xelement in ratomizationHeatmapCounter:
        for yelement in ratomizationHeatmapCounter[xelement]:

            ratomizationHeatmap[xelement - 1][yelement - 1] = np.mean(ratomizationHeatmapCounter[xelement][yelement])
            ratomizationHeatmapCounter[xelement][yelement] = np.mean(ratomizationHeatmapCounter[xelement][yelement])

    heatmap, xedges, yedges = np.histogram2d(length, tmp, bins=5)
    heatmap = np.log2(heatmap)

    plt.clf()
    plt.hist(length, bins=10 ** np.linspace(np.log10(1), np.log10(1000), 40))
    plt.xscale("log")
    plt.xlabel("Number of reactions ({0} models)".format(len(length)), fontsize=18)
    plt.savefig("numberOfReactionsHist.png")

    plt.clf()
    ax = plt.gca()
    ax.plot(length, 1 - tmp, "o", alpha=0.5)
    plt.xlabel("Number of reactions", fontsize=24)
    plt.ylabel("Fraction of syndel reactions", fontsize=24)
    ax.grid(True)
    ax.set_xscale("log")
    # ax.set_autoscale_on(False)
    plt.ylim([-0.1, 1.1])
    # ax.set_yscale('log')
    plt.savefig("reactionsvsnsyndel.png")

    plt.clf()
    plt.scatter(length, 1 - tmp, s=40, c=[max(x, 0) for x in ratomization])
    plt.xlabel("Number of reactions", fontsize=24)
    plt.ylabel("Fracion of syndel reactions", fontsize=24)

    ax = plt.gca()
    # ax.set_xscale('log')
    ax.grid(True)
    plt.xlim(xmin=0, xmax=100)
    plt.gray()
    cb = plt.colorbar()
    cb.set_label("Atomization level")

    plt.savefig("reactionsvssyndelwlinear.png")

    plt.clf()
    plt.imshow(ratomizationHeatmap, extent=extent, aspect="auto", origin="lower", interpolation="nearest")
    plt.xlabel("Fraction of non syn-del reactionsModel size")
    plt.ylabel("Model Size (reactions)")
    cb = plt.colorbar()
    cb.set_label("Atomization level")
    plt.show()
    plt.savefig("atomizationHeatMap2.png")

    heatmap[heatmap < 0] = 0
    plt.clf()
    plt.imshow(heatmap, extent=extent, aspect="auto", origin="lower", interpolation="nearest")
    plt.ylabel("Model size (reactions)")
    plt.xlabel("Percentage of non syn-del reactions")
    cb = plt.colorbar()
    cb.set_label("log2(Number of models)")
    plt.show()
    plt.savefig("atomizationHeatMap3.png")

    plt.clf()
    plt.scatter(length, tmp)
    plt.xlabel("Number of reactions", fontsize=24)
    plt.xscale("log")
    plt.ylabel("Atomization level", fontsize=24)
    plt.savefig("scatterreactionsvslevel.png")

    ratomization = np.sort(ratomization)
    ratomizationm10 = np.sort(ratomizationm10)
    ratomizationl10 = np.sort(ratomizationl10)

    yvals = np.arange(len(ratomization)) / float(len(ratomization))
    plotresults(
        ratomization, yvals, "ratomizationw", "Reaction atomization level ({0} models)".format(len(ratomizationList))
    )
    yvals = np.arange(len(ratomizationm10)) / float(len(ratomizationm10))
    plotresults(
        ratomizationm10,
        yvals,
        "ratomization_m10w",
        "Reaction atomization level >10 reactions({0} models)".format(len(ratomizationListm10)),
    )
    yvals = np.arange(len(ratomizationl10)) / float(len(ratomizationl10))
    plotresults(
        ratomizationl10,
        yvals,
        "ratomization_l10w",
        "Reaction atomization level <=10 reactions({0} models)".format(len(ratomizationListl10)),
    )
    print "syndel", syndel
    print ">10 with 0", largeUseless
示例#29
0
def readXML(fileName):
    #consoleCommands.bngl2xml(fileName)
    fileName = '.'.join(fileName.split('.')[:-1]) + '.xml'
    return readBNGXML.parseXML(fileName)
示例#30
0
                getMapping(rule.mapping, action.site1),
                getMapping(rule.mapping, action.site2)
            ]
            atomic, rc, _ = extractMolecules(action.action, productSites[0],
                                             productSites[1], rule.products,
                                             differentiateDimers)
            productElements.append(rc)
            atomicArray.update(atomic)
            actionName.append('%i-%s' % (index, action.action))
            r = '+'.join([str(x) for x in rule.reactants])
            p = '+'.join([str(x) for x in rule.products])
            label.append('->'.join([r, p, '%i-%s' % (index, action.action)]))

    solveWildcards(atomicArray)
    return (atomicArray, transformationCenter, transformationContext,
            productElements, actionName, label)


if __name__ == "__main__":
    import readBNGXML
    _, rules, _ = readBNGXML.parseXML('output48.xml')
    for idx, rule in enumerate(rules):
        tatomicArray, ttransformationCenter, ttransformationContext, \
            tproductElements, tactionNames, tlabelArray = extractTransformations(
                [rule], True)
        if rule[0].label == '_reverse_v7':
            print str(rule[0])
            print ttransformationContext
            print tproductElements
            raise Exception
示例#31
0
def extractRulesfromBNGL(fileName):
    # console.bngl2xml('complex/{0}.bngl'.format(fileName),timeout=10)
    species, rules, par = readBNGXML.parseXML(fileName)
    return species, rules, par
示例#32
0
def main(fileName,outputfilename,extendedInformation):
    molecules,rules,_ = parseXML(fileName)
    createCollapsedContact(rules,molecules,[1],outputfilename,extendedInformation)         
示例#33
0
def extractStatistics():
    number = 151
    console.bngl2xml('complex/output{0}.bngl'.format(number))
    species, rules, parameterDict = readBNGXML.parseXML(
        'output{0}.xml'.format(number))
    #print rules

    transformationCenter = []
    transformationContext = []

    k = []
    actions = Counter()
    actionSet = Counter()
    for idx, rule in enumerate(rules):
        tatomicArray, ttransformationCenter, ttransformationContext, \
                tproductElements,tactionNames,tlabelArray = extractAtomic.extractTransformations([rule])
        #atomicArray.append(tatomicArray)
        transformationCenter.append(ttransformationCenter)
        transformationContext.append(ttransformationContext)
        k.append(len(rule[0].actions))
        #if len(rule[0].actions) > 3:
        #    print rule[0].reactants
        actions.update([x.action for x in rule[0].actions])
        tmp = [x.action for x in rule[0].actions]
        tmp.sort()
        actionSet.update([tuple(tmp)])

    #print actions
    #print actionSet
    print 'number of species', len(species)
    print 'avg number o actions', np.average(k), np.std(k)
    centerDict = groupByReactionCenter(transformationCenter)
    print 'singletons', len(
        {x: centerDict[x]
         for x in centerDict if len(centerDict[x]) == 1})
    tmp = [[tuple(set(x)), len(centerDict[x])] for x in centerDict]
    #reactionCenterGraph(species,tmp)
    #tmp.sort(key=lambda x:x[1],reverse=True)
    print 'number of reaction centers', len(centerDict.keys())
    print 'number of rules', len(rules)

    #print 'unique',[x for x in centerDict[element] if len(centerDict[element]) == 1]
    redundantDict = groupByReactionCenterAndRateAndActions(rules, centerDict)
    #print redundantDict
    tmp2 = [('$\\tt{{{0}}}$'.format(tuple(set(x))), tuple(set(y[:-1])), y[-1],
             len(redundantDict[x][y])) for x in redundantDict
            for y in redundantDict[x] if 'kr' not in y[-1]]
    tmp2 = set(tmp2)
    tmp2 = list(tmp2)
    tmp2.sort(key=lambda x: x[3], reverse=True)
    tmp2.sort(key=lambda x: x[0], reverse=True)

    tmp2 = [
        '{0} & {1} & {2} & {3}\\\\\n'.format(element[0], element[1],
                                             element[2], element[3])
        for element in tmp2
    ]

    with open('table.tex', 'w') as f:
        f.write('\\begin{tabular}{|cccc|}\n')
        f.write('\\hline\n')
        f.write('Reaction Centers & Action & Score\\\\\\hline\n')
        for element in tmp2:
            f.write(element)
        f.write('\\hline\n')
        f.write('\\end{tabular}\n')

    #print redundantDict
    x = [len(centerDict[x]) for x in centerDict]
    #122,138
    print 'average number of reactions with same rate and reaction cneter', np.average(
        x), np.std(x)
    print 'total number of clusters', len(x)
    print x
示例#34
0
def extractStatistics():
    number = 151
    console.bngl2xml('complex/output{0}.bngl'.format(number))
    species,rules,parameterDict= readBNGXML.parseXML('output{0}.xml'.format(number))
    #print rules
    
    
    transformationCenter = []
    transformationContext = []

    k = []
    actions = Counter()
    actionSet = Counter()
    for idx,rule in enumerate(rules):
        tatomicArray, ttransformationCenter, ttransformationContext, \
                tproductElements,tactionNames,tlabelArray = extractAtomic.extractTransformations([rule])
    #atomicArray.append(tatomicArray)
        transformationCenter.append(ttransformationCenter)
        transformationContext.append(ttransformationContext)
        k.append(len(rule[0].actions))
        #if len(rule[0].actions) > 3:
        #    print rule[0].reactants
        actions.update([x.action for x in rule[0].actions])
        tmp = [x.action for x in rule[0].actions]
        tmp.sort()
        actionSet.update([tuple(tmp)])
    
    
    #print actions
    #print actionSet
    print 'number of species',len(species)
    print 'avg number o actions',np.average(k),np.std(k)
    centerDict = groupByReactionCenter(transformationCenter)
    print 'singletons',len({x:centerDict[x] for x in centerDict if len(centerDict[x]) == 1})
    tmp = [[tuple(set(x)),len(centerDict[x])] for x in centerDict]
    #reactionCenterGraph(species,tmp)
    #tmp.sort(key=lambda x:x[1],reverse=True)
    print 'number of reaction centers',len(centerDict.keys())
    print 'number of rules',len(rules)
    
    #print 'unique',[x for x in centerDict[element] if len(centerDict[element]) == 1]
    redundantDict = groupByReactionCenterAndRateAndActions(rules,centerDict)
    #print redundantDict
    tmp2 = [('$\\tt{{{0}}}$'.format(tuple(set(x))),tuple(set(y[:-1])),y[-1],len (redundantDict[x][y])) for x in redundantDict for y in redundantDict[x] if 'kr' not in y[-1]]
    tmp2 = set(tmp2)
    tmp2 = list(tmp2)
    tmp2.sort(key=lambda x:x[3],reverse=True)
    tmp2.sort(key=lambda x:x[0],reverse=True)

    tmp2 = ['{0} & {1} & {2} & {3}\\\\\n'.format(element[0],element[1],element[2],element[3]) for element in tmp2]
    
    with open('table.tex','w') as f:
        f.write('\\begin{tabular}{|cccc|}\n')
        f.write('\\hline\n')
        f.write('Reaction Centers & Action & Score\\\\\\hline\n')
        for element in tmp2:
            f.write(element)
        f.write('\\hline\n')
        f.write('\\end{tabular}\n')

    #print redundantDict
    x = [len(centerDict[x]) for x in centerDict]    
    #122,138
    print 'average number of reactions with same rate and reaction cneter',np.average(x),np.std(x) 
    print 'total number of clusters',len(x)
    print x
示例#35
0
def main():
    with open('linkArray.dump', 'rb') as f:
        linkArray = pickle.load(f)
    with open('xmlAnnotationsExtended.dump', 'rb') as f:
        annotations = pickle.load(f)

    speciesEquivalence = {}
    onlyDicts = [x for x in listdir('./complex')]
    onlyDicts = [x for x in onlyDicts if '.bngl.dict' in x]

    for x in onlyDicts:
        with open('complex/{0}'.format(x), 'rb') as f:
            speciesEquivalence[int(x.split('.')[0][6:])] = pickle.load(f)

    for cidx, cluster in enumerate(linkArray):
        #FIXME:only do the first cluster
        cidx = 0
        cluster = linkArray[0]
        if len(cluster) == 1:
            continue
        annotationsDict = {idx: x for idx, x in enumerate(annotations)}
        annotationsIncidence = {}

        #get the model intersection points

        for element in annotationsDict:
            for species in annotationsDict[element]:
                key = annotationsDict[element][species][1]
                if key not in annotationsIncidence:
                    annotationsIncidence[key] = set([])
                annotationsIncidence[key].add(element)

        #number = 19
        graph = nx.Graph()
        nodeDict = {}
        superNodeDict = {}

        for element in annotationsIncidence:
            if len(annotationsIncidence[element]) > 1:
                tmpEdgeList = []
                names = []
                for idx in annotationsIncidence[element]:
                    for species in [
                            x for x in annotationsDict[idx]
                            if annotationsDict[idx][x][1] == element
                    ]:
                        try:
                            print speciesEquivalence[idx]
                            if isinstance(speciesEquivalence[idx][species],
                                          str):
                                tmpEdgeList.append('{0}_{1}'.format(
                                    idx,
                                    speciesEquivalence[idx][species][0:-2]))
                                names.append(
                                    speciesEquivalence[idx][species][0:-2])
                            else:
                                tmpEdgeList.append('{0}_{1}'.format(
                                    idx, speciesEquivalence[idx]
                                    [species].molecules[0].name))
                                names.append(speciesEquivalence[idx]
                                             [species].molecules[0].name)
                        except:

                            print '----', 'error', idx, species
                            pass
                names = [x.lower() for x in names]
                name = Counter(names).most_common(5)
                name = [x for x in name if len(x[0]) > 1]
                if len(name) == 0:
                    name = Counter(names).most_common(1)
                for edge in tmpEdgeList:
                    superNodeDict[edge] = name[0][0]
                if len(name) > 0:
                    superNodeDict[name[0][0]] = len(tmpEdgeList)
                #pairs = [(x,y,1) for x in tmpEdgeList for y in tmpEdgeList if x!= y]
                #graph.add_weighted_edges_from(pairs)
        print superNodeDict
        for x in cluster:
            number = x - 1
            try:
                console.bngl2xml('complex/output{0}.bngl'.format(number))
                species, rules, parameterDict, observableList = readBNGXML.parseXML(
                    'output{0}.xml'.format(number))

            except:
                continue
            nodeDict[number] = simpleGraph(graph, species, observableList,
                                           number, superNodeDict)

        nx.write_gml(graph, 'cgraph_{0}.gml'.format(cidx))
        break
示例#36
0
            transformationContext.append(context)
            atomicArray.update(atomic)
            productSites = [getMapping(rule.mapping, action.site1), getMapping(rule.mapping, action.site2)]
            atomic, rc, _ = extractMolecules(
                action.action, productSites[0], productSites[1], rule.products, differentiateDimers
            )
            productElements.append(rc)
            atomicArray.update(atomic)
            actionName.append("%i-%s" % (index, action.action))
            r = "+".join([str(x) for x in rule.reactants])
            p = "+".join([str(x) for x in rule.products])
            label.append("->".join([r, p, "%i-%s" % (index, action.action)]))

    solveWildcards(atomicArray)
    return (atomicArray, transformationCenter, transformationContext, productElements, actionName, label)


if __name__ == "__main__":
    import readBNGXML

    _, rules, _ = readBNGXML.parseXML("output48.xml")
    for idx, rule in enumerate(rules):
        tatomicArray, ttransformationCenter, ttransformationContext, tproductElements, tactionNames, tlabelArray = extractTransformations(
            [rule], True
        )
        if rule[0].label == "_reverse_v7":
            print str(rule[0])
            print ttransformationContext
            print tproductElements
            raise Exception
示例#37
0
def main():
    with open('linkArray.dump', 'rb') as f:
        linkArray = pickle.load(f)
    with open('xmlAnnotationsExtended.dump','rb') as f:
        annotations = pickle.load(f)
        
    speciesEquivalence = {}
    onlyDicts = [ x for x in listdir('./complex')]
    onlyDicts = [x for x in onlyDicts if '.bngl.dict' in x]

    for x in onlyDicts:
        with open('complex/{0}'.format(x),'rb') as f:
            speciesEquivalence[int(x.split('.')[0][6:])] = pickle.load(f)
        
    
    for cidx,cluster in enumerate(linkArray):
        #FIXME:only do the first cluster
        cidx = 1
        cluster = linkArray[1]
        if len(cluster) == 1:
            continue
        annotationsDict = {idx:x for idx,x in enumerate(annotations)}
        annotationsIncidence = {}

        #get the model intersection points

        for element in annotationsDict:
            for species in annotationsDict[element]:
                key = annotationsDict[element][species][1]
                if key not in annotationsIncidence:
                    annotationsIncidence[key] = set([])
                annotationsIncidence[key].add(element)

        #number = 19
        graph = nx.Graph()
        nodeDict = {}
        superNodeDict = {}
    
        for element in annotationsIncidence:
            if len(annotationsIncidence[element]) > 1:
                tmpEdgeList = []
                names= []
                for idx in annotationsIncidence[element]:
                    for species in [x for x in annotationsDict[idx] if annotationsDict[idx][x][1] == element]:
                         try:
                             if isinstance(speciesEquivalence[idx][species],str):
                                 tmpEdgeList.append('{0}_{1}'.format(idx,speciesEquivalence[idx][species][0:-2]))
                                 names.append(speciesEquivalence[idx][species][0:-2])
                             else:
                                 tmpEdgeList.append('{0}_{1}'.format(idx,speciesEquivalence[idx][species].molecules[0].name))
                                 names.append(speciesEquivalence[idx][species].molecules[0].name)
                         except:
                            print 'error',idx,species
                names = [x.lower() for x in names]
                name =  Counter(names).most_common(5)
                name = [x for x in name if len(x[0])> 1]
                if len(name) == 0:
                    name = Counter(names).most_common(1)
                for edge in tmpEdgeList:
                    superNodeDict[edge] = name[0][0]
                if len(name) > 0:
                    superNodeDict[name[0][0]] = len(tmpEdgeList)
                #pairs = [(x,y,1) for x in tmpEdgeList for y in tmpEdgeList if x!= y] 
                #graph.add_weighted_edges_from(pairs)
        print superNodeDict
        for x in cluster:
            number = x-1
            try:
                console.bngl2xml('complex/output{0}.bngl'.format(number))
                species,rules,parameterDict,observableList= readBNGXML.parseXML('output{0}.xml'.format(number))
                
            except:
                continue
            nodeDict[number] = simpleGraph(graph,species,observableList,number,superNodeDict)
            
            
    
       
       
        
                        
        nx.write_gml(graph,'cgraph_{0}.gml'.format(cidx))
        break
示例#38
0
    solveWildcards(atomicArray)
    return (
        atomicArray,
        transformationCenter,
        transformationContext,
        productElements,
        actionName,
        label,
    )


if __name__ == "__main__":
    import readBNGXML

    _, rules, _ = readBNGXML.parseXML("output48.xml")
    for idx, rule in enumerate(rules):
        (
            tatomicArray,
            ttransformationCenter,
            ttransformationContext,
            tproductElements,
            tactionNames,
            tlabelArray,
        ) = extractTransformations([rule], True)
        if rule[0].label == "_reverse_v7":
            print(str(rule[0]))
            print(ttransformationContext)
            print(tproductElements)
            raise Exception
示例#39
0
                            required=False,
                            dest='filter')
    bpg_parser.add_argument('--level',
                            help='Depth to filter pattern list',
                            required=False,
                            dest='level',
                            type=int)

    g1 = parser.add_argument_group('required arguments')
    g1.add_argument('-xml', dest='xml', required=True)

    args = parser.parse_args()

    if (os.path.isfile(args.xml)):
        # This generates all the pattern and transformation arrays and dictionaries
        _, rules = parseXML(args.xml)

        #rewrite required here:
        atomicArray = extractAtomicArray(rules)

        atomicArray, transformationCenter, transformationContext, productElements, actionName, label = extractTransformations(
            rules)

        patternDict, transformationDict = createDictionaries(
            atomicArray, transformationCenter, productElements)

        # This lets you create new empty annotation files
        if args.mode == 'annotate':
            getStats(rules, patternDict, transformationDict)
            print "\n\nAnnotate mode."
            if args.verbose:
示例#40
0
        index += 1
        for action in rule.actions:
            atomic, reactionCenter, context = extractMolecules(action.action, action.site1, action.site2, rule.reactants, differentiateDimers)
            transformationCenter.append(reactionCenter)
            transformationContext.append(context)
            atomicArray.update(atomic)
            productSites = [getMapping(rule.mapping, action.site1), getMapping(rule.mapping, action.site2)]
            atomic, rc, _ = extractMolecules(action.action, productSites[0], productSites[1], rule.products,differentiateDimers)
            productElements.append(rc)
            atomicArray.update(atomic)
            actionName.append('%i-%s' % (index, action.action))
            r = '+'.join([str(x) for x in rule.reactants])
            p = '+'.join([str(x) for x in rule.products])
            label.append('->'.join([r, p, '%i-%s' % (index, action.action)]))

    solveWildcards(atomicArray)
    return (atomicArray, transformationCenter, transformationContext, productElements, actionName, label)


if __name__ == "__main__":
    import readBNGXML
    _, rules, _ = readBNGXML.parseXML('output205_test.xml')
    for idx, rule in enumerate(rules):
        tatomicArray, ttransformationCenter, ttransformationContext, \
            tproductElements, tactionNames, tlabelArray = extractTransformations(
                [rule], True)
        if rule[0].label == 'reaction_3':
            print ttransformationContext
            print tproductElements
            raise Exception