aboutsummaryrefslogtreecommitdiff
path: root/scripts/quick-ligand-protein.py
diff options
context:
space:
mode:
authordeepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>2020-07-07 14:55:17 +0000
committerGitHub <noreply@github.com>2020-07-07 14:55:17 +0000
commit0d135d611506e81d322596c7827b08bbfd3b7c08 (patch)
treea281b8e1f140ad3de77d818747fce03bcfa5b77b /scripts/quick-ligand-protein.py
parent7059ee2a4ced23e467741cc846eb185886ffca38 (diff)
Format code with Blackdeepsource-transform-b65b5545
Diffstat (limited to 'scripts/quick-ligand-protein.py')
-rw-r--r--scripts/quick-ligand-protein.py69
1 files changed, 44 insertions, 25 deletions
diff --git a/scripts/quick-ligand-protein.py b/scripts/quick-ligand-protein.py
index faff403..e211844 100644
--- a/scripts/quick-ligand-protein.py
+++ b/scripts/quick-ligand-protein.py
@@ -1,12 +1,14 @@
#!/usr/bin/python3
import argparse
-#import logzero
-#import logging
-#from logzero import logger as log
+
+# import logzero
+# import logging
+# from logzero import logger as log
import pymol2
import time
import os
+
print(os.getcwd())
#################
@@ -17,7 +19,7 @@ startTime = time.time()
version = "1.0"
desc_text = "PyMol Quick Visualtion " + version
ligandColor = "red"
-#logzero.loglevel(logging.INFO)
+# logzero.loglevel(logging.INFO)
height = 1000
width = 800
dpi = 300
@@ -28,9 +30,9 @@ m1 = "target"
m2 = "ligand"
parser = argparse.ArgumentParser(description=desc_text)
-parser.add_argument("-p","--protein",help="Path to protein file")
-parser.add_argument("-l","--ligand",help="Path to ligand_out file")
-parser.add_argument("-c","--color",help="Color for ligand in visualisation")
+parser.add_argument("-p", "--protein", help="Path to protein file")
+parser.add_argument("-l", "--ligand", help="Path to ligand_out file")
+parser.add_argument("-c", "--color", help="Color for ligand in visualisation")
args = parser.parse_args()
@@ -47,38 +49,55 @@ protein = args.protein
print("Protein: ", protein)
ligand = args.ligand
+
def loadMol(filename, name):
print("Loading " + filename + " as " + name)
- cmd.load(filename,name)
+ cmd.load(filename, name)
+
+
def changeColor(name, colorName):
print("Changed " + name + "'s color to " + colorName)
- cmd.color(colorName,name)
+ cmd.color(colorName, name)
+
+
def orientEtZoom():
cmd.orient()
cmd.zoom()
+
+
def showSurface(name):
- cmd.show("surface",name)
+ cmd.show("surface", name)
+
+
def surfaceTransparency(amount):
- print("Changed surface transparency to " + str(amount*100) + "%")
- cmd.set("transparency",amount)
-def generatePNG(filename,height=height,width=width,dpi=dpi,ray=ray):
+ print("Changed surface transparency to " + str(amount * 100) + "%")
+ cmd.set("transparency", amount)
+
+
+def generatePNG(filename, height=height, width=width, dpi=dpi, ray=ray):
print("Generating " + filename + ".png")
- cmd.png(filename,height,width,dpi=dpi,ray=ray)
+ cmd.png(filename, height, width, dpi=dpi, ray=ray)
+
+
def flipHorizontal():
- cmd.rotate("y",180)
+ cmd.rotate("y", 180)
+
+
def zoomTo(name):
cmd.zoom(name)
+
+
def generatePictures():
- generatePNG('output-front')
+ generatePNG("output-front")
flipHorizontal()
- generatePNG('output-back')
+ generatePNG("output-back")
zoomTo(m2)
- generatePNG('closeup-back')
+ generatePNG("closeup-back")
orientEtZoom()
flipHorizontal()
zoomTo(m2)
- generatePNG('closeup-front')
-
+ generatePNG("closeup-front")
+
print("Initialising PyMol")
session = pymol2.PyMOL()
@@ -86,10 +105,10 @@ print("Starting PyMol Session")
session.start()
cmd = session.cmd
-loadMol(protein,m1)
-loadMol(ligand,m2)
-changeColor(m1,"grey60")
-changeColor(m2,ligandColor)
+loadMol(protein, m1)
+loadMol(ligand, m2)
+changeColor(m1, "grey60")
+changeColor(m2, ligandColor)
orientEtZoom()
showSurface(m1)
surfaceTransparency(0.6)
@@ -97,4 +116,4 @@ surfaceTransparency(0.6)
generatePictures()
endTime = time.time()
-print("Finished Execution in " + str(round((endTime - startTime),2)) + " seconds.")
+print("Finished Execution in " + str(round((endTime - startTime), 2)) + " seconds.")