def test_pseudoatom(self): self.pymol_file.commands += PyMOLCommands.pseudoatom( "mypseudoatom", (1, 1, 1), self.pomegranate) self.pymol_file.commands += PyMOLCommands.pseudoatom( "mypseudoatom2", (2, 2, 2), self.pomegranate, "31.2") self.pymol_file.write("testdata/wrapper_pymol/test_pseudoatom.py")
def test_group(self): self.pymol_file.commands += PyMOLCommands.line("myline1", (0, 0, 0), (1, 1, 1), self.pomegranate, width=10) self.pymol_file.commands += PyMOLCommands.pseudoatom( "mypseudoatom1", (0, 0, 0), self.pomegranate) self.pymol_file.commands += PyMOLCommands.pseudoatom( "mypseudoatom2", (1, 1, 1), self.pomegranate) self.pymol_file.commands += PyMOLCommands.group( "mygroup", ["myline1", "mypseudoatom1", "mypseudoatom2"]) self.pymol_file.write("testdata/wrapper_pymol/test_group.py")
def to_pymol_str(self, i=0, label=True, transparency=0.6): pymol_out = "" point_colour = rgb_to_decimal(self.colour) point_colour = utilities.Colour(point_colour[0], point_colour[1], point_colour[2], transparency) feat_ID = f"{self.identifier}_{i}" group = [] coords = (self.point[0].centre[0], self.point[0].centre[1], self.point[0].centre[2]) radius = self.point[0].radius point_objname = f"{self.identifier}_point_{i}" pymol_out += PyMOLCommands.sphere(point_objname, point_colour, coords, radius=radius) pymol_out += PyMOLCommands.load_cgo(point_objname, f"{point_objname}_obj") group.append(f"{point_objname}_obj") if self.score != 0 and label: score_name = f"{point_objname}_score" pymol_out += PyMOLCommands.pseudoatom( objname=score_name, coords=coords, label=f'{round(self.score, 1)}') group.append(score_name) rank_name = f"{self.identifier}_rank_{i}" pymol_out += PyMOLCommands.pseudoatom(objname=rank_name, coords=coords, label=str(i + 1)) group.append(rank_name) if self.projected: proj_coords = (self.projected[0].centre[0], self.projected[0].centre[1], self.projected[0].centre[2]) projection_objname = f"{self.identifier}_projection_{i}" line_objname = f"{self.identifier}_line_{i}" group.extend([projection_objname, line_objname]) if self.projected_value != 0 and label: proj_score_name = f"{point_objname}_proj_score" pymol_out += PyMOLCommands.pseudoatom( objname=proj_score_name, coords=proj_coords, label=f'{round(self.projected_value, 1)}') group.append(proj_score_name) projected_colour = adjust_lightness(self.colour, percentage=30) projected_colour = utilities.Colour(projected_colour[0], projected_colour[1], projected_colour[2], transparency) projected_radius = self.projected[0].radius pymol_out += PyMOLCommands.sphere(projection_objname, projected_colour, proj_coords, radius=projected_radius) pymol_out += PyMOLCommands.load_cgo(projection_objname, f"{projection_objname}_obj") pymol_out += PyMOLCommands.line(line_objname, coords, proj_coords, rgb=projected_colour) pymol_out += PyMOLCommands.group(feat_ID, group) return pymol_out
def _write_pymol_objects(self, relpath, hr, load_prot=True): """ generates pymol commands associated with an indivdual hotspot :param relpath: path to the directory holding associated files :param hr: hotspot result :type relpath: str :type hr: `hotspots.results.Results` """ self.pymol_out.commands += self._write_pymol_isosurfaces( hr.super_grids, relpath, hr.identifier, "fhm") if self.settings.output_superstar and hr.superstar: self.pymol_out.commands += self._write_pymol_isosurfaces( hr.superstar, relpath, hr.identifier, "superstar") if self.settings.output_weighted and hr.weighted_superstar: self.pymol_out.commands += self._write_pymol_isosurfaces( hr.weighted_superstar, relpath, hr.identifier, "weighted") if self.settings.output_buriedness and hr.buriedness: default_level = 3 objname = f'buriedness_{hr.identifier}' fname = f'{relpath}/buriedness{self.settings.grid_extension}' self.pymol_out.commands += PyMOLCommands.load(fname=fname, objname=objname) # surface_10_apolar_hotspotid surface_objname = f'surface_{objname}' self.pymol_out.commands += PyMOLCommands.isosurface( grd_name=objname, isosurface_name=surface_objname, level=default_level, color=self.settings.colour_dict["buriedness"]) self.pymol_out.commands += PyMOLCommands.pymol_set( setting_name='transparency', value=self.settings.transparency, selection=surface_objname) group_members = [ f'buriedness_{hr.identifier}', f'surface_buriedness_{hr.identifier}' ] self.pymol_out.commands += PyMOLCommands.group( group_name=hr.identifier, members=group_members) # generate grid labels labels = hr.grid_labels() for p, dic in labels.items(): i = 0 group_me = [] for coord, value in dic.items(): objname = f"PS_{p}_{hr.identifier}_{i}" group_me.append(objname) self.pymol_out.commands += PyMOLCommands.pseudoatom( objname=objname, coords=coord, label=f'{round(value, 1)}') group_me.append(objname) i += 1 self.pymol_out.commands += PyMOLCommands.group( f'label_{p}_{hr.identifier}', group_me) self.pymol_out.commands += PyMOLCommands.group( f"labels_{hr.identifier}", [f'label_{p}_{hr.identifier}' for p in hr.super_grids.keys()]) # load up the protein if load_prot: self.pymol_out.commands += PyMOLCommands.load( f'{relpath}/protein.pdb', f'protein_{hr.identifier}') if len(self.settings.protein_color_dic) > 0: self.pymol_out += PyMOLCommands.color( "slate", f'protein_{hr.identifier}') self.pymol_out.commands += PyMOLCommands.show( "cartoon", f'protein_{hr.identifier}') self.pymol_out.commands += PyMOLCommands.hide( "line", f'protein_{hr.identifier}') self.pymol_out.commands += PyMOLCommands.show("sticks", "organic")