With the help of the Counter (collections module), the number of each type of characters was calculated by "columns" in the list with elements, each element is a string of letters and symbols (in my case the alternation of "a", "c", "g", "t" , "-"). Each line has 200 characters.
From this
['agtcgtcgatcgatcgatcga----', 'aaagggtctgcgatgcgaattagca', 'gcgatcgtggcg-----cgggcggg'] lst = ['agtcgtcgatcgatcgatcga----', 'aaagggtctgcgatgcgaattagca','gcgatcgtggcg-----cgggcggg'] r = [collections.Counter(ar) for ar in zip(*lst)] Print ('\n'.join(str(value) fro value in r)) Got it (set quantity randomly):
Counter ({'a':2, '-':1, 'c':3}) Counter ({'t':3, '-':1, 'g':1}) Counter ({'a':2, '-':31, 'c':3}) и тд. And I need to get something like this (the number is also randomly set):
1: a=2, g=1, c=0, t=0, -=0 2: a=1, g=1, c=1, t=0, -=0 3: a=0, g=0, c=3, t=0, -=0 ... 200. a=2, g=1, c=0, t=0, -=4 Or at least this way (the main thing is to see the position number at the beginning):
1. ({'a':2, '-':1, 'c':3}) 2. ({'t':3, '-':1, 'g':1}) 3. ({'a':2, '-':31, 'c':3}) и тд.
a=2mean in the first line of the desired result? - Enikeyschik