Skip to content

Commit

Permalink
Merge branch 'main' into 36_update_readme
Browse files Browse the repository at this point in the history
  • Loading branch information
VinzentRisch committed Jan 19, 2024
2 parents 125154b + c179878 commit 9ce64c6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion q2_amr/card/heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,25 @@ def heatmap(
TEMPLATES = pkg_resources.resource_filename("q2_amr", "assets")
annotation_dir = str(amr_annotation)
with tempfile.TemporaryDirectory() as tmp:
# Create directories for the JSON annotation files and the heatmap output files
results_dir = os.path.join(tmp, "results")
json_files_dir = os.path.join(tmp, "json_files")
os.makedirs(results_dir)
os.makedirs(json_files_dir)

# Move all JSON files from the annotation directories into one json_files_dir.
# Files get renamed to include sample and bin name.
for json_file in glob.glob(os.path.join(annotation_dir, "*", "*", "*.json")):
sample, bin_name, _ = json_file.split(os.path.sep)[-3:]
destination_path = os.path.join(json_files_dir, f"{sample}_{bin_name}")
destination_path = os.path.join(json_files_dir, f"{sample}_{bin_name}.json")
shutil.copy(json_file, destination_path)

# Run RGI heatmap function.
run_rgi_heatmap(tmp, json_files_dir, clus, cat, display, frequency)

# Change names of all output files to not include number of files.
change_names(results_dir)

copy_tree(os.path.join(TEMPLATES, "rgi", "heatmap"), output_dir)
copy_tree(results_dir, os.path.join(output_dir, "rgi_data"))
context = {"tabs": [{"title": "Heatmap", "url": "index.html"}]}
Expand Down

0 comments on commit 9ce64c6

Please sign in to comment.