It may be easy to do but as a beginner it seems to me trivial.
I have text like this or file containing this text:
'fdhdhjduvduvfbvhufbvufvhifbusdbjhkbueigvuerafvguavgugvg'
How can use Python to split the text like this:
'fdh dhj duv duv fbv huf bvu fvh ifb usd bjh kbu eig vue raf vgu avg ugvg'
'f dhd hjd uvd uvf bvh ufb vuf vhi fbu sdb jhk bue igv uer afv gua vgu gvg'
'fd hdh jdu vdu vfb vhu fbv ufv hif bus dbj hkb uei gvu era fvg uav gug vg'
Then need to calculate frequency of three seq (for example how many 'fdh') and rank all most frequented seq.
I saw the answers here: What is the most "pythonic" way to iterate over a list in chunks?
But I do not know which one is good for me. Also I need to open a file that contain the text and write to another file. Please provide me an expert opinion.
EDIT:
with open(fasta, 'r') as fin, open(outfile, 'w') as fout:
for item in Counter(s[i:i+4] for i in range(len(fin))).most_common():
fout.write(item)
GIVES ME ERROR
TypeError: object of type '_io.TextIOWrapper' has no len()