Last active
July 8, 2022 16:09
-
-
Save epaule/15b49602a787649c84b2f58a23d85713 to your computer and use it in GitHub Desktop.
filter fasta file by size (less than)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# usage: ruby filter_fasta.rb size fasta.file | |
require 'bio' | |
s = ARGV.shift.to_i | |
Bio::FlatFile.auto(ARGF) do |ff| | |
ff.each do |entry| | |
if entry.seq.length < s | |
puts entry.seq.to_fasta(entry.definition) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment