我正在使用带有此代码的词典和列表:
def data4circos(assembly_len, reference_len, reference_name, assembly_contigs):
'''
[
{"id":"chr03","label":"chr03","color":"#996600","len":35020413},
{"id":"tig00007144","label":"tig00007144","color":"#666600","len":40868},
...
}
'''
print reference_len
print reference_len[reference_name]
print reference_name
print assembly_len
print assembly_contigs
print assembly_contigs[0]
print assembly_len[assembly_contigs[0]]
并产生以下输出:
reference_len: OrderedDict([('chr01', '29070452'), ('chr02', '29511734'), ('chr03', '35020413')])
reference_len[reference_name]: 35020413
reference_name: chr03
assembly_len: OrderedDict([('tig00007144', '40868'), ('tig00000004', '276328'), ('tig00000013', '34218') ])
assembly_contigs: ['tig00007144', 'tig00026480', 'tig00003221', 'tig00010111', 'tig00000318', 'tig00009327']
assembly_contigs[0]:tig00007144
assembly_len[assembly_contigs[0]]: 40868
从上面的数据创建看起来像这样的json文件的最佳方法是什么:
[
{"id":<reference_name>,"label":<reference_name>,"color":"#996600","len":<reference_len[reference_name]>},
{"id":<assembly_contigs[0]>,"label":<assembly_contigs[0]>,"color":"#666600","len":<assembly_len[assembly_contigs[0]]>},
...
]
最终的出局应该是这样的:
[
{"id":"chr03","label":"chr03","color":"#996600","len":35020413},
{"id":"tig00007144","label":"tig00007144","color":"#666600","len":40868},
...
]
提前谢谢。