diff --git a/ngtax_to_biom.py b/ngtax_to_biom.py index b36b2194d47a755f3fe5426c3772be22212f0db5..3eab99403ada2051f4b967075d524b908f32cd36 100755 --- a/ngtax_to_biom.py +++ b/ngtax_to_biom.py @@ -140,7 +140,7 @@ def process_rdf_files(rdf_file): def biom_preformatter(): # Format tax matrix a bit so further parsing as added prefixes tax_df = process_tax() - + # Load and transform the ASV file into a matrix lines = [] for line in open("asv.tsv"): @@ -218,9 +218,12 @@ def tsv_to_biom(): # Create Python object from JSON string data obj = json.loads(json_data) - + # Fix taxonomy split issue + for index, row in enumerate(obj["rows"]): + row['metadata']['taxonomy'] = row['metadata']['taxonomy'].split("; ") # Pretty Print JSON json_formatted_str = json.dumps(obj, indent=4, sort_keys=True) + biom_file = job.split("/")[-1].replace(".job", ".biom") print("Writing biom file to", biom_file) print(json_formatted_str, file=open(biom_file, "w"))