aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-09-02 18:15:21 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-09-02 18:15:21 +0530
commitf6196ac068280e76e096ff6a1c66e584ec8cbaa7 (patch)
tree0a97046bea7ea9117f828f2d5781be9e47297519 /app
parent9e749e326bbcf72c575798b8b5f6bfc99053efb2 (diff)
added instructions in README and deleted misc file
Diffstat (limited to 'app')
-rw-r--r--app/run_docking.py82
-rw-r--r--app/run_local.py82
-rw-r--r--app/views.py3
3 files changed, 2 insertions, 165 deletions
diff --git a/app/run_docking.py b/app/run_docking.py
deleted file mode 100644
index 1b86d92..0000000
--- a/app/run_docking.py
+++ /dev/null
@@ -1,82 +0,0 @@
-import mysql.connector as con
-
-mycon = con.connect(host="sql12.freesqldatabase.com",user="sql12352288",password="7X35JENbK3",port=3306,database="sql12352288")
-mycursor = mycon.cursor()
-
-sql_select_Query = "select * from curie where done=0 LIMIT 1"
-mycursor.execute(sql_select_Query)
-
-records = mycursor.fetchall()
-
-def email(zipArchive):
- import smtplib
- from email.mime.multipart import MIMEMultipart
- from email.mime.text import MIMEText
- from email.mime.base import MIMEBase
- from email import encoders
-
- fromaddr = "navanchauhan@gmail.com"
- toaddr = toEmail
-
- msg = MIMEMultipart()
- msg['From'] = fromaddr
- msg['To'] = toaddr
- msg['Subject'] = "Curie Web Results for Job ID " + str(jobID)
- body = "Attached Zip contains the docked files, PLIP report and PyMOL Visualisations. If the ZIP file does not contain these files, please report this issue by replying to this email. Job was submitted on {} with the description {}".format(date, description)
-
- msg.attach(MIMEText(body, 'plain'))
- filename = "Curie_Web_Results_Job_ID_" + str(jobID) + ".zip"
- p = MIMEBase('application', 'octet-stream')
- with open((str(zipArchive) + ".zip"), "rb") as attachment:
- p.set_payload((attachment).read())
- encoders.encode_base64(p)
- p.add_header('Content-Disposition', "attachment; filename= %s" % filename)
- msg.attach(p)
-
- s = smtplib.SMTP('smtp.gmail.com', 587)
- s.starttls()
- s.login(fromaddr, 'ircd mday avbc tice')
-
- text = msg.as_string()
-
- s.sendmail(fromaddr, toaddr, text)
- s.quit()
-
-
-print(records[0])
-r = records[0]
-jobID = r[0]
-toEmail = r[1]
-target = r[2]
-ligand = r[3]
-config = r[4]
-date = r[5]
-description = r[6]
-
-import os
-cd = os.getcwd()
-f = os.path.join(cd,"static/uploads")
-t = os.path.join(f,"receptor",target)
-r = os.path.join(f,"ligands",ligand)
-c = os.path.join(f,"configs",config)
-print(f)
-import tempfile
-from shutil import copy
-from shutil import make_archive
-
-with tempfile.TemporaryDirectory() as directory:
- print('The created temporary directory is %s' % directory)
- os.chdir(directory)
- copy(t,os.getcwd())
- copy(r,os.getcwd())
- copy(c, os.getcwd())
- os.system("docker run --rm -v ${PWD}:/results -w /results -u $(id -u ${USER}):$(id -g ${USER}) navanchauhan/curie-cli -r %s -l %s -c %s -dpi" % (target,ligand,config))
- #copy("report.pdf",f)
- z = "Curie_Web_Result_"+str(jobID)
- zi = os.path.join(f,z)
- make_archive(zi, 'zip', directory)
- #copy(("Curie_Web_Result_"+str(jobID)),f)
- email(zi)
- #print((str(zi) + ".zip"))
- mycursor.execute("UPDATE curie set done=1 where id={}".format(jobID))
- mycon.commit() \ No newline at end of file
diff --git a/app/run_local.py b/app/run_local.py
deleted file mode 100644
index 4b902d2..0000000
--- a/app/run_local.py
+++ /dev/null
@@ -1,82 +0,0 @@
-import mysql.connector as con
-
-mycon = con.connect(host="sql12.freesqldatabase.com",user="sql12352288",password="7X35JENbK3",port=3306,database="sql12352288")
-mycursor = mycon.cursor()
-
-sql_select_Query = "select * from curie where done=0 LIMIT 1"
-mycursor.execute(sql_select_Query)
-
-records = mycursor.fetchall()
-
-def email(zipArchive):
- import smtplib
- from email.mime.multipart import MIMEMultipart
- from email.mime.text import MIMEText
- from email.mime.base import MIMEBase
- from email import encoders
-
- fromaddr = "navanchauhan@gmail.com"
- toaddr = toEmail
-
- msg = MIMEMultipart()
- msg['From'] = fromaddr
- msg['To'] = toaddr
- msg['Subject'] = "Curie Web Results for Job ID " + str(jobID)
- body = "Attached Zip contains the docked files, PLIP report and PyMOL Visualisations. If the ZIP file does not contain these files, please report this issue by replying to this email. Job was submitted on {} with the description {}".format(date, description)
-
- msg.attach(MIMEText(body, 'plain'))
- filename = "Curie_Web_Results_Job_ID_" + str(jobID) + ".zip"
- p = MIMEBase('application', 'octet-stream')
- with open((str(zipArchive) + ".zip"), "rb") as attachment:
- p.set_payload((attachment).read())
- encoders.encode_base64(p)
- p.add_header('Content-Disposition', "attachment; filename= %s" % filename)
- msg.attach(p)
-
- s = smtplib.SMTP('smtp.gmail.com', 587)
- s.starttls()
- s.login(fromaddr, 'ircd mday avbc tice')
-
- text = msg.as_string()
-
- s.sendmail(fromaddr, toaddr, text)
- s.quit()
-
-
-print(records[0])
-r = records[0]
-jobID = r[0]
-toEmail = r[1]
-target = r[2]
-ligand = r[3]
-config = r[4]
-date = r[5]
-description = r[6]
-
-import os
-cd = os.getcwd()
-f = os.path.join(cd,"static/uploads")
-t = os.path.join(f,"receptor",target)
-r = os.path.join(f,"ligands",ligand)
-c = os.path.join(f,"configs",config)
-print(f)
-import tempfile
-from shutil import copy
-from shutil import make_archive
-
-with tempfile.TemporaryDirectory() as directory:
- print('The created temporary directory is %s' % directory)
- os.chdir(directory)
- copy(t,os.getcwd())
- copy(r,os.getcwd())
- copy(c, os.getcwd())
- os.system("main_local.sh -r %s -l %s -c %s -dpi" % (target,ligand,config))
- #copy("report.pdf",f)
- z = "Curie_Web_Result_"+str(jobID)
- zi = os.path.join(f,z)
- make_archive(zi, 'zip', directory)
- #copy(("Curie_Web_Result_"+str(jobID)),f)
- email(zi)
- #print((str(zi) + ".zip"))
- mycursor.execute("UPDATE curie set done=1 where id={}".format(jobID))
- mycon.commit()
diff --git a/app/views.py b/app/views.py
index 65dd4a9..86a01fd 100644
--- a/app/views.py
+++ b/app/views.py
@@ -222,7 +222,8 @@ def dock_upload():
mycon.commit()
print("Description",description)
-
+ cwd = os.path.join(os.getcwd(),"app")
+ subprocess.Popen(['python3', 'dock-docker.py'],cwd=cwd)
return render_template('display_result.html', filename="OwO", description=description,job=jobID)
flash_errors(form)