[docs]defget_rna_models_from_dir(directory):models=[]ifnotos.path.exists(directory):raiseException('Dir does not exist! ',directory)files=glob.glob(directory+"/*.pdb")files_sorted=sort_nicely(files)forfinfiles_sorted:models.append(f)returnmodels

[docs]defsort_nicely(l):"""Sort the given list in the way that humans expect. http://blog.codinghorror.com/sorting-for-humans-natural-sort-order/ """defconvert(text):returnint(text)iftext.isdigit()elsetextdefalphanum_key(key):return[convert(c)forcinre.split('([0-9]+)',key)]l.sort(key=alphanum_key)returnl