aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-07-07 12:22:30 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-07-07 12:22:30 +0530
commit6a67fd7e8b7e3244fb009e7101e5c501bf2439d8 (patch)
tree8a441b173047b57fa4a577e599df0370b86582e9
parentc74428d94a79087ca5aed2a23e1535864c924124 (diff)
removed extra files and changed zi to zipArchive
-rw-r--r--app/backend_test.py99
-rw-r--r--app/create_table.py17
-rw-r--r--app/dbTestFiller.py69
-rw-r--r--app/dock_docker.py4
-rw-r--r--app/test.py5
5 files changed, 2 insertions, 192 deletions
diff --git a/app/backend_test.py b/app/backend_test.py
deleted file mode 100644
index 6d3c8f7..0000000
--- a/app/backend_test.py
+++ /dev/null
@@ -1,99 +0,0 @@
-import mysql.connector as con
-
-mycon = con.connect(host="navanspi.duckdns.org",user="curieweb",password="curie-web-russian-54",port=3306,database="curie")
-mycursor = mycon.cursor()
-
-sql_select_Query = 'select * from curieweb where id="18u3r0chcf6nr6mj" LIMIT 1'
-mycursor.execute(sql_select_Query)
-
-records = mycursor.fetchall()
-
-def email(zi):
- 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"
- attachment = open((str(zi) + ".zip"), "rb")
- p = MIMEBase('application', 'octet-stream')
- 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()
-
-receptor_name = "protein.pdbqt"
-ligand_name = "ligand.pdbqt"
-description = "Curie Web Task"
-
-#print(records[0])
-r = records[0]
-jobID = r[0]
-toEmail = r[1]
-targetB = r[2]
-if r[3] != None:
- receptor_name = str(r[3])
-if r[6] != None:
- ligand_name = str(r[6])
-ligandB = r[4]
-configB = r[7]
-date = r[8]
-if r[9] != None:
- description = r[9]
-
-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())
- file = open(receptor_name,"wb")
- file.write(targetB)
- file.close()
- file = open(ligand_name,"wb")
- file.write(ligandB)
- file.close()
- file = open("config.txt","wb")
- file.write(configB)
- file.close()
- 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 config.txt -dpi" % (receptor_name,ligand_name))
- #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 curieweb set done=1 where id="%s"' % (jobID))
- mycon.commit() \ No newline at end of file
diff --git a/app/create_table.py b/app/create_table.py
deleted file mode 100644
index a431ba4..0000000
--- a/app/create_table.py
+++ /dev/null
@@ -1,17 +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()
-
-try:
- mycursor.execute("create table curie (id INT PRIMARY KEY, email VARCHAR(255), receptor VARCHAR(255), ligand VARCHAR(255), config VARCHAR(255), date DATE, description VARCHAR(255),done TINYINT DEFAULT 0)")
-except con.ProgrammingError:
- print("Table Already Exists!")
-
-try:
- mycursor.execute("insert into curie values (1,'navanchauhan@gmail.com','lu.pdbqt','test.pdbqt','owo.txt',CURDATE(),'CURIE WEB TASK',0)")
-except con.IntegrityError:
- print("Duplicate Entry For Primary Key!")
-
-mycon.commit() \ No newline at end of file
diff --git a/app/dbTestFiller.py b/app/dbTestFiller.py
deleted file mode 100644
index 48f8c16..0000000
--- a/app/dbTestFiller.py
+++ /dev/null
@@ -1,69 +0,0 @@
-import mysql.connector as con
-
-debug = False
-host = "navanspi.duckdns.org"
-done = 1
-
-if debug != False:
- host = "192.168.1.6"
- done = 0
-
-mycon = con.connect(host=host,user="curieweb",password="curie-web-russian-54",port=3306,database="curie")
-mycursor = mycon.cursor()
-
-try:
- mycursor.execute("create table curieweb ( id varchar(16) primary key, email nvarchar(255) NOT NULL, protein LONGBLOB NOT NULL, protein_name VARCHAR(255), ligand_pdbqt LONGBLOB, ligand_smile VARCHAR(255), ligand_name VARCHAR(255), config LONGBLOB NOT NULL, date DATE, description VARCHAR(255), done TINYINT DEFAULT 0)")
-except con.ProgrammingError:
- print("Table Already Exists!")
-
-#try:
-# mycursor.execute("insert into curieweb values (1,'navanchauhan@gmail.com','lu.pdbqt','test.pdbqt','owo.txt',CURDATE(),'CURIE WEB TASK',0)")
-#except con.IntegrityError:
-# print("Duplicate Entry For Primary Key!")
-
-from random import choice, shuffle
-from string import digits, ascii_lowercase
-
-def gen_word(N, min_N_dig, min_N_low):
- choose_from = [digits]*min_N_dig + [ascii_lowercase]*min_N_low
- choose_from.extend([digits + ascii_lowercase] * (N-min_N_low-min_N_dig))
- chars = [choice(bet) for bet in choose_from]
- shuffle(chars)
- return ''.join(chars)
-
-def convertToBinaryData(filename):
- with open(filename, 'rb') as file:
- binaryData = file.read()
- return binaryData
-
-from os.path import basename
-
-ligand = convertToBinaryData("./static/uploads/ligands/test.pdbqt")
-receptor = convertToBinaryData("static/uploads/receptor/lu.pdbqt")
-config = convertToBinaryData("static/uploads/configs/owo.txt")
-ligandName = "Eucalyptol"
-receptorName = "6LU7"
-
-sqlQuery = "insert into curieweb (id, email, protein, protein_name, ligand_pdbqt, ligand_name,date, config,done) values (%s,%s,%s,%s,%s,%s,CURDATE(),%s,%s) "
-
-jobID = gen_word(16, 1, 1)
-print("Succesfuly submitted Job ID:",jobID)
-
-insert_tuple = (jobID,"navanchauhan@gmail.com",receptor,receptorName,ligand,ligandName,config,done)
-
-try:
- mycursor.execute(sqlQuery,insert_tuple)
-except con.IntegrityError:
- print("Oops, Collision occured. Generating new Job ID and trying again.")
- jobID = gen_word(16, 1, 1)
- insert_tuple = (jobID,"navanchauhan@gmail.com",receptor,receptorName,ligand,ligandName,config,done)
- mycursor.execute(sqlQuery,insert_tuple)
-
-print("Removing Test Query")
-
-q = 'delete from curieweb where id="%s"' % (jobID)
-mycursor.execute(q)
-
-mycon.commit()
-
-print("Database working perfectly") \ No newline at end of file
diff --git a/app/dock_docker.py b/app/dock_docker.py
index 2b0c959..e1b17d1 100644
--- a/app/dock_docker.py
+++ b/app/dock_docker.py
@@ -8,7 +8,7 @@ mycursor.execute(sql_select_Query)
records = mycursor.fetchall()
-def email(zi):
+def email(zipArchive):
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@@ -26,7 +26,7 @@ def email(zi):
msg.attach(MIMEText(body, 'plain'))
filename = "Curie_Web_Results_Job_ID_" + str(jobID) + ".zip"
- attachment = open((str(zi) + ".zip"), "rb")
+ attachment = open((str(zipArchive) + ".zip"), "rb")
p = MIMEBase('application', 'octet-stream')
p.set_payload((attachment).read())
encoders.encode_base64(p)
diff --git a/app/test.py b/app/test.py
deleted file mode 100644
index dddc9e7..0000000
--- a/app/test.py
+++ /dev/null
@@ -1,5 +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()
-mycursor.execute("SELECT COUNT(*) FROM curie")
-id = mycursor.fetchall()[0][0] \ No newline at end of file