Ejemplo n.º 1
0
    #- Get all metabolic pathways of all E. coli organisms from KEGG.
    eColiOrganisms = FEV_KEGG.KEGG.Organism.Group(
        searchString='Escherichia coli K-12').organisms

    #- For each organism, combine all pathways to the metabolic network, by UNION operation.
    organismEcGraphs = []
    for organism in eColiOrganisms:
        organismPathways = organism.getMetabolicPathways()
        organismSubstanceReactionGraph = SubstanceReactionGraph.fromPathway(
            organismPathways)

        #- Convert this metabolic network into a substance-ecNumber graph.
        organismSubstanceGeneGraph = SubstanceGeneGraph.fromSubstanceReactionGraph(
            organismSubstanceReactionGraph)
        organismSubstanceEcGraph = SubstanceEcGraph.fromSubstanceGeneGraph(
            organismSubstanceGeneGraph)

        organismEcGraphs.append(organismSubstanceEcGraph)

    firstGraph = organismEcGraphs.pop(0)

    #- Combine all organisms' networks to a consensus network, by INTERSECT operation, leaving only substances and EC numbers that occur in all organisms.
    intersectedEcGraph = firstGraph
    intersectedEcGraph = intersectedEcGraph.intersection(organismEcGraphs)

    #- Print all EC numbers that occur in all organisms.
    output = []
    for ecNumber in intersectedEcGraph.getECs():
        output.append(ecNumber.__str__())

    output.sort()
Ejemplo n.º 2
0
 
 #- Convert each pathway into a substance-ecNumber graph. This is the incomplete metabolic network.
 ecoReactionGraph = SubstanceReactionGraph.fromPathway(ecoPathways)
 ssoReactionGraph = SubstanceReactionGraph.fromPathway(ssoPathways)
 
 ecoGeneGraph = SubstanceGeneGraph.fromSubstanceReactionGraph(ecoReactionGraph)
 ssoGeneGraph = SubstanceGeneGraph.fromSubstanceReactionGraph(ssoReactionGraph)
 
 ecoEnzymeGraph = SubstanceEnzymeGraph.fromSubstanceGeneGraph(ecoGeneGraph)
 ssoEnzymeGraph = SubstanceEnzymeGraph.fromSubstanceGeneGraph(ssoGeneGraph)
 
 #- Remove multifunctional enzymes, meaning enzymes associated with more than one EC number. Helps to reduce false gene duplications.
 ecoEnzymeGraph.removeMultifunctionalEnzymes()
 ssoEnzymeGraph.removeMultifunctionalEnzymes()
 
 ecoEcGraph = SubstanceEcGraph.fromSubstanceEnzymeGraph(ecoEnzymeGraph)
 ssoEcGraph = SubstanceEcGraph.fromSubstanceEnzymeGraph(ssoEnzymeGraph)
 
 #- Combine both species' networks to a consensus network, by INTERSECTION operation.
 intersectionEcGraph = ecoEcGraph.intersection(ssoEcGraph)
 
 #- Create the networks of EC numbers that only occur in eco.
 onlyEcoEcGraph = ecoEcGraph.difference(intersectionEcGraph, subtractNodes = False)
 
 
 
 # New steps:
 output = []
 
 #- For each eco-only EC number, gather any eco gene which encodes an enzyme associated with this EC number.
 new_ec_numbers = onlyEcoEcGraph.getECs()
Ejemplo n.º 3
0
    def _SubstanceReactionGraph2SubstanceEcGraph(
        self, speciesSubstanceReactionGraph: SubstanceReactionGraph
    ) -> SubstanceEcGraph:
        """
        Converts NUKA's substance-reaction graph into a substance-EC graph. Uses pathway information embedded into the graph object.
        
        Parameters
        ----------
        speciesSubstanceReactionGraph : SubstanceReactionGraph
            NUKA's substance-reaction graph.
        
        Returns
        -------
        SubstanceEcGraph
            NUKA's substance-EC graph.
        
        Warnings
        --------
        This function is special to NUKA and **MUST NOT** be used anywhere else!
        """
        # shallow-copy old graph to new graph
        graph = SubstanceEcGraph(
            speciesSubstanceReactionGraph.underlyingRawGraph)
        graph.name = 'Substance-EC NUKA'

        # create dict of replacements: reaction -> {EC numbers}
        replacementDict = dict()

        # for each embedded pathway, get list of 'enzyme' entries
        for pathway in speciesSubstanceReactionGraph.pathwaySet:
            ecEntryList = [
                e for e in pathway.entries.values() if e.type == 'enzyme'
            ]

            # for each EC number, get reactions in which it is involved
            for ecEntry in ecEntryList:
                reactionIDList = ecEntry.reaction.split()
                if len(
                        reactionIDList
                ) > 0:  # filter EC numbers not associated with any reaction
                    ecNumberList = ecEntry.name.split()

                    # replace each reaction with its associated EC number
                    for reactionID in reactionIDList:
                        reactionName = reactionID.split(':', 1)[1]
                        reaction = ReactionID(reactionName)

                        # save associated EC numbers in a set
                        ecNumberSet = set()
                        for ecNumberString in ecNumberList:
                            ecNumber = EcNumber(
                                ecNumberString.replace('ec:', ''))
                            ecNumberSet.add(ecNumber)

                        # update the replacement dict for the current reaction, adding the newly created EC number set
                        replacementSet = replacementDict.get(reaction, None)
                        if replacementSet == None or replacementSet.__class__ != set:
                            replacementSet = set()
                        replacementSet.update(ecNumberSet)
                        replacementDict[reaction] = replacementSet

        # get list of all reaction edges. Copy edge list to prevent changes in-place, which would NOT work
        edgeList = list(graph.getEdges())

        # replace reaction edges with EC number edges, using replacement dict
        for edge in edgeList:
            substrate, product, reaction = edge

            # delete old edge
            graph.removeEdge(substrate, product, reaction, False)

            # add new edges, according to replacement dict
            replacementSet = replacementDict[reaction]
            for ecNumber in replacementSet:
                graph.addEC(substrate, product, ecNumber, False)

        if init_verbosity > 0:
            print('calculated ' + graph.name)

        return graph
