#check for mismatch for this_assign, that_assign in zip(micro_assign, geo_assign): for this_item, that_item in zip(this_assign, that_assign): if this_item == raw_to_micro_mapping[that_item]: pass else: print('mismatch %d, %d' % (this_item, that_item)) micro_assign_path = '/home/shenglan/TryMSMbuilder/output/ten_ligands/KC_microassign_c' + str( N_MICRO) + '_s' + str(LOAD_STRIDE) + '.out' pickle.dump(micro_assign, open(micro_assign_path, 'wb')) save_micro_pdb_path = '/home/shenglan/TryMSMbuilder/output/ten_ligands/KC_microassign_c' + str( N_MICRO) + '_s' + str(LOAD_STRIDE) + '.pdb' util.convert_sequences_to_pdb(seq_path, micro_assign_path, save_micro_pdb_path) # dictionary; key: microstate id; # item: list of distances to binding pocket for points in microstate clusters_dist = {} for ii in range(len(distances)): if len(distances) == len(micro_assign) and len(distances[ii]) == len( micro_assign[ii]): for nn in range(len(distances[ii])): if micro_assign[ii][nn] in clusters_dist.keys(): clusters_dist[micro_assign[ii][nn]].append(distances[ii][nn]) else: clusters_dist.update( {micro_assign[ii][nn]: [distances[ii][nn]]})
np.savetxt(countsmat_path, countsmat, fmt='%8.4g') transmat_path = '/home/shenglan/TryMSMbuilder/output/C/ergodic/KC_transmat_c' + str( N_CLUSTER) + '_s' + str(LOAD_STRIDE) + '.out' np.savetxt(transmat_path, transmat, fmt='%10.4g') centers_path = '/home/shenglan/TryMSMbuilder/output/C/ergodic/KC_centers_c' + str( N_CLUSTER) + '_s' + str(LOAD_STRIDE) + '.out' np.savetxt(centers_path, centers, fmt='%10.4g') #---------------------------------------------------------------------------------- # Convert to pdb #---------------------------------------------------------------------------------- pdb_path = '/home/shenglan/TryMSMbuilder/output/C/ergodic/KC_c' + str( N_CLUSTER) + '_s' + str(LOAD_STRIDE) + '.pdb' util.convert_sequences_to_pdb(seq_path, assign_path, pdb_path) #---------------------------------------------------------------------------------- # Visualization of data #---------------------------------------------------------------------------------- # fig5 = plt.figure(figsize=(14,3)) # # plt.plot(assignments[0],'r.',alpha = 0.5) # plt.plot(assignments[1],'b.',alpha = 0.5) # plt.plot(assignments[2],'g.',alpha = 0.5) # plt.xlabel('Frame') # plt.ylabel('Cluster number') # plt.title('cluster numbers, condition B') # plt.savefig('/home/shenglan/TryMSMbuilder/output/fig5.png') # plt.close(fig5) #
# assignments to macro states macro_assign = [] for this_assign in geo_assign: this_list = np.zeros(len(this_assign),dtype = int) macro_assign.append(this_list) for nn in range(len(macro_assign)): for ii in range(len(macro_assign[nn])): macro_assign[nn][ii] = micro_to_macro_mapping[micro_assign[nn][ii]] macro_assign_path = '/home/shenglan/TryMSMbuilder/output/C/ergodic/KC_macroassign_c'+str(N_MACRO)+'_s'+str(LOAD_STRIDE)+'.out' pickle.dump(macro_assign,open(macro_assign_path,'wb')) micro_assign_path = '/home/shenglan/TryMSMbuilder/output/C/ergodic/KC_microassign_c'+str(N_MICRO)+'_s'+str(LOAD_STRIDE)+'.out' pickle.dump(micro_assign,open(micro_assign_path,'wb')) seq_path = '/home/shenglan/TryMSMbuilder/output/C/ergodic/sequences_s'+str(LOAD_STRIDE)+'.out' save_macro_pdb_path = '/home/shenglan/TryMSMbuilder/output/C/ergodic/KC_macroassign_c'+str(N_MACRO)+'_s'+str(LOAD_STRIDE)+'.pdb' save_micro_pdb_path = '/home/shenglan/TryMSMbuilder/output/C/ergodic/KC_microassign_c'+str(N_MICRO)+'_s'+str(LOAD_STRIDE)+'.pdb' util.convert_sequences_to_pdb(seq_path,macro_assign_path,save_macro_pdb_path) util.convert_sequences_to_pdb(seq_path,micro_assign_path,save_micro_pdb_path) # macro_assign = pcca.fit(partial_micro_assign) # # print macro_assign
KC_assignments = KC_clustering.fit_predict(sequences_all) KC_centers = KC_clustering.cluster_centers_ KM_clustering = KCenters(n_clusters = N_CLUSTER) KM_assignments = KM_clustering.fit_predict(sequences_all) KM_centers = KM_clustering.cluster_centers_ KC_output_file = '/home/shenglan/TryMSMbuilder/output/KC_centers_c'+str(N_CLUSTER)+'_s'+str(LOAD_STRIDE)+'.out' KM_output_file = '/home/shenglan/TryMSMbuilder/output/KM_centers_c'+str(N_CLUSTER)+'_s'+str(LOAD_STRIDE)+'.out' np.savetxt(KC_output_file,KC_centers,fmt = '%10.4g') np.savetxt(KM_output_file,KM_centers,fmt = '%10.4g') KC_assign_file = '/home/shenglan/TryMSMbuilder/output/KC_assign_'+str(N_CLUSTER)+'_s'+str(LOAD_STRIDE)+'.out' KM_assign_file = '/home/shenglan/TryMSMbuilder/output/KM_assign_'+str(N_CLUSTER)+'_s'+str(LOAD_STRIDE)+'.out' pickle.dump(KC_assignments,open(KC_assign_file,'wb')) pickle.dump(KM_assignments,open(KM_assign_file,'wb')) KC_pdb_path = KC_output_file.split('.')[0]+'.pdb' KM_pdb_path = KM_output_file.split('.')[0]+'.pdb' util.convert_to_pdb(KC_output_file,KC_pdb_path) util.convert_to_pdb(KM_output_file,KM_pdb_path) KC_pdb_file = '/home/shenglan/TryMSMbuilder/output/KC_c'+str(N_CLUSTER)+'.pdb' util.convert_sequences_to_pdb(seqfile,KC_assign_file,KC_pdb_file) KM_pdb_file = '/home/shenglan/TryMSMbuilder/output/KM_c'+str(N_CLUSTER)+'.pdb' util.convert_sequences_to_pdb(seqfile,KM_assign_file,KM_pdb_file)
pickle.dump(assignments,open(assign_path,'wb')) countsmat_path = '/home/shenglan/TryMSMbuilder/output/C/all_clusters/KC_countsmat_c'+str(N_CLUSTER)+'_s'+str(LOAD_STRIDE)+'.out' np.savetxt(countsmat_path,countsmat,fmt = '%8.4g') transmat_path = '/home/shenglan/TryMSMbuilder/output/C/all_clusters/KC_transmat_c'+str(N_CLUSTER)+'_s'+str(LOAD_STRIDE)+'.out' np.savetxt(transmat_path,transmat,fmt = '%10.4g') centers_path = '/home/shenglan/TryMSMbuilder/output/C/all_clusters/KC_centers_c'+str(N_CLUSTER)+'_s'+str(LOAD_STRIDE)+'.out' np.savetxt(centers_path,centers,fmt = '%10.4g') #---------------------------------------------------------------------------------- # Convert to pdb #---------------------------------------------------------------------------------- pdb_path = '/home/shenglan/TryMSMbuilder/output/C/all_clusters/KC_c'+str(N_CLUSTER)+'_s'+str(LOAD_STRIDE)+'.pdb' util.convert_sequences_to_pdb(seq_path,assign_path,pdb_path) #---------------------------------------------------------------------------------- # Visualization of data #---------------------------------------------------------------------------------- # fig5 = plt.figure(figsize=(14,3)) # # plt.plot(assignments[0],'r.',alpha = 0.5) # plt.plot(assignments[1],'b.',alpha = 0.5) # plt.plot(assignments[2],'g.',alpha = 0.5) # plt.xlabel('Frame') # plt.ylabel('Cluster number') # plt.title('cluster numbers, condition B') # plt.savefig('/home/shenglan/TryMSMbuilder/output/fig5.png') # plt.close(fig5) #
import utilities as util import numpy as np import pickle # crd_file = '/home/shenglan/TryMSMbuilder/output/cluster_centers.out' # pdb_path = '/home/shenglan/TryMSMbuilder/output/cluster_centers.pdb' # # util.convert_to_pdb(crd_file,pdb_path) # # crd_file = '/home/shenglan/TryMSMbuilder/output/KM_centers_50.out' # pdb_path = '/home/shenglan/TryMSMbuilder/output/KM_centers_50.pdb' # # util.convert_to_pdb(crd_file,pdb_path) # # crd_file = '/home/shenglan/TryMSMbuilder/output/KC_centers_50.out' # pdb_path = '/home/shenglan/TryMSMbuilder/output/KC_centers_50.pdb' # # util.convert_to_pdb(crd_file,pdb_path) seqfile = '/home/shenglan/TryMSMbuilder/output/sequences.out' assignfile = '/home/shenglan/TryMSMbuilder/output/KC_assign_5.out' savefile = '/home/shenglan/TryMSMbuilder/output/KC_rec_crds.pdb' util.convert_sequences_to_pdb(seqfile,assignfile,savefile)
import utilities as util import numpy as np import pickle # crd_file = '/home/shenglan/TryMSMbuilder/output/cluster_centers.out' # pdb_path = '/home/shenglan/TryMSMbuilder/output/cluster_centers.pdb' # # util.convert_to_pdb(crd_file,pdb_path) # # crd_file = '/home/shenglan/TryMSMbuilder/output/KM_centers_50.out' # pdb_path = '/home/shenglan/TryMSMbuilder/output/KM_centers_50.pdb' # # util.convert_to_pdb(crd_file,pdb_path) # # crd_file = '/home/shenglan/TryMSMbuilder/output/KC_centers_50.out' # pdb_path = '/home/shenglan/TryMSMbuilder/output/KC_centers_50.pdb' # # util.convert_to_pdb(crd_file,pdb_path) seqfile = '/home/shenglan/TryMSMbuilder/output/sequences.out' assignfile = '/home/shenglan/TryMSMbuilder/output/KC_assign_5.out' savefile = '/home/shenglan/TryMSMbuilder/output/KC_rec_crds.pdb' util.convert_sequences_to_pdb(seqfile, assignfile, savefile)
KM_assignments = KM_clustering.fit_predict(sequences_all) KM_centers = KM_clustering.cluster_centers_ KC_output_file = '/home/shenglan/TryMSMbuilder/output/KC_centers_c' + str( N_CLUSTER) + '_s' + str(LOAD_STRIDE) + '.out' KM_output_file = '/home/shenglan/TryMSMbuilder/output/KM_centers_c' + str( N_CLUSTER) + '_s' + str(LOAD_STRIDE) + '.out' np.savetxt(KC_output_file, KC_centers, fmt='%10.4g') np.savetxt(KM_output_file, KM_centers, fmt='%10.4g') KC_assign_file = '/home/shenglan/TryMSMbuilder/output/KC_assign_' + str( N_CLUSTER) + '_s' + str(LOAD_STRIDE) + '.out' KM_assign_file = '/home/shenglan/TryMSMbuilder/output/KM_assign_' + str( N_CLUSTER) + '_s' + str(LOAD_STRIDE) + '.out' pickle.dump(KC_assignments, open(KC_assign_file, 'wb')) pickle.dump(KM_assignments, open(KM_assign_file, 'wb')) KC_pdb_path = KC_output_file.split('.')[0] + '.pdb' KM_pdb_path = KM_output_file.split('.')[0] + '.pdb' util.convert_to_pdb(KC_output_file, KC_pdb_path) util.convert_to_pdb(KM_output_file, KM_pdb_path) KC_pdb_file = '/home/shenglan/TryMSMbuilder/output/KC_c' + str( N_CLUSTER) + '.pdb' util.convert_sequences_to_pdb(seqfile, KC_assign_file, KC_pdb_file) KM_pdb_file = '/home/shenglan/TryMSMbuilder/output/KM_c' + str( N_CLUSTER) + '.pdb' util.convert_sequences_to_pdb(seqfile, KM_assign_file, KM_pdb_file)