This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Remove sequences <300 bases from FASTA file

I have a multiple FASTA file containing contigs deriving from metagenomic data. I need to remove all contigs less than 300 bp long. Ho do I proceed?

genome next-gen sequencing assembly

This should be just a comment and not an answer, as you're only pointing to an existing post/answer. I've moved it to one.

Hi zoppisemma

There are multiple solutions provided by different users. you should upvote/ accept answers which helped. This will help others looking for such solutions.

accept or upvote

4 answers

using seqkit

seqkit seq -m 300 your_fasta.fa

download here

Using reformat.sh from BBMap suite.

reformat.sh in=your.fa out=filtered.fa minlength=300

Hi!

You can use seqtk for the same. The command should be:

seqtk seq -L 300 contigs.fasta > file.fasta

Ahh. That's nice. Glad to learn something new today!

I am using it for all sorts of fasta/q manipulation and found it really fast and effective.

awk solution which should work for multiline fasta files:

awk -v RS=">" -v FS="\n" '{for(i=2;i<NF;i++) {l+=length($i)}; if(l>300) printf ">%s", $0}' test.fasta

Log in to answer this question.