def getNucleotides(jsonname, fstname): with open(jsonname+".json") as json: taxa = load(json) nucleotides = DnaCharacterMatrix.get_from_path("../work/"+ fstname+".fst", schema="fasta") for taxon in nucleotides.taxon_set: for accession, metadata in taxa.items(): if accession == taxon.label.split(".")[0]: taxon.label = metadata["name"].replace(" ", "_") return nucleotides