aboutsummaryrefslogtreecommitdiff
path: root/app/dock-single.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/dock-single.py')
-rw-r--r--app/dock-single.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/app/dock-single.py b/app/dock-single.py
index be623f7..a94f3e9 100644
--- a/app/dock-single.py
+++ b/app/dock-single.py
@@ -90,6 +90,16 @@ def bounding_box(receptor, residues):
return {"size_x": SizeX, "size_y": SizeY, "size_z": SizeZ, "center_x": CenterX, "center_y": CenterY, "center_z": CenterZ}
+def get3DModel(protein,ligand):
+ import pymol2
+ session = pymol2.PyMOL()
+ session.start()
+ cmd = session.cmd
+ cmd.load(protein,"target")
+ cmd.load(ligand,"ligand")
+ cmd.save("model.dae")
+ session.stop()
+
def removeWater(pdbpath):
import pymol2
session = pymol2.PyMOL()
@@ -202,11 +212,13 @@ date = records[6]
import os
cd = os.getcwd()
f = os.path.join(cd,"static/uploads")
+reportDirectory = os.path.join(f,"reports")
+modelDirectory = os.path.join(f,"3DModels")
#t = os.path.join(f,"receptor",target)
#r = os.path.join(f,"ligands",ligand)
#c = os.path.join(f,"configs",config)
import tempfile
-from shutil import make_archive
+from shutil import make_archive, copyfile
import time
with tempfile.TemporaryDirectory() as directory:
@@ -228,6 +240,19 @@ with tempfile.TemporaryDirectory() as directory:
z = "Curie_Web_Result_"+str(jobID)
zi = os.path.join(f,z)
make_archive(zi, 'zip', directory)
+ copyfile("report.pdf",os.path.join(reportDirectory,(str(jobID)+".pdf")))
+ get3DModel(pdbpath,"%s_out.pdbqt"%(records[4]))
+ os.system("collada2gltf -i model.dae -o model.gltf")
+ copyfile("model.gltf",os.path.join(modelDirectory,(str(jobID)+".gltf")))
+ arch = os.popen("uname -m").read()
+ if "x86" in arch:
+ os.system("docker run -it --rm -v $(pwd):/usr/app leon/usd-from-gltf:latest model.gltf model.usdz")
+ elif "aarch64" in arch:
+ os.system("docker run -it --rm -v $(pwd):/usr/app navanchauhan/usd-from-gltf:latest model.gltf model.usdz")
+ try:
+ copyfile("model.usdz",os.path.join(modelDirectory,(str(jobID)+".usdz")))
+ except:
+ print("Could not generate USDZ file")
#copy(("Curie_Web_Result_"+str(jobID)),f)
email(zi)
#print((str(zi) + ".zip"))