python - numpy.loadtxt "could not convert string to float" -
i examining code here.
when running code get:
[root@mycomp]$ python needleman-wunsch.py traceback (most recent phone call last): file "needleman-wunsch.py", line 92, in <module> (alignedseq1, alignedseq2) = computefmatrix(seq1, seq2, -6) file "needleman-wunsch.py", line 34, in computefmatrix similaritymatrixmap = readblosum50("blosum50.txt") file "needleman-wunsch.py", line 16, in readblosum50 similaritymatrix = np.loadtxt(filename, delimiter='\t') file "/usr/local/lib/python2.7/site-packages/numpy/lib/npyio.py", line 827, in loadtxt items = [conv(val) (conv, val) in zip(converters, vals)] valueerror: not convert string float: r n d c q e g h l k m f p s t w y v
a minimal illustration reproduces is:
import numpy numpy.loadtxt("data.txt", delimiter='\t')
with data.txt
being:
r n d c q 5 -2 -1 -2 -1 -1 r -2 7 -1 -2 -4 1 n -1 -1 7 2 -2 0
you can have the original blosum50.txt
file , total code the link above.
erasing first line of blosum50.txt
gave same error.
you can replace loadtxt
with
numpy.genfromtxt("data.txt", delimiter='\t', skip_header=true)[:, 1:]
this skips header, converts column names nan
, chops them off.
python numpy alignment sequence
No comments:
Post a Comment