Issue
I am using protein-ligand affinity value file as input that return its values to list. Code is
def sep_input_file(input_file):
lines = preprocessing(read_file(open(input_file,"r")))
if lines.shape[1] == 2:
return list(lines[:,0]), list(lines[:,1]), list(np.ones(len(lines)))
elif lines.shape[1] == 3:
return list(lines[:,0]), list(lines[:,1]), list(np.array(lines[:,2], dtype = np.float32))
Input file is:
protein | ligand | affinity |
---|---|---|
./data/complexes/2hyyProtein.mol2 | ./data/complexes/2hyyLigand.mol2 | 10.2 |
Please suggest me how to resolve it?
Getting the error
error:
return list(lines[:,0]), list(lines[:,1]), list(np.array(lines[:,2], dtype = np.float32))
ValueError: could not convert string to float:
Solution
There are most likely strings that can't be parsed into floats in the affinity
column. Try replacing
list(np.array(lines[:,2], dtype = np.float32))
with
result = []
for data in lines[:,2]:
try:
value = float(data.replace(',', '.').strip())
except (ValueError, TypeError):
value = None
result.append(value)
There will be None
values in the result where the parsing fails.
Answered By - Michal Racko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.