Commit 515f1ccb authored by Penom Nom's avatar Penom Nom
Browse files

Fix bug when cluster has no hit.

parent 05565c14
......@@ -120,10 +120,19 @@ def add_tax_metadata( biom_file, blast_file, taxonomy_file, output_file ):
biom = BiomIO.from_json( biom_file )
for cluster in biom.rows:
cluster_id = cluster['id']
biom.add_metadata( cluster_id, "taxonomy", cluster_annot[cluster_id]['tax'], "observation")
biom.add_metadata( cluster_id, "evalue", cluster_annot[cluster_id]['evalue'], "observation")
biom.add_metadata( cluster_id, "identity", cluster_annot[cluster_id]['identity'], "observation")
biom.add_metadata( cluster_id, "aln_length", cluster_annot[cluster_id]['aln_length'], "observation")
taxonomy = [""]
evalue = ""
identity = ""
aln_length = ""
if cluster_annot.has_key( cluster_id ):
taxonomy = cluster_annot[cluster_id]['tax']
evalue = cluster_annot[cluster_id]['evalue']
identity = cluster_annot[cluster_id]['identity']
aln_length = cluster_annot[cluster_id]['aln_length']
biom.add_metadata( cluster_id, "taxonomy", taxonomy, "observation")
biom.add_metadata( cluster_id, "evalue", evalue, "observation")
biom.add_metadata( cluster_id, "identity", identity, "observation")
biom.add_metadata( cluster_id, "aln_length", aln_length, "observation")
BiomIO.write( output_file, biom )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment