This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract sequences from fasta that have a certain length ?

lets say that I have a fasta file which have reads with different sizes and I want to create a new fasta that have reads with lengths ranging from 50bp to 100bp is there any tool for doing this? I checked this one:

https://bioinformaticsreview.com/20200728/extract-fasta-sequences-based-on-sequence-length-using-perl/?unapproved=848&moderation-hash=3b17a078f5852674e7f10c913b8561a6#comment-848

but I got an error message ):

readline() on unopened filehandle at extractfasta.pl line 7

this is the command that I used:

perl extractfasta.pl /path-to/BAC4A_L00M_R1_001.fasta 50 100 > 100_maxln.fasta
minlength fasta

1 answer

THanks so much for your answer, what I need is to make a new fasta that have sequences that have a length range between 50-100. those links are aproached to filter a fasta rather than extracting sequences by length

That is fine. People can find these solutions via search in future in one spot.

seqkit seq -m 50 -M 100 /path-to/BAC4A_L00M_R1_001.fasta > 100_maxln.fasta

Log in to answer this question.