示例#1
0
    #- calculate redundancy
    cladeRedundancy = Redundancy(cladeEcGraph)
    cladeRedundancyContribution = RedundancyContribution(
        cladeRedundancy, cladeNeofunctionalisedMetabolismSet)

    cladeRobustnessContributedECsForContributingNeofunctionalisedEC = cladeRedundancyContribution.getContributedKeysForSpecial(
        redundancyType)
    cladeRobustnessContributingNeofunctionalisedECs = set(
        cladeRobustnessContributedECsForContributingNeofunctionalisedEC.keys())

    #- REPEAT for each function change consisting of "neofunctionalised" ECs, which also contribute to redundancy
    output.append(
        '"neofunctionalised" ECs: ' +
        str(len(cladeNeofunctionalisedMetabolismSet)) + ' (' + str(
            Percent.getPercentStringShort(
                len(cladeNeofunctionalisedMetabolismSet), cladeEcCount, 0)) +
        '%)')

    robustnessContributingNeofunctionalisations = dict()

    for functionChange, neofunctionalisations in cladeNeofunctionalisationsForFunctionChange.items(
    ):
        #-     report enzyme pairs of neofunctionalisations, which caused the EC to be considered "neofunctionalised", and are in return contributing to redundancy

        if functionChange.ecA in cladeRobustnessContributingNeofunctionalisedECs or functionChange.ecB in cladeRobustnessContributingNeofunctionalisedECs:  # function change contributes to robustness

            for neofunctionalisation in neofunctionalisations:
                currentSetOfContributedECs = robustnessContributingNeofunctionalisations.get(
                    neofunctionalisation, None)

                if currentSetOfContributedECs is None:
