I have a file which looks like this, this a tab separated text file
aaa 0.0520852296 0.1648703511 0.1648703511
bbb 0.1062639955 0.1632039268 0.1632039268
ccc 1.4112745088 4.3654577641 4.3654577641
ddd 0.4992644913 0.1648703511 0.1648703511
eeee 0.169058175 0.1632039268 0.1632039268
and the output should be
aaa 0.0232736716 0.0328321936 0.0328321936
bbb 0.0474828153 0.0325003428 0.0325003428
ccc 0.6306113983 0.8693349271 0.8693349271
ddd 0.2230904597 0.0328321936 0.0328321936
eeee 0.0755416551 0.0325003428 0.0325003428
That each row/total sum of column
So on with many rows and columns for this .txt
file I need to find the column sum for each column from. 2nd column to last column and then divide each numerical row with the column sum.
And print it as the output.
So far I have done until split and strip and from there I am not able to select select from second row.
import numpy as np
motif_path = '/home/test/test.txt'
f =open(motif_path,'r')
x = f.readlines()
kk = [s.strip().split("\t") for s in x]
When I tried
for i in Kk[1][1]
, I received and error:
TypeError: unsupported operand type(s) for +: 'int' and 'str'