Question: How to remove multiple fasta sequence from fasta file using gene id
0
gravatar for nabiyogesh
5 months ago by
nabiyogesh70
South Korea
nabiyogesh70 wrote:

I am looking a command or script by which I can remove multiple sequences from fasta file using gene ID.

rna-seq • 361 views
ADD COMMENTlink modified 5 months ago by Jacob Warner390 • written 5 months ago by nabiyogesh70
1

Please add more information, concerning how your data looks like. I can only guess that the gene id is part of the fasta description or identifier.

In addition, if you show what you tried (and didn't work) people will be more eager to help you. Show some effort from your side too.

ADD REPLYlink written 5 months ago by WouterDeCoster21k
1
gravatar for Jacob Warner
5 months ago by
Jacob Warner390
Jacob Warner390 wrote:

If you store the gene names in a variable you can loop and pull them out with awk:

id='gen1 gene2' ;
for gene in $id; 
do 
awk '/'$gene'/{flag=1;print $0;next}/^>/{flag=0}flag' file.fasta >> outfile.fasta ;
done

edit: For a list of genes in a file use:

id=$(cat genelist)

instead of the 'manual' id assignement above.

ADD COMMENTlink modified 5 months ago • written 5 months ago by Jacob Warner390
1

Thank you for your solution and explanation, but I don't think we do OP a favour in the long run by always providing ready-to-use answers which will learn OP nothing in the end, especially if OP doesn't show some effort on trying to solve this without help.

ADD REPLYlink written 5 months ago by WouterDeCoster21k
0
gravatar for Antonio R. Franco
5 months ago by
Spain. Universidad de Córdoba
Antonio R. Franco3.4k wrote:

There is a very nice, fast and convenient program called faSomeRecords that can do what you are asking. In fact, can do two sorts of things by giving a list. Either extract those fasta file that are containing into a list file, or discard them It is working in the Linux environment, though

You just need to run faSomeRecords to get information about the options

 linux@ARFLinux:~$ faSomeRecords 
faSomeRecords - Extract multiple fa records
usage:
   faSomeRecords in.fa listFile out.fa
options:
   -exclude - output sequences not in the list file.
ADD COMMENTlink modified 5 months ago • written 5 months ago by Antonio R. Franco3.4k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1264 users visited in the last hour