Commit 9e88eb22 authored by sgriep's avatar sgriep
Browse files

Merge branch 's3upload' into 'main'

Add S3 Upload feature

See merge request ahoek/wasp_sven_test!2
parents 85210b13 5d88ca1d
#!/usr/bin/env python3
import requests
import logging
import json
# Get URL parameters for S3-POST-Upload from Cloud VM
requestInfo = requests.get('http://134.176.27.97/getS3UL')
requestJson = json.loads(requestInfo.text)
# Extract key (=ID) for data set
resultID = requestJson['key']
fileToUpload = 'S3Upload/results.tar.gz'
url = "https://s3.computational.bio.uni-giessen.de/wasptest"
with open(fileToUpload, 'rb') as f:
files = {'file': (fileToUpload, f)}
http_response = requests.post(url, data=requestJson, files=files)
print(http_response)
# If successful, returns HTTP status code 204
logging.info(f'File upload HTTP status code: {http_response.status_code}')
# HTML code for website/document including button to
# access the uploaded data set in a WASP container
htmlText = """
<html>
<body>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {{
font-family: Arial, sans-serif;
}}
.loader {{
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #006599;
border-right: 16px solid #830d0d;
border-bottom: 16px solid #cbcbcb;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}}
/* Safari */
@-webkit-keyframes spin {{
0% {{ -webkit-transform: rotate(0deg); }}
100% {{ -webkit-transform: rotate(360deg); }}
}}
@keyframes spin {{
0% {{ transform: rotate(0deg); }}
100% {{ transform: rotate(360deg); }}
}}
</style>
<center>
<h1>Loading WASP analysis results, please wait...</h1>
<p></p>
<h4>(this may take a few seconds)</h4>
<p></p>
<br>
<p>
<img src="https://s3.computational.bio.uni-giessen.de/swift/v1/share/WASP_Logo.png" alt="WASP Logo" width="18%"/>
</p>
<p>
<br>
<div class="loader"></div>
</p>
<meta http-equiv="refresh" content="0; url=http://134.176.27.97/wasp?data={}" />
</center>
</body>
</html>
""".format(resultID)
# Write HTML file
HTMLfile = open("Results/wasp_results.html", "w")
HTMLfile.write(htmlText)
HTMLfile.close()
......@@ -48,15 +48,7 @@ print(PROTOCOL)
rule all:
input:
expand("Samples/transformed/{sample}.fastq", sample=SAMPLES),
expand("Results/{sample}/FastQC_Files/", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_Mapping_Rates.json", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_Gene_Counts.json", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_Cell_Numbers.json", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_UMI_Counts.json", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_Mapping_Rates_Sample.json", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_Gene_Counts_Sample.json", sample=SAMPLES),
expand("Results/{sample}/{sample}_Demultiplexed.zip", sample=SAMPLES),
"Results/wasp_results.html"
# Transforming reads if necessary
......@@ -360,3 +352,28 @@ rule geneCountSample:
shell:
"Scripts/gene_counting_json.py {input} {wildcards.sample}"
# Tar & zip Results directory
rule tarZip:
input:
expand("Results/{sample}/FastQC_Files/", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_Mapping_Rates.json", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_Gene_Counts.json", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_Cell_Numbers.json", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_UMI_Counts.json", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_Mapping_Rates_Sample.json", sample=SAMPLES),
expand("Results/{sample}/JSON_Files/{sample}_Gene_Counts_Sample.json", sample=SAMPLES),
expand("Results/{sample}/{sample}_Demultiplexed.zip", sample=SAMPLES),
output:
"S3Upload/results.tar.gz"
shell:
"tar cfz S3Upload/results.tar.gz Results/"
# S3Upload
rule s3Upload:
input:
"S3Upload/results.tar.gz"
output:
"Results/wasp_results.html"
shell:
"Scripts/uploadS3.py"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment