-
Notifications
You must be signed in to change notification settings - Fork 1
/
Specificity_prediction.py
43 lines (27 loc) · 1.02 KB
/
Specificity_prediction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# coding: utf-8
import os
from sys import argv
import pandas as pd
import joblib
def uncharacterize_pred(nbdata, my_model):
## Prediction for uncharacterized TLRs
rdata = nbdata.iloc[:,1:28]
pred_classes = []
for index, row in rdata.iterrows():
#print(row)
pred_class = my_model.predict([row])
pred_classes.append(pred_class[0])
#print(pred_classes)
nbdata['Predicted_class'] = pd.Series(pred_classes)
nbt_df = nbdata[['Gene_name', 'Predicted_class']]
#print('\n Prediction of uncharacterized TLRs: \n', nbt_df)
return (nbt_df)
if __name__=='__main__':
input_file = argv[1]
## Predicting Novel and Blind set TLR specificity
nbdata = pd.read_csv(input_file, skiprows=2, sep="\t")
#print(nbdata)
my_model = joblib.load('bin/RFC-LOO_model.pkl')
nbt_df = uncharacterize_pred(nbdata, my_model)
nbt_df.to_csv("TLR_specificity_prediction.tsv", sep="\t", index=None)