thank you very much. follow up question. What if the header in the fasta file has >gene3 <additional information="">. they were skipped. What would be the easiest way to include them?
Obtain sequences that did not appear in your fasta file
Good day, I am trying to identify which sequences did not appear from my list. I have file1.txt which is a list of genes
#gene1
#gene2
#gene3
#gene4
#gene5
I also have file2.fa
#>gene1
ACTAGA
#>gene3
ACATGA
#>gene6
AGATA
I want to be able to identify the genes that are not found in file2.fa based on file1.txt list sample output would be
#gene2
#gene4
#gene5
I tried for i in $(cat file1.txt); do perl -ne '/$i/ && print' file2.fa > output.txt; done
it gives everything that appeared in the list. I tried diffirent iterations to get whats not on the list but I wasn't able to.
Hope someone could help me with this.
Thanks!
• 2,632 views
•
link
2 answers
comm -23 <(sort file1.txt ) <(grep '>' file2.fa | cut -c 2- | sort)
• 1 views
•
link
• 1 views
•
link
What would be the easiest way to include them?
insert a cut command before sort
• 1 views
•
link
output:
$ grep \> file2.fa | sed 's/>//g' | grep -vf - file1.txt
gene2
gene4
gene5
input:
$ cat file2.fa
>gene1
ACTAGA
>gene3
ACATGA
>gene6
AGATA
$ cat file1.txt
gene1
gene2
gene3
gene4
gene5
• 1 views
•
link
Log in to answer this question.

I assume those
#are not in your real data since that will break thefastaformat.yup sorry. It was showing as something else in my laptop before I added the #
Please use the formatting bar (especially the

codeoption) to present your post better. I've done it for you this time. You would not need to add#in that case.Thank you!
Thank you very much genomax. Will do that next time.