3 """This script creates input files for pmi/bin/run_clustering.py
5 from __future__
import print_function
9 output_prefix=
"./test_output/run"
13 head = (
"med6",
"med8",
"med11",
"med17",
"med18",
"med20",
"med22")
14 middle = (
"med1",
"med4",
"med7",
"med9",
"med10",
"med14",
"med17",
"med18",
"med19",
"med21",
"med31")
15 sub_middle = (
"med4",
"med9",
"med7",
"med21",
"med31")
16 tail = (
"med2",
"med3",
"med5",
"med14",
"med15",
"med16")
17 full = tuple(set(head+middle+tail))
19 std = [
"ISDCrossLinkMS_Distance_intrarb",
20 "ISDCrossLinkMS_Distance_interrb",
21 "ISDCrossLinkMS_Data_Score",
22 "SimplifiedModel_Linker_Score_None",
24 "ISDCrossLinkMS_Sigma"]
26 em = [
"GaussianEMRestraint_None"]
29 jobs = [[sub_middle,std+em],
63 other_options={
'global_output_dir' :
'output/',
64 'number_of_best_scoring_models' : 500,
65 'distance_matrix_file' :
"distance.rawmatrix.pkl",
66 'load_distance_matrix_file' : 0,
67 'skip_clustering' : 0,
69 'exit_after_display' : 0,
71 'number_of_clusters' : nclusters,
74 for nj,(subunits,feature_keys)
in enumerate(jobs):
75 if not os.path.isdir(output_prefix+str(nj+1)):
77 out_fn = os.path.join(output_prefix+str(nj+1),
'analysis.txt')
78 print(
'writing',out_fn)
79 d = os.path.dirname(out_fn)
83 for dd
in glob.glob(os.path.join(output_prefix+str(nj+1),
'*')):
84 if os.path.isdir(dd)
and (
'modeling' in dd
or 'jackmodel' in dd):
85 if os.path.isfile(os.path.join(dd,
'best.scores.rex.py')):
89 output_dir =
'%s/clustering/kmeans_2_%i/'%(d,nclusters)
90 if not os.path.isdir(os.path.join(d,
'clustering')):
91 os.mkdir(os.path.join(d,
'clustering'))
93 outf.write(
'subunits ')
94 for subunit
in subunits:
95 outf.write(subunit+
' ')
97 outf.write(
'\nmerge_directories ')
101 outf.write(
'\noutput_dir '+output_dir)
103 outf.write(
'\nfeature_keys ')
104 for feature
in feature_keys:
105 outf.write(feature+
' ')
108 for key
in other_options:
109 outf.write(key+
" "+str(other_options[key])+
'\n')
114 inf=open(os.path.join(d,
'best.scores.rex.py'),
'r')
115 l=inf.readlines()[0].replace('self.',
'')
117 scores.append(best_score_list[-1])
119 outf.write(
'prefilter_value %.2f\n'%max(scores))