diff --git a/DDV.py b/DDV.py index cb95d69..dd2387a 100644 --- a/DDV.py +++ b/DDV.py @@ -124,8 +124,10 @@ def ddv(args): batch.fastas) sys.exit(0) - if args.layout_type == "NONE": # DEPRECATED: Shortcut for old visualizations to create dz stack from existing large image + if args.layout_type == "NONE": # Complete webpage generation from existing image output_dir = make_output_dir_with_suffix(base_path, '') + layout = TileLayout(use_titles=not args.no_titles, sort_contigs=args.sort_contigs) + layout.generate_html(base_path, output_dir, args.output_name) print("Creating Deep Zoom Structure for Existing Image...") create_deepzoom_stack(args.image, os.path.join(output_dir, 'GeneratedImages', "dzc_output.xml")) print("Done creating Deep Zoom Structure.") @@ -209,26 +211,23 @@ def create_parallel_viz_from_fastas(args, n_genomes, output_dir, output_name, fa layout = ParallelLayout(n_genomes=n_genomes) layout.process_file(output_dir, output_name, fastas) layout_final_output_location = layout.final_output_location + del layout try: for extra_fasta in fastas: shutil.copy(extra_fasta, os.path.join(output_dir, os.path.basename(extra_fasta))) except shutil.SameFileError: pass # not a problem - print("Done creating Large Image.") - if not args.no_webpage: - layout.generate_html(fasta, output_dir, output_name) - del layout - print("Creating Deep Zoom Structure from Generated Image...") - create_deepzoom_stack(os.path.join(output_dir, layout_final_output_location), - os.path.join(output_dir, 'GeneratedImages', "dzc_output.xml")) - print("Done creating Deep Zoom Structure.") - else: - del layout + print("Done creating Large Image and HTML.") + print("Creating Deep Zoom Structure from Generated Image...") + create_deepzoom_stack(os.path.join(output_dir, layout_final_output_location), + os.path.join(output_dir, 'GeneratedImages', "dzc_output.xml")) + print("Done creating Deep Zoom Structure.") if args.run_server: run_server(output_dir) + def create_tile_layout_viz_from_fasta(args, fasta, output_dir, output_name, layout=None): print("Creating Large Image from Input Fasta...") if layout is None: diff --git a/TileLayout.py b/TileLayout.py index f8e6ca6..cc6e215 100644 --- a/TileLayout.py +++ b/TileLayout.py @@ -146,7 +146,7 @@ def calc_all_padding(self): if len(self.contigs) > 10000: print("Over 10,000 scaffolds detected! Titles for entries less than 10,000bp will not be drawn.") self.skip_small_titles = True - # self.sort_contigs = True # Important! Skipping isn't valid unless they're sorted + self.sort_contigs = True # Important! Skipping isn't valid unless they're sorted if self.sort_contigs: print("Scaffolds are being sorted by length.") self.contigs.sort(key=lambda fragment: -len(fragment.seq)) # Best to bring the largest contigs to the forefront @@ -298,7 +298,7 @@ def output_image(self, output_folder, output_file_name): print("-- Writing:", output_file_name, "--") self.final_output_location = os.path.join(output_folder, output_file_name + ".png") self.image.save(self.final_output_location, 'PNG') - del self.image + # del self.image def max_dimensions(self, image_length): @@ -329,8 +329,8 @@ def generate_html(self, input_file_path, output_folder, output_file_name): copytree(os.path.join(os.getcwd(), 'html template'), output_folder) # copies the whole template directory html_path = os.path.join(output_folder, 'index.html') html_content = {"title": output_file_name.replace('_', ' '), - "originalImageWidth": str(self.image.width), - "originalImageHeight": str(self.image.height), + "originalImageWidth": str(self.image.width if self.image else 1), + "originalImageHeight": str(self.image.height if self.image else 1), "image_origin": str(self.origin), "ColumnPadding": str(self.levels[2].padding), "columnWidthInNucleotides": str(self.levels[1].chunk_size), diff --git a/html template/img/LEGEND-A.png b/html template/img/LEGEND-A.png index d06f693..7776d41 100644 Binary files a/html template/img/LEGEND-A.png and b/html template/img/LEGEND-A.png differ diff --git a/html template/img/LEGEND-C.png b/html template/img/LEGEND-C.png index e0a7459..7f0eef9 100644 Binary files a/html template/img/LEGEND-C.png and b/html template/img/LEGEND-C.png differ diff --git a/html template/img/LEGEND-G.png b/html template/img/LEGEND-G.png index 0855926..5084160 100644 Binary files a/html template/img/LEGEND-G.png and b/html template/img/LEGEND-G.png differ diff --git a/html template/img/LEGEND-T.png b/html template/img/LEGEND-T.png index 2487c02..5e8cc6a 100644 Binary files a/html template/img/LEGEND-T.png and b/html template/img/LEGEND-T.png differ