polychrom.pymol_show module

This class is a collection of functions for showing data with pymol. Note that the limit of pymol is 100k monomers, therefore interpolateData is useful to collapse the 200k-long simulation into a 100k-long conformation.

polychrom.pymol_show.createRegions(a)[source]

Creates array of non-zero regions of a. if a is 0 1 1 0 1 0 result will be (1,3), (4,5), because elements 1,2 and 4 are non-zero.

polychrom.pymol_show.do_coloring(data, regions, colors, transparencies, showGui=True, saveTo=None, showChain='worm', returnScriptName=None, showMainChain=True, chainRadius=0.02, subchainRadius=0.04, chainTransparency=0.5, support='', transparentBackground=True, multiplier=0.4, spherePositions=[], pdbGroups=None, sphereRadius=0.3, sphereColor='grey60', force=False, miscArguments='')[source]

!!! Please read this completely. Otherwise you’ll suck :( !!!

Creates a PDB file and a rasmol script that shows an XYZ polymer using pymol. Polymer consists of two parts: chain and subchain. A chain is a grey polymer, that is meant to resemble the main chain. It is meant to be thin, gray and transparent (overall, here transparency 1 means transparent, transparency 0 means fully visible). A subchain consists of a certain number of regions, each has it’s own color, transparency, etc.

Parameters
  • data (an Nx3 array of XYZ coordinates) –

  • regions (a list of tuples (start, end)) – Note that rasmol acceps subchains in a format (first monomer, last monomer), not the usual python convention (first, last+1)!!! An overlap check will watch this. If you want two colorings to gradually transition into each other, then you should use ((0,10),(10,25),(25,…)).

colors : a list of colors (“red”, “green”, “blue”, etc.) for each region

transparencies : a list of floats between 0 and 1. 0 is fully visible

chain_radius : radius of a main chain in arbitraty units

subchain_radius : radius of a subchain in arbitrary units

chain_transparency : transparency of a main chain

supportcode to put at the end of the script

put all the “save” or “ray” commands here if you want automation

multipliera number, probably between .1 and 3

Increasing it makes chain more smooth Decreasing it makes it more kinky, but may cause bugs or even missing chain regions

misc_argumentsstr

Misc arguments to pymol command at the very end (mainly >/dev/null)

Warning

Do not call this scripy “pymol.py!”

Warning

Please resize the window to the needed size and run “ray” command (press “ray” button) to get a nice image. Then DO NOT MOVE the image and find “export” in the menu. Otherwise your image will be not that high quality

Note

performance of “ray” command depends on two things. First is resolution : it is more than quadratic in that Second is chain complexity. Tens thousand of monomers at high resolution may take up to an hour to ray. Though it actually looks awesome then!

Run an example method below to see how the code works. See full automation examples below.

polychrom.pymol_show.getTmpPath(folder=None, **kwargs)[source]
polychrom.pymol_show.interpolateData(data, targetN=90000, colorArrays=[])[source]

Converts a polymer of any length to a smoothed chain with (hopefully) fixed distance between neighboring monomers. Does it by cubic spline interpolation as following.

  1. Interpolate the data using cubic spline

  2. Evaluate cubic spline at targetN*10 values

  3. Rescale the evaluated spline such that total distance is targetN

4. Select targetN points along the path with distance between neighboring points _along the chain_ equal to 1.

Parameters
  • data (Nx3 array) – Input xyz coordinates

  • targetN (int) – Length of output polymer. It is not adviced to make it many times less than N

Returns

(about targetN) x 3 array

polychrom.pymol_show.makeMovie(fileList, imgFolder, fps=15, aviFilename='output.avi')[source]
polychrom.pymol_show.makeMoviePymol(fileList, destFolder, fps=10, aviFilename='output.avi', rotationPeriod=0.0, resolution=(600, 600), fiberWidth=1.0, rescalingFactor=1.0, pymolScript=None)[source]

experimental example script for making a movie…

polychrom.pymol_show.new_coloring(data, regions, colors, transparencies, showGui=True, saveTo=None, showChain='worm', returnScriptName=None, chainRadius=0.02, subchainRadius=0.04, chainTransparency=0.5, support='', presupport='', transparentBackground=True, multiplier=0.4, spherePositions=[], pdbGroups=None, sphereRadius=0.3, force=False, miscArguments='')[source]

!!! Please read this completely. Otherwise you’ll suck :( !!!

Creates a PDB file and a rasmol script that shows an XYZ polymer using pymol. Polymer consists of two parts: chain and subchain. A chain is a grey polymer, that is meant to resemble the main chain. It is meant to be thin, gray and transparent (overall, here transparency 1 means transparent, transparency 0 means fully visible). A subchain consists of a certain number of regions, each has it’s own color, transparency, etc.

Parameters
  • data (an Nx3 array of XYZ coordinates) –

  • regions (a list of tuples (start, end)) – Note that rasmol acceps subchains in a format (first monomer, last monomer), not the usual python convention (first, last+1)!!! An overlap check will watch this. If you want two colorings to gradually transition into each other, then you should use ((0,10),(10,25),(25,…)).

colors : a list of colors (“red”, “green”, “blue”, etc.) for each region

transparencies : a list of floats between 0 and 1. 0 is fully visible

chain_radius : radius of a main chain in arbitraty units

subchain_radius : radius of a subchain in arbitrary units

chain_transparency : transparency of a main chain

supportcode to put at the end of the script

put all the “save” or “ray” commands here if you want automation

multipliera number, probably between .1 and 3

Increasing it makes chain more smooth Decreasing it makes it more kinky, but may cause bugs or even missing chain regions

misc_argumentsstr

Misc arguments to pymol command at the very end (mainly >/dev/null)

Warning

Do not call this scripy “pymol.py!”

Warning

Please resize the window to the needed size and run “ray” command (press “ray” button) to get a nice image. Then DO NOT MOVE the image and find “export” in the menu. Otherwise your image will be not that high quality

Note

performance of “ray” command depends on two things. First is resolution : it is more than quadratic in that Second is chain complexity. Tens thousand of monomers at high resolution may take up to an hour to ray. Though it actually looks awesome then!

Run an example method below to see how the code works. See full automation examples below.

polychrom.pymol_show.show_chain(data, showGui=True, saveTo=None, showChain='worm', chains=None, support='', **kwargs)[source]

Shows a single rainbow-colored chain using PyMOL.

Arguments: gui - if True then show the GUI. save_to - a path to a saved .png figure showChain - “worm” or “spheres”

Keywords arguments: chain_radius : the radius of the displayed chain. Default: 0.1