I have a file containing multiple fast sequneces. For a specific consensus pattern as input, I extracted all the matching patterns from target fasta sequences with
grep -o -E "CC[GT]AAA[GC][AC]TT[GC]" input.fasta
However, the above command will retrieve just the matching sequences from fasta sequences and I also wanted to get the corresponding fasta header of each match.
For example, if input.fasta file is something like this,
>Gene 1
TGATGAAAAATGATAGAT
ATTGGGGGAAAAAAAAAT
>Gene 2
TTTCCTAAAGATTGT
AAATTTAAAAATGTTTTT
(Gene 2 has matching subsequence CCTAAAGATTG)
Output:
CCTAAAGATTG Gene2
I prefer a solution with grep. But other possible solutions also helpful.