# Pattern mining from a genomic sequence

I need to find the following pattern from a genomic sequence

TTCGB-N15-TTCGB
B represents C, G, or T
N15 represents A, T, G or C and these four base combination should have the length of 15 bases.


To do the same, I tried grep command, but I could not specify B and N15 in the grep command line. Therefore, please help me to find the same.

For example, I have a nucleotide sequences as follows

>ATGCTTATTGCCCATTTCGTGCATGCATATGCGCATTCGCGATCGATTAGGGATAT


Expected outcome,

TTCGTGCATGCATATGCGCATTCGC

• Could you please update your question to clarify that N15 represents A, T, G or C for exactly 15 bases? – gringer Nov 5 '19 at 23:00

echo ">ATGCTTATTGCCCATTTCGTGCATGCATATGCGCATTCGCGATCGATTAGGGATAT" | grep -oP  'TTCG[CGT][ATGC]{1,15}TTCG[CGT]'

• [CGT] looks for one occurrence of one of the three.
• [ATGC]{1,15} looks for "up to 15 letter long" combinations of the four bases.
Moreover, -P makes your regex call Perl-like and is required to make this regex work. Different regex flavors behave (slightly) differently.
• Dear @haci, I have followed your command line for the test data (I had given in the example section of my question), which gives proper result. But when I tried the same with my genome file with the following command, echo \$(<org15.fasta) | grep -oP 'TTCG[CGT][ATGC]{1,15}TTCG[CGT]' and I am getting output as follows, TTCGCCGCGGCGACGTTTTCGC TTCGCATTCGG TTCGCCACCTTGTTCGG TTCGGCTTTCGC TTCGTGGCCTTCGG TTCGGCTTCTTCGT TTCGTCAAGGACCCGATTTCGG TTCGCATCTTCGC  – K. Dineshkumar Nov 5 '19 at 11:48
• What is your "N15 criteria" though? [ATGC]{1,15} looks for up to 15 repetitions of the four bases as you specified in your question. And as far as I can see in the output you get, this is what you are getting, 2 TTCGB stretches are connected by up to 15 bases. – haci Nov 5 '19 at 11:55
• OK, then just change [ATGC]{1,15} to [ATGC]{15} as Timur Shtatland suggested. The reason for [ATGC]{1,15} was your phrase in the question: "N represents A, T, G or C up to 15 bases". – haci Nov 5 '19 at 13:50