示例#2
0
    cladeASortedList = list(cladeANeofunctionalisedMetabolismSet)
    cladeASortedList.sort()

    #- calculate redundancy
    cladeARedundancy = Redundancy(cladeAEcGraph)
    cladeARedundancyContribution = RedundancyContribution(
        cladeARedundancy, cladeANeofunctionalisedMetabolismSet)
    cladeARobustECsForNeofunctionalisedEC = cladeARedundancyContribution.getContributedKeysForSpecial(
        RedundancyType.ROBUSTNESS)
    cladeAFlexibleECsForNeofunctionalisedEC = cladeARedundancyContribution.getContributedKeysForSpecial(
        RedundancyType.TARGET_FLEXIBILITY)

    #- REPEAT for each "neofunctionalised" EC
    output.append('"neofunctionalised" ECs: ' + str(len(cladeASortedList)) +
                  ' (' + str(
                      Percent.getPercentStringShort(len(cladeASortedList),
                                                    cladeAEcCount, 0)) + '%)')
    for ecNumber in cladeASortedList:
        #-     print number of ECs the "neofunctionalised" EC provides redundancy for (robustness and flexibility)
        output.append(
            str(ecNumber) + ' \t(' +
            str(len(cladeAFlexibleECsForNeofunctionalisedEC.get(
                ecNumber, []))) + ' target-flexibility) (' +
            str(len(cladeARobustECsForNeofunctionalisedEC.get(ecNumber, []))) +
            ' robustness)')

    output.append('')
    output.append('Target-flexibility: ' + Percent.floatToPercentString(
        cladeARedundancy.getRedundancyRatio(RedundancyType.TARGET_FLEXIBILITY))
                  )
    output.append('Target-flexibility contribution: ' +
                  Percent.floatToPercentString(
示例#3
0
 output.append('')
 output.append(', '.join(clade.ncbiNames) + ':')
 output.append('')
 
 #- get ECs
 cladeEcGraph = clade.coreMetabolism(majorityPercentageCoreMetabolism)
 cladeEcCount = len(cladeEcGraph.getECs())
 output.append( 'core metabolism ECs: ' + str(cladeEcCount) )
 output.append('')
 
 #- calculate redundancy
 cladeRedundancy = Redundancy(cladeEcGraph)
 
 #- print number of redundant ECs, including percentage of all ECs, for all types of redundancy
 output.append('')
 output.append( 'Robustness fully: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.ROBUSTNESS) ) )
 output.append( 'Robustness partial: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.ROBUSTNESS_PARTIAL) ) )
 output.append( 'Robustness both: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.ROBUSTNESS_BOTH) ) )
 output.append('')
 output.append( 'Flexibility fully: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.FLEXIBILITY) ) )
 output.append( 'Flexibility partial: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.FLEXIBILITY_PARTIAL) ) )
 output.append( 'Flexibility both: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.FLEXIBILITY_BOTH) ) )
 output.append('')
 output.append( 'Target-flexibility fully: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.TARGET_FLEXIBILITY) ) )
 output.append( 'Target-flexibility partial: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.TARGET_FLEXIBILITY_PARTIAL) ) )
 output.append( 'Target-flexibility both: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.TARGET_FLEXIBILITY_BOTH) ) )
 output.append('')
 output.append( 'Source-flexibility fully: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.SOURCE_FLEXIBILITY) ) )
 output.append( 'Source-flexibility partial: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.SOURCE_FLEXIBILITY_PARTIAL) ) )
 output.append( 'Source-flexibility both: ' + Percent.floatToPercentString(cladeRedundancy.getRedundancyRatio(RedundancyType.SOURCE_FLEXIBILITY_BOTH) ) )
 output.append('')
示例#4
0
    Export.addColourAttribute(cladeEcGraph,
                              Export.Colour.GREEN,
                              nodes=False,
                              edges=edgesOfContributingNeofunctionalisedECs)

    Export.forCytoscape(cladeEcGraph,
                        clade.ncbiNames[0],
                        inCacheFolder=True,
                        addDescriptions=True,
                        totalNumberOfOrganisms=clade.organismsCount)

    #- REPEAT for each function change consisting of "neofunctionalised" ECs, which also contribute to redundancy
    output.append(
        '"neofunctionalised" ECs: ' +
        str(len(cladeNeofunctionalisedMetabolismSet)) + ' (' + str(
            Percent.getPercentStringShort(
                len(cladeNeofunctionalisedMetabolismSet), cladeEcCount, 0)) +
        '%)')

    robustKeys = cladeRedundancy.getRedundantKeys(redundancyType)
    robustKeysCount = len(robustKeys)
    output.append(
        'robust ECs: ' + str(robustKeysCount) + ' (' +
        str(Percent.getPercentStringShort(robustKeysCount, cladeEcCount, 0)) +
        '%)')

    output.append('    of which are robust due to "neofunctionalised" ECs: ' +
                  str(
                      Percent.getPercentStringShort(
                          cladeRedundancyContribution.getKeyContributionRatio(
                              redundancyType), 1, 0)) + '%')
示例#5
0
 
 #- calculate "neofunctionalised" ECs
 cladeNeofunctionalisedMetabolismSet = clade.neofunctionalisedECs(majorityPercentageCoreMetabolism, majorityPercentageNeofunctionalisation).getECs()
 cladeNeofunctionalisationsForFunctionChange = clade.neofunctionalisationsForFunctionChange(majorityPercentageCoreMetabolism, majorityPercentageNeofunctionalisation)
 
 #- calculate redundancy
 cladeRedundancy = Redundancy(cladeEcGraph)
 cladeRedundancyContribution = RedundancyContribution(cladeRedundancy, cladeNeofunctionalisedMetabolismSet)
 
 for redundancyType in redundancyTypes:
     
     cladeRobustnessContributedECsForContributingNeofunctionalisedEC = cladeRedundancyContribution.getContributedKeysForSpecial(redundancyType)
     cladeRobustnessContributingNeofunctionalisedECs = set(cladeRobustnessContributedECsForContributingNeofunctionalisedEC.keys())
     
     #- REPEAT for each function change consisting of "neofunctionalised" ECs, which also contribute to redundancy
     output.append( '"neofunctionalised" ECs: ' + str(len(cladeNeofunctionalisedMetabolismSet)) + ' (' + str(Percent.getPercentStringShort(len(cladeNeofunctionalisedMetabolismSet), cladeEcCount, 0)) + '%)' )
     
     robustnessContributingNeofunctionalisations = dict()
     
     for functionChange, neofunctionalisations in cladeNeofunctionalisationsForFunctionChange.items():
         #-     report enzyme pairs of neofunctionalisations, which caused the EC to be considered "neofunctionalised", and are in return contributing to redundancy        
         
         if functionChange.ecA in cladeRobustnessContributingNeofunctionalisedECs or functionChange.ecB in cladeRobustnessContributingNeofunctionalisedECs: # function change contributes to robustness
             
             for neofunctionalisation in neofunctionalisations:
                 currentSetOfContributedECs = robustnessContributingNeofunctionalisations.get(neofunctionalisation, None)
                 
                 if currentSetOfContributedECs is None:
                     currentSetOfContributedECs = set()
                     robustnessContributingNeofunctionalisations[neofunctionalisation] = currentSetOfContributedECs
                 
示例#6
0
    #- calculate redundancy
    cladeRedundancy = Redundancy(cladeEcGraph)
    cladeRedundancyContribution = RedundancyContribution(
        cladeRedundancy, cladeNeofunctionalisedMetabolismSet)

    cladeRobustnessContributedECsForContributingNeofunctionalisedEC = cladeRedundancyContribution.getContributedKeysForSpecial(
        redundancyType)
    cladeRobustnessContributingNeofunctionalisedECs = set(
        cladeRobustnessContributedECsForContributingNeofunctionalisedEC.keys())

    #- REPEAT for each function change consisting of "neofunctionalised" ECs, which also contribute to redundancy
    output.append(
        '"neofunctionalised" ECs: ' +
        str(len(cladeNeofunctionalisedMetabolismSet)) + ' (' + str(
            Percent.getPercentStringShort(
                len(cladeNeofunctionalisedMetabolismSet), cladeEcCount, 0)) +
        '%)')

    robustnessContributingNeofunctionalisations = dict()

    for functionChange, neofunctionalisations in cladeNeofunctionalisationsForFunctionChange.items(
    ):
        #-     report enzyme pairs of neofunctionalisations, which caused the EC to be considered "neofunctionalised", and are in return contributing to redundancy

        if functionChange.ecA in cladeRobustnessContributingNeofunctionalisedECs or functionChange.ecB in cladeRobustnessContributingNeofunctionalisedECs:  # function change contributes to robustness

            for neofunctionalisation in neofunctionalisations:
                currentSetOfContributedECs = robustnessContributingNeofunctionalisations.get(
                    neofunctionalisation, None)

                if currentSetOfContributedECs is None:
示例#7
0
    
    #- REPEAT for each clade in Archaea, Bacteria, Archaea+Bacteria
    for clade in [CoreLUCA.CladeType.archaea, CoreLUCA.CladeType.bacteria, CoreLUCA.CladeType.archaeaBacteria]:
        
        #-     get collective metabolism of clade
        luca = CoreLUCA(clade)
        output.append(luca.nameAbbreviation)
        
        collectiveMetabolismLength = len( luca.collectiveMetabolism().getECs() )
        
        #-     REPEAT for varying majority percentages
        for percentage in range(100, 0, -10):
            
            #-         calculate core metabolism
            ecNumbers = luca.substanceEcGraph( percentage ).getECs()
            
            #-         print number of ECs by majority percentage
            if percentage == 100:
                #-         IF majority percentage is 100%, i.e. consensus, also print the ECs
                output.append( str(percentage) + "% ECs: " + str(len( ecNumbers )) + " (" + ", ".join([str(x) for x in ecNumbers]) + ")"  + ' -> ' + Percent.getPercentStringShort(len( ecNumbers ), collectiveMetabolismLength, 0) + '% of collective')
            else:
                output.append( str(percentage) + "% ECs: " + str(len( ecNumbers )) + ' -> ' + Percent.getPercentStringShort(len( ecNumbers ), collectiveMetabolismLength, 0) + '% of collective')
            
        output.append("\n")
        
        luca.clade.group.freeHeap()
        luca = None
    
    for line in output:
        print(line)