Skip to content

Commit

Permalink
Merge branch 'main' of github.com:IGS/gEAR
Browse files Browse the repository at this point in the history
  • Loading branch information
jorvis committed Dec 18, 2024
2 parents b5373bc + 6c3c3cc commit 4ec02de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion www/api/resources/tsne_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def post(self, dataset_id):
dpi = io_fig.dpi # default dpi is 100, but will be saved as 150 later on
# With 2 plots as a default (gene expression and colorize_by), we want to grow the figure size slowly based on the number of plots

num_plots_wide = max_columns if max_columns else num_plots
num_plots_wide = max_columns if plot_by_group and max_columns else num_plots
num_plots_high = ceil(num_plots / num_plots_wide)

# set the figsize based on the number of plots
Expand Down
38 changes: 19 additions & 19 deletions www/cgi/download_source_file.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,29 @@ or H5AD file.
'''

from shutil import copyfileobj
import sys
import cgi, html, json
import os
import sys
import cgi, html

lib_path = os.path.abspath(os.path.join('..', '..', 'lib'))
sys.path.append(lib_path)
import geardb


def download_file(file_path, file_name):
print("Content-type: application/octet-stream")
print(f"Content-Disposition: attachment; filename={file_name}")
print()
sys.stdout.flush()

with open(file_path, 'rb') as binfile:
while True:
chunk = binfile.read(8192) # Read in 8KB chunks
if not chunk:
break
sys.stdout.buffer.write(chunk)
sys.stdout.buffer.flush()

def main():
form = cgi.FieldStorage()
dataset_id = html.escape(form.getvalue('dataset_id'))
Expand All @@ -40,23 +54,9 @@ def main():
h5ad_path = ""

if dtype == 'tarball' and os.path.isfile(tarball_path):
print("Content-type: application/octet-stream")
print("Content-Disposition: attachment; filename={0}.tar.gz".format(dataset_id))
print()
sys.stdout.flush()

with open(tarball_path, 'rb') as binfile:
copyfileobj(binfile, sys.stdout.buffer)

download_file(tarball_path, f"{dataset_id}.tar.gz")
elif dtype == 'h5ad' and os.path.isfile(h5ad_path):
print("Content-type: application/octet-stream")
print("Content-Disposition: attachment; filename={0}.h5ad".format(dataset_id))
print()
sys.stdout.flush()

with open(h5ad_path, 'rb') as binfile:
copyfileobj(binfile, sys.stdout.buffer)

download_file(h5ad_path, f"{dataset_id}.h5ad")
else:
raise FileNotFoundError("File not found")

Expand Down

0 comments on commit 4ec02de

Please sign in to comment.