Skip to content

Commit

Permalink
Updated color legend. Fixes for HTML generation with no image
Browse files Browse the repository at this point in the history
  • Loading branch information
josiahseaman committed Dec 4, 2017
1 parent 72d359e commit c3b3918
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
21 changes: 10 additions & 11 deletions DDV.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions TileLayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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),
Expand Down
Binary file modified html template/img/LEGEND-A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified html template/img/LEGEND-C.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified html template/img/LEGEND-G.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified html template/img/LEGEND-T.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c3b3918

Please sign in to comment.