Question: Extract Sequence From Fasta File Using Ids From a separate txt File in linux
0
gravatar for roberta.berezin
20 months ago by
roberta.berezin0 wrote:

Hi everyone,

I have two files a fasta file and a txt file containing a list of sequence ID.

I would like to exclude the list of sequence ID ( text file) from fasta file. I have tried this command :

seqtk subseq input.fasta list_ids.txt > output.fasta

But it gives me an output with a fasta file containing only the list ofID sequences . I want a output ( fasta) without the sequence ID. if you could explain any answers in detail, I would be highly grateful

rna-seq • 2.4k views
ADD COMMENTlink modified 20 months ago by h.mon28k • written 20 months ago by roberta.berezin0
3

This question has been asked a gazillon times on biostars.org . What did you find so far ?

ADD REPLYlink written 20 months ago by Pierre Lindenbaum124k

Pierre, i saw similiar questions.. but most of them are about a " different output".. i want a output without the list of ID... I saw a command line in seqtk, pyton, and someothers, but none of them worked for what i want. do u have another alternative ?

ADD REPLYlink written 20 months ago by roberta.berezin0
1

Using seqtk and unix tools:

grep ">" input.fasta | tr -d ">" | grep -v -w -f list_ids.txt > list_ids_2.txt
seqtk subseq input.fasta list_ids_2.txt > output.fasta

Or in one line:

seqtk subseq input.fasta $(grep ">" input.fasta | tr -d ">" | grep -v -w -f list_ids.txt) > output.fasta

ADD REPLYlink written 20 months ago by h.mon28k
1
gravatar for genomax
20 months ago by
genomax74k
United States
genomax74k wrote:

faSomeRecords from Kent Utilities is the one you want. Linux version linked here, macOS available.

faSomeRecords in.fa listFile out.fa
options:
   -exclude - output sequences not in the list file.
ADD COMMENTlink modified 20 months ago • written 20 months ago by genomax74k
0
gravatar for Joe
20 months ago by
Joe14k
United Kingdom
Joe14k wrote:

As others have said, this has been asked many many times, but this script will also do what you want if you invoke it with --invert.

ADD COMMENTlink written 20 months ago by Joe14k
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: 1254 users visited in the last hour