Question: Extract Sequence From Fasta File Using Ids From a separate txt File in linux
0
gravatar for roberta.berezin
2.4 years 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 • 3.6k views
ADD COMMENTlink modified 2.4 years ago by h.mon30k • written 2.4 years 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 2.4 years ago by Pierre Lindenbaum129k

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 2.4 years 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 2.4 years ago by h.mon30k
1
gravatar for genomax
2.4 years ago by
genomax87k
United States
genomax87k 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 2.4 years ago • written 2.4 years ago by genomax87k
0
gravatar for Joe
2.4 years ago by
Joe17k
United Kingdom
Joe17k 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 2.4 years ago by Joe17k
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: 1182 users visited in the last hour