def createJSONforD3(node_value,link_value):
'''
This function takes the variables created in the functions nodes() and links() and creates a json file that contains all the necessary information for plotting the netwrok of associations between the different OTUs with the color of the links reflecting the prediction of the types of interactions occurring between pairs of OTUs.
:param node_value: list of dictionaries returned from function nodes
:param link_value: list of dictionaries returned from function links
:return data4plot_json: file in json format in site folder that contains the information required for plotting network of associations between OTUs and the predicted interactions occurring between pairs of species.
'''
import json
cherrypy.log('Finally, we will dump the information about the nodes and links of our network to a json file.')
'''
@summary: put the nodes values and the links values into the final dataset that is in the dictionary format
'''
dataDict = {'nodes': node_value, 'links': link_value}
'''
@summary: dump the new data into a json file
'''
with open('data4plot_json','w') as outfile:
cherrypy.log('The information will be dumped into the file %s' %outfile)
json.dump(dataDict, outfile)
cherrypy.log('We finished creating the json file.')
评论列表
文章目录