Ejemplo n.º 4
0
 #- Download pathway description as KGML.
 eco = Organism('eco')
 
 eco00260 = eco.getPathway('00260')
 eco01100 = eco.getPathway('01100')
 
 #- Convert to substance-reaction graph.
 eco00260_reactionGraph = SubstanceReactionGraph.fromPathway(eco00260)
 eco01100_reactionGraph = SubstanceReactionGraph.fromPathway(eco01100)
 
 #- Convert to substance-gene graph
 eco00260_geneGraph = SubstanceGeneGraph.fromSubstanceReactionGraph(eco00260_reactionGraph)
 eco01100_geneGraph = SubstanceGeneGraph.fromSubstanceReactionGraph(eco01100_reactionGraph)
 
 #- Convert to substance-ec graph
 eco00260_ecGraph = SubstanceEcGraph.fromSubstanceGeneGraph(eco00260_geneGraph)
 eco01100_ecGraph = SubstanceEcGraph.fromSubstanceGeneGraph(eco01100_geneGraph)
 
 #- Get set of EC numbers for each graph.
 eco00260_ecNumbers = eco00260_ecGraph.getECs()
 eco01100_ecNumbers = eco01100_ecGraph.getECs()
 
 #- Calculate difference of EC number sets.
 difference_ecNumbers = eco00260_ecNumbers.difference(eco01100_ecNumbers)
 
 #- Print genes (EC number).
 output = []
 for ecNumber in difference_ecNumbers:
     output.append(ecNumber.__str__())
 output.sort()
 print(str(len(output)) + ' results')
Ejemplo n.º 5
0
    allNonOverviewPathways = eco.getMetabolicPathways(
        includeOverviewMaps=False)

    #- Convert to substance-reaction graph.
    eco01100_reactionGraph = SubstanceReactionGraph.fromPathway(eco01100)
    allNonOverviewPathways_reactionGraph = SubstanceReactionGraph.fromPathway(
        allNonOverviewPathways)

    #- Convert to substance-gene graph.
    eco01100_geneGraph = SubstanceGeneGraph.fromSubstanceReactionGraph(
        eco01100_reactionGraph)
    allNonOverviewPathways_geneGraph = SubstanceGeneGraph.fromSubstanceReactionGraph(
        allNonOverviewPathways_reactionGraph)

    #- Convert to substance-ec graph.
    eco01100_ecGraph = SubstanceEcGraph.fromSubstanceGeneGraph(
        eco01100_geneGraph)
    allNonOverviewPathways_ecGraph = SubstanceEcGraph.fromSubstanceGeneGraph(
        allNonOverviewPathways_geneGraph)

    #- Get set of EC numbers for each graph.
    eco01100_ecNumbers = eco01100_ecGraph.getECs()
    allNonOverviewPathways_ecNumbers = allNonOverviewPathways_ecGraph.getECs()

    #- Calculate difference of EC number sets.
    difference_ecNumbers = eco01100_ecNumbers.difference(
        allNonOverviewPathways_ecNumbers)

    #- Print EC numbers.
    output = []
    for ecNumber in difference_ecNumbers:
        output.append(ecNumber.__str__())
Ejemplo n.º 6
0
 
 #- Get 00260 pathways of eco and sso from KEGG.
 eco = FEV_KEGG.KEGG.Organism.Organism('eco')
 sso = FEV_KEGG.KEGG.Organism.Organism('sso')
 
 eco00260 = eco.getPathway('00260')
 sso00260 = sso.getPathway('00260')
 
 #- Convert each pathway into a substance-ecNumber graph. This is the incomplete metabolic network.
 ecoReactionGraph = SubstanceReactionGraph.fromPathway(eco00260)
 ssoReactionGraph = SubstanceReactionGraph.fromPathway(sso00260)
 
 ecoGeneGraph = SubstanceGeneGraph.fromSubstanceReactionGraph(ecoReactionGraph)
 ssoGeneGraph = SubstanceGeneGraph.fromSubstanceReactionGraph(ssoReactionGraph)
 
 ecoEcGraph = SubstanceEcGraph.fromSubstanceGeneGraph(ecoGeneGraph)
 ssoEcGraph = SubstanceEcGraph.fromSubstanceGeneGraph(ssoGeneGraph)
 
 #- Combine both species' networks to a consensus network, by INTERSECTION operation.
 intersectionEcGraph = ecoEcGraph.intersection(ssoEcGraph)
 
 #- Create the networks of EC numbers that only occur in 1) eco, and 2) sso.
 onlyEcoEcGraph = ecoEcGraph.difference(intersectionEcGraph, subtractNodes = False)
 onlySsoEcGraph = ssoEcGraph.difference(intersectionEcGraph, subtractNodes = False)
 
 #- Print those EC numbers.
 print('EC numbers occuring only in eco:')
 output = []
 for ecNumber in onlyEcoEcGraph.getECs():
     output.append(ecNumber.__str__())