Skip to content

Commit

Permalink
Fix matrices spelling in tcr-dist tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jwkai committed Feb 15, 2023
1 parent 0706634 commit 3fc5487
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions alldata/bblab_site/tools/tcr_distance/tcr_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ def terminate(dir_num):
assert (shutil.rmtree.avoids_symlink_attacks == True), "version needs to protect against symlink attacks"
shutil.rmtree( "{}/tmp_{}".format(tmp_dirs_path, dir_num) )

# this function removes all files except for matricies.zip and status
# this function removes all files except for matrices.zip and status
def clear_dir(dir_num):
#file = open("{}/status".format(wd), "a")
#file.write("clearing directory! #{}".format(dir_num) + str("\n"))
#file.close()

assert (shutil.rmtree.avoids_symlink_attacks == True), "version needs to protect against symlink attacks"
for name in os.listdir( tmp_dirs_path + "/tmp_{}".format(dir_num) ):
if name != "matricies.zip" and name != "status" and name != "terminate":
if name != "matrices.zip" and name != "status" and name != "terminate":
file_path = "{}/tmp_{}/{}".format(tmp_dirs_path, dir_num, name)
if os.path.isfile(file_path):
os.remove(file_path)
Expand Down Expand Up @@ -203,7 +203,7 @@ def append_status_file(val):

append_status_file("compressing files")

command = "cd {}; zip matricies.zip clones__A.dist clones__B.dist clones__AB.dist; cd -".format(wd)
command = "cd {}; zip matrices.zip clones__A.dist clones__B.dist clones__AB.dist; cd -".format(wd)
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# This loop allows for the process to be terminated
Expand Down Expand Up @@ -244,7 +244,7 @@ def append_status_file(val):


# If the output file doesn't exist, then destroy the current directory
if not os.path.exists("{}/matricies.zip".format(wd)):
if not os.path.exists("{}/matrices.zip".format(wd)):
append_status_file("pipeline failed (output file was not generated). Make sure your input was correct.")
append_status_file("done")
time.sleep(5)
Expand All @@ -255,10 +255,10 @@ def append_status_file(val):
##### Read the compressed file and email it


email_size = os.path.getsize("{}/matricies.zip".format(wd))
email_size = os.path.getsize("{}/matrices.zip".format(wd))
if email_size * 1.37 < 25000000:
with open("{}/matricies.zip".format(wd), "rb") as file:
matricies_data = file.read()
with open("{}/matrices.zip".format(wd), "rb") as file:
matrices_data = file.read()


##### Send an email with the xlsx file in it.
Expand All @@ -267,11 +267,11 @@ def append_status_file(val):
# 1.37 is the factor around which files tend to be expanded.
if send_email == 1 and email_size * 1.37 < 25000000:
# make the output files into mailable files.
mat_file = mailer.create_file( "matricies", 'zip', matricies_data )
mat_file = mailer.create_file( "matrices", 'zip', matrices_data )

# Add the body to the message and send it.
end_message = "This is an automatically generated email, please do not respond."
msg_body = "The included .zip file ({}.zip) contains the requested tcr_distance matrix data. \n\n{}".format("matricies", end_message)
msg_body = "The included .zip file ({}.zip) contains the requested tcr_distance matrix data. \n\n{}".format("matrices", end_message)

if mailer.send_sfu_email("tcr_dist", email_address, "TCR Distance Results", msg_body, [mat_file]) == 0:
pass
Expand Down
4 changes: 2 additions & 2 deletions alldata/bblab_site/tools/tcr_distance/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def download_file(request):
else:
return HttpResponse("no dir")

file_path = os.path.dirname(os.path.realpath(__file__)) + "/tmp_dirs/tmp_{}/matricies.zip".format(dirNum)
file_path = os.path.dirname(os.path.realpath(__file__)) + "/tmp_dirs/tmp_{}/matrices.zip".format(dirNum)
if not (os.path.exists(file_path) and os.path.isfile(file_path)):
return HttpResponse("no file" + str(dirNum))

Expand All @@ -147,7 +147,7 @@ def download_file(request):
terminate_directory(dirNum) # tell self to be destroyed on the next check -> there should only ever be 1 left over.

response = HttpResponse(file_dat, content_type="application/zip")
response['Content-Disposition'] = "inline; filename=matricies.zip"
response['Content-Disposition'] = "inline; filename=matrices.zip"
return response
else:
return HttpResponse("not allowed")
Expand Down

0 comments on commit 3fc5487

Please sign in to comment.