clade = Clade('Archaea') # pre-fetch collective metabolism into memory clade.collectiveMetabolism( excludeMultifunctionalEnzymes=settings.defaultNoMultifunctional) # pre-fetch collective enzyme metabolism into memory clade.collectiveMetabolismEnzymes( excludeMultifunctionalEnzymes=settings.defaultNoMultifunctional) return clade if __name__ == '__main__': #- get clade clade = getClade() majorityPercentageCoreMetabolism = 80 majorityPercentageNeofunctionalisation = 0 #- get neofunctionalisations neofunctionalisationsForFunctionChange = clade.neofunctionalisationsForFunctionChange( majorityPercentageCoreMetabolism, majorityPercentageNeofunctionalisation) #- export to HTML, including links and further info dictToHtmlFile(neofunctionalisationsForFunctionChange, clade.ncbiNames[0] + '_Neofunctionalisations-For-FunctionChange.html', byValueFirst=False, inCacheFolder=True, addEcDescriptions=True)
allNeofunctionalisations = set( ) # set of all neofunctionalisations, no matter which function change they belong to for valueSet in neofunctionalisationsForFunctionChange.values(): allNeofunctionalisations.update(valueSet) output.append('') output.append('All neofunctionalisations: ' + str(len(allNeofunctionalisations))) #- print them into nice HTML ecNumbers = set() for functionChange in neofunctionalisationsForFunctionChange.keys(): ecNumbers.update(functionChange.ecPair) dictToHtmlFile(neofunctionalisationsForFunctionChange, clade.ncbiNames[0] + '_Neofunctionalisations-For-FunctionChange.html', byValueFirst=False, inCacheFolder=True, addEcDescriptions=ecNumbers) output.append('\t[see ' + clade.ncbiNames[0] + '_Neofunctionalisations-For-FunctionChange.html]') output.append('') #- calculate "neofunctionalised" ECs cladeNeofunctionalisedMetabolismSet = clade.neofunctionalisedECs( majorityPercentageCoreMetabolism, majorityPercentageNeofunctionalisation, eValue=eValue).getECs() cladeNeofunctionalisationsForFunctionChange = clade.neofunctionalisationsForFunctionChange( majorityPercentageCoreMetabolism, majorityPercentageNeofunctionalisation, eValue=eValue)
output.append('') neofunctionalisationsForContributedEC = dict() for neofunctionalisation, contributedECs in robustnessContributingNeofunctionalisations.items(): for contributedEC in contributedECs: currentSetOfNeofunctionalisations = neofunctionalisationsForContributedEC.get(contributedEC, None) if currentSetOfNeofunctionalisations is None: currentSetOfNeofunctionalisations = set() neofunctionalisationsForContributedEC[contributedEC] = currentSetOfNeofunctionalisations currentSetOfNeofunctionalisations.add(neofunctionalisation) ecNumbers = set() for contributedEC in neofunctionalisationsForContributedEC.keys(): ecNumbers.add( contributedEC ) dictToHtmlFile(neofunctionalisationsForContributedEC, clade.ncbiNames[0] + '_' + redundancyType.name + '_Neofunctionalisations-For-Contributed-EC.html', byValueFirst=False, inCacheFolder=True, addEcDescriptions = ecNumbers) for line in output: print( line )