def add_ebv_attribute(inFile, pedgraph, animal=1, atCol=4, atName="attr1"):
"""
inFile - pedigree as .txt file
pedgraph - Pedigree as a networkX graph object
animal - column for the animal ID
atCol - column for the attribute
atName - name for the attribute
"""
ped_df = pd.read_table(inFile, header=None, delim_whitespace=True)
#print ped_df
dic_ped = dict(zip(ped_df[animal - 1], ped_df[atCol - 1]))
#print dic_ped
correct_dic_ped = {str(k):int(-v) for k,v in dic_ped.items()}
#print correct_dic_ped
for node, value in dic_ped.items():
pedgraph.node[str(node)]["EBV"] = value
return correct_dic_ped
评论列表
文章目录