This doesn't work if sequence has scattered "X". OP requirement is "I am keeping filter criteria as if a read contains morethan 2 X ( continuesly or anywhere in the read) should be removed".
For eg.
output:
$ awk -v RS='>' '!/XX/{printf $0RT}' file.fa
>seq1
ATWDXGCX
>seq3
ATWDXGCC
with seqkit and awk:
$ seqkit fx2tab file.fa | awk -F'X' 'NF<=2' | seqkit tab2fx
>seq3
ATWDXGCC
Input:
$ cat file.fa
>seq1
ATWDXGCX
>seq2
ATWXXGCX
>seq3
ATWDXGCC
awk --version GNU Awk 5.0.1,
This type of task is a good learning opportunity. It could be done in about 5 or 6 lines of python for instance.
What have you attempted so far?
If fasta headers don't have x, this should work with seqkit:
It seems to me that you keep asking similar question without making any effort to solve any of them on your own. Here you asked how to remove sequences containing
Ncharacters. Well, removing sequences with Xs is the same as removing Ns - you only change one letter in the script. You should have plenty of material with all the scripts others have written for you to solve this kind of problem with minimal effort. Most people here are helpful and kind enough to do this for you, but you will help yourself in the long run if you actually learn how to do it. You know that quote about teaching a man to fish?Thanks for the advice.
Still i didn't get any solution for this, which is why i came up with a new thread. i tried with googlong also, but i couldn't get any. If i am better in scripting i could've done by myself. Taking ideas for the first time from others and learning from that is also fishing.
When I look at that thread, I see at least three solutions. Maybe they are not to your exact liking, but it isn't true that you didn't get
anysolutions.For example, this solution from that thread:
Change
NtoX, and==0to< 2and there is your solution. This is at least your fourth fishing lesson.