Hi Guys, 
I am new to the forum to come directly with a question / problem.

I want to write a program that counts the patterns like this.
I have given such sequences as an example:

> - A: AAAAAAAAA
- B: AAAAACAAG
- C: GAAAACGAA
- D: AAAAAAAAT
> 

A patten is a group of four letters of the four groups. As an example, the first Patten would be "AAGA". Now I wonder how many times that happens in my entire Sequenze. So far I have only found programs that are looking for a given pattern. Does anyone have an idea how to program this or do you already know where this was done?

I'm very thankful for your help!

Best regards




Something like this ? 

#### Input fasta file : test.fa

    >A
    AAAAAAAAA
    >B
    AAAAACAAG
    >C
    GAAAACGAA
    >D
    AAAAAAAAT

#### Python counter 

    from Bio import SeqIO
    import pandas as pd
    from collections import Counter
    
    df = pd.DataFrame()
    for record in SeqIO.parse("test.fa", "fasta"):
        df[record.id] = list(str(record.seq))
    df = df.transpose()

It returns a dataframe like this : 

    	0	1	2	3	4	5	6	7	8
    A	A	A	A	A	A	A	A	A	A
    B	A	A	A	A	A	C	A	A	G
    C	G	A	A	A	A	C	G	A	A
    D	A	A	A	A	A	A	A	A	T


Then you can count  column string occurence with Counter
 
    c = Counter([df[i].str.cat() for i in df])
    # Output : Counter({'AAGA': 2, 'AAAA': 5, 'ACCA': 1, 'AGAT': 1})


Note : 
It only works if you have few sequence. Loading the dataframe with a huge fasta will fail with low memory. 
You also may want to see [Position Weight Matrix][1] 


  [1]: https://en.wikipedia.org/wiki/Position_weight_matrix