import prody
prot = prody.parsePDB('3UB5')
@> PDB file is found in the local folder (/Users/dkoes/.../3ub5.pdb.gz). @> 4055 atoms and 1 coordinate set(s) were parsed in 0.04s.
The default visualization in ProDy uses matplotlib.
%matplotlib inline
prody.showProtein(prot)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment. warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
<mpl_toolkits.mplot3d.axes3d.Axes3D at 0x10c93dbd0>
With the latest version of ProDy, py3Dmol
will be used if it has been imported.
prody.checkUpdates()
@> You are using the latest ProDy release (v1.8.2).
import py3Dmol
prody.showProtein(prot)
A number of keyword arguments are supported.
The background color is configurable.
prody.showProtein(prot,backgroundColor="black")
The height and width of the viewer can be changed.
prody.showProtein(prot, height=400, width=200,backgroundcolor='gray')
The viewer can be zoomed and centered on a given AtomSelectionSpec.
prody.showProtein(prot, zoomto={'resn':'ATP'})
Custom styles can be applied by providing AtomSelectionSpec and AtomStyleSpec objects.
A single style may be applied.
prody.showProtein(prot,style={'cartoon':{'colorscheme':'chain'},'stick':{'colorscheme':'chain'}})
For more complex styling, generate and manipulate the py3Dmol view object directly.
view = prody.view3D(prot)
view.setStyle({'cartoon':{'colorscheme':'chain'}})
view.setStyle({'hetflag':True},{'stick':{'colorscheme':'magentaCarbon'}})
view.setStyle({'bonds': 0},{'sphere':{'radius':0.5}})
view.addLabel('Chain A',{'inFront':True,'showBackground':False,'fontColor':'blue'},{'chain':'A'})
view.addLabel('Chain P',{'inFront':True,'showBackground':False,'fontColor':'green'},{'chain':'P'})
view.show()
Squared fluctuations (or any other alpha-carbon length numerical vector) can be visualized in a RWB colorscheme. Red values are larger.
gnm, sel = prody.calcGNM(prot)
@> Kirchhoff was built in 0.06s. @> 20 modes were calculated in 0.04s.
prody.showProtein(prot,flucts=prody.calcSqFlucts(gnm))
Individual modes may be visualized.
prody.showProtein(prot,flucts=gnm[0].getArray())
Styles can still be applied.
prody.showProtein(prot,flucts=gnm[1].getArray(),style={'cartoon':{}})
It is also possible to provide an array of vectors (one per a calpha) that can be used to animate motions. The animate kwarg takes the 3Dmol.js animate options.
anm, sel = prody.calcANM(prot)
@> Hessian was built in 0.35s. @> 20 modes were calculated in 0.85s.
prody.showProtein(prot,vecs=anm[0].getArray(),
flucts=prody.calcSqFlucts(anm[0]),
style={'cartoon':{}})