def check_hsa_analysis(dct): for i,k in enumerate(dct.keys()): os.chdir(dct[k]['dirname']) # FindAllFiles dct_hsa = {'cwd':dct[k]['dirname'],'pattern':'*.dat'} H = FindAllFiles(dct_hsa) set9 = H.get_files() # H.query_ [dirname,file,filename](searchstring,pos,dct) # H.remove_[dirname,file,filename](searchstring,pos,dct) set9 = H.query_file('hsa',set9) set9 = H.sort_dirname(-1,set9) H.print_query(set9) # set9 print(len(set9.keys()),'of',H.total) # if ((not os.path.exists('hsa_current')) and (len(set9.keys()) != 0)): # if (not os.path.exists('hsa_%s' % new_dir)): if ((dct[traj]['dirname'] == dct[k]['dirname']) and (not os.path.exists('hsa_current'))): print('making hsa_current') os.makedirs('hsa_current') # hcount = 0 for h in set9.keys(): # print h if os.path.basename(set9[h]['dirname']) == os.path.basename(dct[k]['dirname']): new_hsa_cur = os.path.join(dct[k]['dirname'],'hsa_current',set9[h]['filename']) # print 'moving to hsa_current:',new_hsa_cur # hcount += 1 os.rename(set9[h]['file'],new_hsa_cur) lst_hsa = glob.glob('hsa_current/hsa*.dat') # 1 if len(lst_hsa) > 0: print('base:',os.path.basename(dct[k]['dirname'])) print(lst_hsa)
# --------------------------------------------------------- # # Import Data! (3/4) # # --------------------------------------------------------- # # mylib my_library = os.path.expanduser('~/.pylib') sys.path.append(my_library) from mylib.FindAllFiles import * # FindAllFiles dct_find = {'cwd': my_dir, 'pattern': '.dat'} x = FindAllFiles(dct_find) x.get_files() print len(x.dct.keys()), 'of', x.total set9 = x.remove_dirname('fail', -2, x.dct) set9 = x.query_file('curvature_local', set9) set9 = x.sort_dirname(-2, set9) print len(set9.keys()), 'of', x.total # sys.exit() # data_name set9 = x.query_dirname(str(data_name), -2, set9) set9 = x.sort_dirname(-1, set9) x.print_query(set9) print len(set9.keys()), 'of', x.total # trajectory set9 = x.query_dirname(str(trajectory), -1, set9) set9 = x.sort_dirname(-1, set9) x.print_query(set9) print len(set9.keys()), 'of', x.total