Question: How to remove multiple fasta sequence from fasta file using gene id
0
gravatar for Bioinfonext
19 months ago by
Bioinfonext120
Korea
Bioinfonext120 wrote:

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

rna-seq • 1.8k views
ADD COMMENTlink modified 19 months ago by Jake Warner670 • written 19 months ago by Bioinfonext120
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 19 months ago by WouterDeCoster34k
2
gravatar for Antonio R. Franco
19 months ago by
Spain. Universidad de Córdoba
Antonio R. Franco3.9k 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 19 months ago • written 19 months ago by Antonio R. Franco3.9k
1
gravatar for Jake Warner
19 months ago by
Jake Warner670
Jake Warner670 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 19 months ago • written 19 months ago by Jake Warner670
2

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 19 months ago by WouterDeCoster34k
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: 822 users visited in the last hour