Talk:Load: Difference between revisions
(pb with selection in mol2 file) |
(→Sorting files nicely for loading: new section) |
||
Line 3: | Line 3: | ||
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... | 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 | 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) |
Latest revision as of 07:09, 12 October 2012
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)