Main Page

From PyMOLWiki
Revision as of 05:27, 19 February 2019 by Speleo3 (talk | contribs) (2to3)
Jump to navigation Jump to search
hosted by SBGridlogo2.jpg
Welcome to the PyMOL Wiki!
The community-run support site for the PyMOL molecular viewer.
To request a new account, email SBGrid at: accounts (@) sbgrid dot org
Quick Links
Tutorials Table of Contents Commands
Script Library Plugins FAQ
Gallery | Covers PyMOL Cheat Sheet (PDF) Getting Help
News & Updates
Python 3 New Python 3 compatibility guide for scripts and plugins
Official Release PyMOL v2.3 has been released on February 11, 2019.
POSF New PyMOL fellows announced for 2018-2019
Tutorial Plugins Tutorial updated for PyQt5
New Plugin ProBiS H2O is a new plugin for identification of conserved waters in protein structures.
Selection keywords New polymer.protein and polymer.nucleic selection keywords. Thanks everyone who participated in the poll!
Plugin Update MOLE 2.5 is an updated version of channel analysis software in PyMOL
New Script dssr_block is a wrapper for DSSR (3dna) and creates block-shaped nucleic acid cartoons
Older News See Older News.
Did you know...

CollapseSel

= Overview =

CollapseSel is a small utility function to compress strings for selections. So, if you have a selection with residues 1+2+3+4+20+21+22+100-120 this will return, 1-4+20-22+100-120.

CollapseIDs is a small utility function to compress strings for an array of IDs. This does NOT have the logic for detecting duplicates, CollapseSel does.

Example

run /dir/to/collapseSel.py
fetch 1cll
select EE, resn GLU
print collapseSel("EE")
#
# and PyMOL should output:
#
# 6-7+11+14+31+45+47+54+67+82-84+87+104+114+119-120+123+127+139-140
#

The Code

<source lang="python"> import pymol from pymol import stored

def collapseIDs(ids): """ Helper function to make a smart list of IDs: eg turns 1+2+3+4+5 into 1-5. """ rVal = [] if len(ids)==0: return ""

scanning=False anchor = 0 start = 0 # 1-5 7-10 12 21-23 for cur in range(0,len(ids)-1): if ids[cur]+1 == ids[cur+1]: if scanning: scanning=True continue else: scanning=True start = cur else: if ..→

A Random PyMOL-generated Cover. See Covers.