Hi, thank you! This code also gives sequence only for the last gene ID in the list.
Output of file gene_lists.txt protein.fasta is:
gene_lists.txt: ASCII text, with CRLF line terminators
protein.fasta: ASCII text, with very long lines
Hi,
I have a protein fasta file and a gene list file. I want to retrieve sequences of all genes in gene list file at one time to save time. I am using this command line:
for i in `cat gene_list.txt` ; do grep -A1 "$i" protein.fasta ; done
However, it only gives sequence for the last gene in the gene_list.txt file. I want to retrieve sequences of all the gene. Thank you for the help!
for i in `cat gene_list.txt` ; do grep -A1 "$i" protein.fasta
hum, better:
grep -A1 -F -w -f gene_list.txt protein.fasta
However, it only gives sequence for the last gene in the gene_list.txt file
are you sure these are text file and not a windoz-thing ? What is the output of file gene_lists.txt protein.fasta ?
Hi, thank you! This code also gives sequence only for the last gene ID in the list.
Output of file gene_lists.txt protein.fasta is:
gene_lists.txt: ASCII text, with CRLF line terminators
protein.fasta: ASCII text, with very long lines
with CRLF line terminators
this is your problem. https://en.wikipedia.org/wiki/Newline#Issues_with_different_newline_formats
It worked even with my previous code after converting using dos2unix. Thank you very much.
Log in to answer this question.
This can't be a genome file since you would not be able to get individual gene sequences from it.
Best option is to use
faSomeRecordsutility. See: C: How do I extract Fasta Sequences based on a list of IDs?By genome I meant protein. Sorry for the confusion. I have edited it in the question.