本文整理汇总了Python中biom.table.Table.to_json方法的典型用法代码示例。如果您正苦于以下问题:Python Table.to_json方法的具体用法?Python Table.to_json怎么用?Python Table.to_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类biom.table.Table
的用法示例。
在下文中一共展示了Table.to_json方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from biom.table import Table [as 别名]
# 或者: from biom.table.Table import to_json [as 别名]
def main(table_loc, otu_list, collapsed_name, output_file, classic=False):
table = load_table(table_loc)
f = open(otu_list)
otus = f.read().strip().split()
otus = set(otus) & set(table.ids(axis="observation"))
table1 = table.filter(otus, axis="observation", inplace=False)
table2 = table.filter(otus, axis="observation", invert=True, inplace=False)
sums1 = table1.sum(axis='sample')
sums2 = table2.sum(axis='sample')
new_table = Table(numpy.array([sums1,sums2]), [collapsed_name, "not_"+collapsed_name], table.ids(axis="sample"), type="otu baptable")
if classic:
# print to tab delimited biom table
open(output_file, 'w').write(new_table.to_tsv())
else:
# print biom table
new_table.to_json("predict_reactions.py", open(output_file, 'w'))
示例2: len
# 需要导入模块: from biom.table import Table [as 别名]
# 或者: from biom.table.Table import to_json [as 别名]
# print "index: %i" %index
ind_taxonomy.append('%s%s' %(syn[levels[index]], taxon[0]['ScientificName']))
# print ind_taxonomy
Taxonomy[taxon[0]['ScientificName']]['taxonomy'] = ind_taxonomy
# print "Taxonomy: %s" %Taxonomy
for taxon in observ_ids:
# print taxon
# print Taxonomy[taxon]
observation_metadata.append(Taxonomy[taxon])
#print "observation metadata:\n%s" %observation_metadata
#print len(observation_metadata)
table = Table(data, observ_ids, sample_id, observation_metadata, sample_metadata, table_id='Example Table')
print table
out=open(args.prefix+".biom","w")
table.to_json('pplacer converted by jplace_to_biom.py v.'+VERSION, direct_io=out)
out.close()
out=open(args.prefix+".tsv","w")
out.write(table.to_tsv(header_key='taxonomy', header_value='taxomomy')) #to_json('generaged by test', direct_io=out)
out.close()
print "\n##### DONE! #####\n"