File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed
models/distance_pipeline/Tutorials Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ RR_FORMAT = """PFRMAT RR
2
+ MODEL 1
3
+ """
4
+ def save_rr (seq ,sample_pred ,file_name_rr ):
5
+ my_file = open (file_name_rr ,'w' )
6
+ my_file .write (RR_FORMAT )
7
+ my_file .write (seq + '\n ' )
8
+ for i in range (0 ,len (seq )):
9
+ for j in range (i + 5 ,len (seq )):
10
+ print (max (sample_pred [0 ][i ][j ]))
11
+ my_file .write (str (i + 1 )+ " " + str (j + 1 )+ " " + "0 8 " + str (max (sample_pred [0 ][i ][j ]))+ "\n " )
12
+ my_file .write ('END\n ' )
13
+ my_file .close ()
14
+ save_rr (seq ,sample_pred ,'file_name_rr' )
Original file line number Diff line number Diff line change
1
+ with open ("file_name.pssm" , "r" ) as f :
2
+ lines = f .readlines ()[2 :- 6 ]
3
+ key = "ACDEFGHIKLMNPQRSTVWY"
4
+ text_keys = lines [0 ].replace ("\n " , "" ).split (" " )[4 :]
5
+
6
+ # PSSM OPTION 1
7
+ text_vals = np .array ([" " .join (line .replace ("\n " , "" )[72 :- 11 ].split ()).split () for line in lines [1 :]]).astype (float )
8
+
9
+ # PSSM OPTION 2
10
+ # text_vals = np.array([" ".join(line.replace("\n", "")[10:72].split()).split() for line in lines[1:]]).astype(float)
11
+
12
+ # normalize to [0,1]
13
+ # text_vals = text_vals / np.sum(text_vals, axis=1).reshape((len(text_vals), 1))
14
+ for i in range (len (text_vals )):
15
+ text_vals [i ] = (text_vals [i ] - np .amin (text_vals [i ])) / (np .amax (text_vals [i ] - np .amin (text_vals [i ])))
16
+
17
+ # create NxL PSSM
18
+ pssm = np .zeros_like (text_vals )
19
+ for i ,aa in enumerate (text_keys ):
20
+ pssm [key .index (aa ), :] = text_vals [i , :]
21
+
22
+ inputs_pssm = wider_pssm (pssm .T , seq )
23
+ inputs = np .concatenate ((inputs_aa , inputs_pssm ), axis = - 1 )
You can’t perform that action at this time.
0 commit comments