@harish
Just FYI (for larger datasets), see this (seqkit benchmark)
• 0 views
•
link
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?
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
@harish
Just FYI (for larger datasets), see this (seqkit benchmark)
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.
See this post and tweak for 300.
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.
Thanks for the correction Ram.
duplicate: How To Filter Multi Fasta By Length??
Other people gave you excellent solutions. Nevertheless, you may be also interested in SEDA (http://www.sing-group.org/seda/ ), an open-source tool for processing FASTA files. Among other functions, it provides an operation to apply different filters, including sequence length (https://www.sing-group.org/seda/manual/operations.html#filtering ). Regards.
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.