This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to remove some fasta sequences by header information from a large fasta file, any command and script please?

Dear all,

I would like to remove some fasta sequences within a large fasta file in term of header information (sequence name), could anybody please help me out to this end? Thanks so much in advance

The header information is like here:

> contig1
ATGCGTACGTCATG
>contig2
GCTACGTCCCA
alignment rna-seq blast next-gen

2 answers

The BBMap package contains a tool called FilterByName which can do this:

filterbyname.sh in=file.fa out=filtered.fa names=contig1,contig2

It supports prefixes, case-sensitive or insensitive matching, inclusion or exclusion, and substring matching. Rather than a list of names, you can instead point "names=" to another fasta or fastq file.

Thanks Brian. I'm trying to use your tool to this end, but I faced with the following error. Could you please let me know what is wrong and how to solve it?

Exception in thread "main" java.lang.AssertionError: Unknown parameter names.txt
        at driver.FilterReadsByName.<init>(FilterReadsByName.java:118)
        at driver.FilterReadsByName.main(FilterReadsByName.java:41)

Many thanks

What is wrong:

Unknown parameter names.txt

How to solve it:

Execute command as Brian suggested (using parameter names=).

There are several threads with similar questions, just enjoy the multitude of answers and choose the one most suited for you, see here, or here, or here.

Log in to answer this question.