aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>2020-08-07 15:28:27 +0000
committerGitHub <noreply@github.com>2020-08-07 15:28:27 +0000
commit69a6ef3a23ab68ccce0bb33d9e8251edfe3da4b5 (patch)
tree1ddac309ee8694f1d606b41a219ee4350848dd0e
parent64b51efa0c9979a39bf6f957a61793cd1281ee77 (diff)
Format code with Black
-rw-r--r--scripts/quick-ligand-protein.py73
1 files changed, 46 insertions, 27 deletions
diff --git a/scripts/quick-ligand-protein.py b/scripts/quick-ligand-protein.py
index a300800..5873270 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,12 +105,12 @@ print("Starting PyMol Session")
session.start()
cmd = session.cmd
-loadMol(protein,m1)
-cmd.remove("resn hoh") # remove water
-cmd.color("blue","hetatm") # color heteroatoms
-loadMol(ligand,m2)
-changeColor(m1,"grey60")
-changeColor(m2,ligandColor)
+loadMol(protein, m1)
+cmd.remove("resn hoh") # remove water
+cmd.color("blue", "hetatm") # color heteroatoms
+loadMol(ligand, m2)
+changeColor(m1, "grey60")
+changeColor(m2, ligandColor)
orientEtZoom()
showSurface(m1)
surfaceTransparency(0.6)
@@ -99,4 +118,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.")