Server script (run_gemmi.py) for minimapai.de

 avatar
jbcooper
python
2 years ago
1.0 kB
4
Indexable
Never
Mini Map Aide
#!/usr/bin/python3
import cgi
import os
import cgitb
import subprocess
print("Content-type:text/html\r\n\r\n") # needed
cgitb.enable()
form = cgi.FieldStorage()
pdbfile = form["pdbfile"]
pdbname = os.path.basename(pdbfile.filename)
open("/var/www/html/temp/" + pdbname, "wb").write(pdbfile.file.read())
#message = "<p>The file " + pdbname + " was uploaded successfully</p>"
#print(message)
mtzfile = form["mtzfile"]
mtzname = os.path.basename(mtzfile.filename)
open("/var/www/html/temp/" + mtzname, "wb").write(mtzfile.file.read())
#message = "<p>The file " + mtzname + " was uploaded successfully</p>"
#print(message)
diffneeded = form.getvalue("diffneeded")
#print(diffneeded)
mapname=mtzname.split(".",1)[0]
if diffneeded=="true": gemmiproc=["gemmi","sf2map","-d","-s3","--mapmask=../temp/"+pdbname,"../temp/"+mtzname,"../temp/"+mapname+"_diff.map"]
else: gemmiproc=["gemmi","sf2map","-s3","--mapmask=../temp/"+pdbname,"../temp/"+mtzname,"../temp/"+mapname+".map"]
#print("<p>",gemmiproc,"</p>")
gemmirun=subprocess.run(gemmiproc)