I have the following text file- http://www.ncbi.nlm.nih.gov/Class/FieldGuide/BLOSUM62.txt
I need a python code to give me the specific entries of the matrix. I'm using multidimensional lists and would prefer doing it without the numpy library in python. My intent is to form lists within lists where the outer(main) list contains rows of the matrix and the inner list contains the cells of the matrix.
I'm using the following code-
handle=open(fname)
li=[]
matrix=[]
for line in handle:
if not line.startswith('#'):
a=line.split()
for i in a:
li.append(i)
matrix.append(li)
print matrix
However, this just returns a one dimensional list with each element being one cell of the matrix. I'm lost regarding how to fix this. The output should be something of this form-
[['A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I', 'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V', 'B', 'Z', 'X', '*'],
['A', '4', '-1', '-2', '-2', '0', '-1', '-1', '0', '-2', '-1', '-1', '-1', '-1', '-2', '-1', '1', '0', '-3', '-2', '0', '-2', '-1', '0', '-4']]