This is a read-only mirror of pymolwiki.org

Talk:Load

From PyMOL Wiki
Revision as of 00:44, 28 March 2014 by Pyadmin (talk | contribs) (2 revisions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Hi, I am newby in pymol scripts but I try tu use the numerotation of residues in mol2 files and pymol read only the 2 first numbers of each residu. For exemple, if you have HIS224 and HIS227 in your mol2 file, and try to "select resi 224 and resn HIS", pymol won't find the residu. If you try "select resi 22 and resn HIS" pymol find 2 residu!!! the last possibility is to use the number of residu in the substructure block in the mol2 file. But in this case, select 13/ (for exemple) gives only hydrogenes atoms... good luke and good night

Sorting files nicely for loading

Here's a bit of python code to enhance the loading order of alphanumeric filenames - to be used in place of the lst.sort() call in the glob example like

slst = sorted_nicely(lst)

Not sure where the most appropriate place to put it is though

---

import re

def sorted_nicely( l ):

   """ Sort the given iterable in the way that humans expect.
       Mark Byers version from stackoverflow.com post
   """
   convert = lambda text: int(text) if text.isdigit() else text
   alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
   return sorted(l, key = alphanum_key)