Skip to content

Commit bbbca02

Browse files
committed
Compatibility with CAFA assessment added
1 parent 6b4ad6b commit bbbca02

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

file_utils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,18 @@ def read_embeddings(embeddings_in):
5151
return embeddings
5252

5353

54-
def write_predictions_cafa(predictions, out_file, model_num):
54+
def write_predictions_cafa(predictions, out_file, model_num, team_name):
5555
"""
5656
Write prediictions in CAFA format
5757
:param predictions: predictions to write
5858
:param out_file: output file
5959
:param model_num: number of model that is used
60+
:param team_name: Team name to use in output file
6061
:return:
6162
"""
6263
with open(out_file, 'w') as out:
63-
out.write('AUTHOR\tRostlab2\nMODEL\t{}\nKEYWORDS\thomolog, machine learning, natural language processing.'
64-
'\n'.format(model_num))
64+
out.write('AUTHOR\t{}\nMODEL\t{}\nKEYWORDS\thomolog, machine learning, natural language processing.'
65+
'\n'.format(team_name, model_num))
6566
for p in predictions.keys():
6667
prediction = predictions[p]
6768
for pred in prediction.keys():

function_prediction.py

+21
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,24 @@ def write_predictions(predictions, out_file):
218218
ri = prediction[pred]
219219
out.write('{}\t{}\t'.format(p, pred))
220220
out.write('{:0.2f}\n'.format(float(ri)))
221+
222+
@staticmethod
223+
def write_predictions_cafa(predictions, out_file, model_num, team_name):
224+
"""
225+
Write prediictions in CAFA format
226+
:param predictions: predictions to write
227+
:param out_file: output file
228+
:param model_num: number of model that is used
229+
:param team_name: Team name to use in output file
230+
:return:
231+
"""
232+
with open(out_file, 'w') as out:
233+
out.write('AUTHOR\t{}\nMODEL\t{}\nKEYWORDS\thomolog, machine learning, natural language processing.'
234+
'\n'.format(team_name, model_num))
235+
for p in predictions.keys():
236+
prediction = predictions[p]
237+
for pred in prediction.keys():
238+
ri = prediction[pred]
239+
out.write('{}\t{}\t'.format(p, pred))
240+
out.write('{:0.2f}\n'.format(float(ri)))
241+
out.write('END')

predict_go_embedding_inference.py

+5
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,10 @@ def main():
4040
predictions_out = '{}_{}_{}.txt'.format(config_data['output'], dist, o)
4141
FunctionPrediction.write_predictions(predictions, predictions_out)
4242

43+
# for compatibility with CAFA assessment tool use the following lines
44+
# team_name = RandomTeam
45+
# predictions_out = '{}_{}_all_go_{}.txt'.format(team_name, dist, o.upper())
46+
# FunctionPrediction.write_predictions_cafa(predictions, predictions_out, dist, team_name)
47+
4348

4449
main()

0 commit comments

Comments
 (0)