This is a test version of Biostars. For the public version, visit https://www.biostars.org.
grep DNA after a pattern

HI,

I have DNA sequences like these :

and I want to keep all sequences after this pattern "ACTTAAGTGTATGTAAACTTCCGACTTCAACTG" beginning with "TA". I tried

grep -v "ACTTAAGTGTATGTAAACTTCCGACTTCAACTG" file.txt

but it does not work.

Kindly help.

dnaseq grep

Not sure what you mean. If you want sequences that start with the pattern followed by TA then look for the whole thing, i.e. ACTTAAGTGTATGTAAACTTCCGACTTCAACTGTA

What about awk -F "ACTTAAGTGTATGTAAACTTCCGACTTCAACTGTA" '{print "TA"$2}'.

Split sequence if contains the query and TA at the end, if so print TA and everything downstream of it.

the first one worked : awk -F "ACTTAAGTGTATGTAAACTTCCGACTTCAACTG" '{print $2}' file.txt but has lots of empty spaces

I want to keep all the sequences after this pattern.

3 answers

Your code (grep -v) selects only lines that do not have the string ACTTAAGTGTATGTAAACTTCCGACTTCAACTG, so zero. If you want to select only ACTTAAGTGTATGTAAACTTCCGACTTCAACTG followed by AT, but dropping the ACTTAAGTGTATGTAAACTTCCGACTTCAACTG string, you can use grep in combo with sed.

grep "ACTTAAGTGTATGTAAACTTCCGACTTCAACTGTA" file.txt | sed "s/ACTTAAGTGTATGTAAACTTCCGACTTCAACTGTA/TA/g"

enter image description here

https://ibb.co/HtX3K3c

Log in to answer this question.