aboutsummaryrefslogtreecommitdiff
path: root/plip/visualization/chimera.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 /plip/visualization/chimera.py
parent7059ee2a4ced23e467741cc846eb185886ffca38 (diff)
Format code with Blackdeepsource-transform-b65b5545
Diffstat (limited to 'plip/visualization/chimera.py')
-rw-r--r--plip/visualization/chimera.py84
1 files changed, 56 insertions, 28 deletions
diff --git a/plip/visualization/chimera.py b/plip/visualization/chimera.py
index a37fffb..436d0e3 100644
--- a/plip/visualization/chimera.py
+++ b/plip/visualization/chimera.py
@@ -5,8 +5,8 @@ class ChimeraVisualizer:
self.chimera = chimera_module
self.tid = tid
self.uid = plcomplex.uid
- self.plipname = 'PLIP-%i' % self.tid
- self.hetid, self.chain, self.pos = self.uid.split(':')
+ self.plipname = "PLIP-%i" % self.tid
+ self.hetid, self.chain, self.pos = self.uid.split(":")
self.pos = int(self.pos)
self.colorbyname = self.chimera.colorTable.getColorByName
self.rc = self.chimera.runCommand
@@ -32,7 +32,10 @@ class ChimeraVisualizer:
self.update_model_dict()
self.rc("background solid white")
self.rc("setattr g display 0") # Hide all pseudobonds
- self.rc("~display #%i & :/isHet & ~:%s" % (self.model_dict[self.plipname], self.hetid))
+ self.rc(
+ "~display #%i & :/isHet & ~:%s"
+ % (self.model_dict[self.plipname], self.hetid)
+ )
def update_model_dict(self):
"""Updates the model dictionary"""
@@ -51,39 +54,47 @@ class ChimeraVisualizer:
def show_hydrophobic(self):
"""Visualizes hydrophobic contacts."""
- grp = self.getPseudoBondGroup("Hydrophobic Interactions-%i" % self.tid, associateWith=[self.model])
+ grp = self.getPseudoBondGroup(
+ "Hydrophobic Interactions-%i" % self.tid, associateWith=[self.model]
+ )
grp.lineType = self.chimera.Dash
grp.lineWidth = 3
- grp.color = self.colorbyname('gray')
+ grp.color = self.colorbyname("gray")
for i in self.plcomplex.hydrophobic_contacts.pairs_ids:
self.bs_res_ids.append(i[0])
def show_hbonds(self):
"""Visualizes hydrogen bonds."""
- grp = self.getPseudoBondGroup("Hydrogen Bonds-%i" % self.tid, associateWith=[self.model])
+ grp = self.getPseudoBondGroup(
+ "Hydrogen Bonds-%i" % self.tid, associateWith=[self.model]
+ )
grp.lineWidth = 3
for i in self.plcomplex.hbonds.ldon_id:
b = grp.newPseudoBond(self.atoms[i[0]], self.atoms[i[1]])
- b.color = self.colorbyname('blue')
+ b.color = self.colorbyname("blue")
self.bs_res_ids.append(i[0])
for i in self.plcomplex.hbonds.pdon_id:
b = grp.newPseudoBond(self.atoms[i[0]], self.atoms[i[1]])
- b.color = self.colorbyname('blue')
+ b.color = self.colorbyname("blue")
self.bs_res_ids.append(i[1])
def show_halogen(self):
"""Visualizes halogen bonds."""
- grp = self.getPseudoBondGroup("HalogenBonds-%i" % self.tid, associateWith=[self.model])
+ grp = self.getPseudoBondGroup(
+ "HalogenBonds-%i" % self.tid, associateWith=[self.model]
+ )
grp.lineWidth = 3
for i in self.plcomplex.halogen_bonds:
b = grp.newPseudoBond(self.atoms[i[0]], self.atoms[i[1]])
- b.color = self.colorbyname('turquoise')
+ b.color = self.colorbyname("turquoise")
self.bs_res_ids.append(i.acc_id)
def show_stacking(self):
"""Visualizes pi-stacking interactions."""
- grp = self.getPseudoBondGroup("pi-Stacking-%i" % self.tid, associateWith=[self.model])
+ grp = self.getPseudoBondGroup(
+ "pi-Stacking-%i" % self.tid, associateWith=[self.model]
+ )
grp.lineWidth = 3
grp.lineType = self.chimera.Dash
for i, stack in enumerate(self.plcomplex.pistacking):
@@ -101,13 +112,15 @@ class ChimeraVisualizer:
r.addAtom(centroid_lig)
b = grp.newPseudoBond(centroid_lig, centroid_prot)
- b.color = self.colorbyname('forest green')
+ b.color = self.colorbyname("forest green")
self.bs_res_ids += stack.proteinring_atoms
def show_cationpi(self):
"""Visualizes cation-pi interactions"""
- grp = self.getPseudoBondGroup("Cation-Pi-%i" % self.tid, associateWith=[self.model])
+ grp = self.getPseudoBondGroup(
+ "Cation-Pi-%i" % self.tid, associateWith=[self.model]
+ )
grp.lineWidth = 3
grp.lineType = self.chimera.Dash
for i, cat in enumerate(self.plcomplex.pication):
@@ -125,7 +138,7 @@ class ChimeraVisualizer:
r.addAtom(centroid)
b = grp.newPseudoBond(centroid, chargecenter)
- b.color = self.colorbyname('orange')
+ b.color = self.colorbyname("orange")
if cat.protcharged:
self.bs_res_ids += cat.charge_atoms
@@ -135,7 +148,9 @@ class ChimeraVisualizer:
def show_sbridges(self):
"""Visualizes salt bridges."""
# Salt Bridges
- grp = self.getPseudoBondGroup("Salt Bridges-%i" % self.tid, associateWith=[self.model])
+ grp = self.getPseudoBondGroup(
+ "Salt Bridges-%i" % self.tid, associateWith=[self.model]
+ )
grp.lineWidth = 3
grp.lineType = self.chimera.Dash
for i, sbridge in enumerate(self.plcomplex.saltbridges):
@@ -153,7 +168,7 @@ class ChimeraVisualizer:
r.addAtom(chargecenter2)
b = grp.newPseudoBond(chargecenter1, chargecenter2)
- b.color = self.colorbyname('yellow')
+ b.color = self.colorbyname("yellow")
if sbridge.protispos:
self.bs_res_ids += sbridge.positive_atoms
@@ -162,14 +177,20 @@ class ChimeraVisualizer:
def show_wbridges(self):
"""Visualizes water bridges"""
- grp = self.getPseudoBondGroup("Water Bridges-%i" % self.tid, associateWith=[self.model])
+ grp = self.getPseudoBondGroup(
+ "Water Bridges-%i" % self.tid, associateWith=[self.model]
+ )
grp.lineWidth = 3
for i, wbridge in enumerate(self.plcomplex.waterbridges):
- c = grp.newPseudoBond(self.atoms[wbridge.water_id], self.atoms[wbridge.acc_id])
- c.color = self.colorbyname('cornflower blue')
+ c = grp.newPseudoBond(
+ self.atoms[wbridge.water_id], self.atoms[wbridge.acc_id]
+ )
+ c.color = self.colorbyname("cornflower blue")
self.water_ids.append(wbridge.water_id)
- b = grp.newPseudoBond(self.atoms[wbridge.don_id], self.atoms[wbridge.water_id])
- b.color = self.colorbyname('cornflower blue')
+ b = grp.newPseudoBond(
+ self.atoms[wbridge.don_id], self.atoms[wbridge.water_id]
+ )
+ b.color = self.colorbyname("cornflower blue")
self.water_ids.append(wbridge.water_id)
if wbridge.protisdon:
self.bs_res_ids.append(wbridge.don_id)
@@ -178,16 +199,20 @@ class ChimeraVisualizer:
def show_metal(self):
"""Visualizes metal coordination."""
- grp = self.getPseudoBondGroup("Metal Coordination-%i" % self.tid, associateWith=[self.model])
+ grp = self.getPseudoBondGroup(
+ "Metal Coordination-%i" % self.tid, associateWith=[self.model]
+ )
grp.lineWidth = 3
for i, metal in enumerate(self.plcomplex.metal_complexes):
- c = grp.newPseudoBond(self.atoms[metal.metal_id], self.atoms[metal.target_id])
- c.color = self.colorbyname('magenta')
+ c = grp.newPseudoBond(
+ self.atoms[metal.metal_id], self.atoms[metal.target_id]
+ )
+ c.color = self.colorbyname("magenta")
- if metal.location == 'water':
+ if metal.location == "water":
self.water_ids.append(metal.target_id)
- if metal.location.startswith('protein'):
+ if metal.location.startswith("protein"):
self.bs_res_ids.append(metal.target_id)
def cleanup(self):
@@ -197,13 +222,16 @@ class ChimeraVisualizer:
# Hide all non-interacting water molecules
water_selection = []
for wid in self.water_ids:
- water_selection.append('serialNumber=%i' % wid)
+ water_selection.append("serialNumber=%i" % wid)
self.rc("~display :HOH")
self.rc("display :@/%s" % " or ".join(water_selection))
# Show all interacting binding site residues
self.rc("~display #%i & ~:/isHet" % self.model_dict[self.plipname])
- self.rc("display :%s" % ",".join([str(self.atoms[bsid].residue.id) for bsid in self.bs_res_ids]))
+ self.rc(
+ "display :%s"
+ % ",".join([str(self.atoms[bsid].residue.id) for bsid in self.bs_res_ids])
+ )
self.rc("color lightblue :HOH")
def zoom_to_ligand(self):