Skip to content

Instantly share code, notes, and snippets.

@epaule
Last active July 8, 2022 16:09
Show Gist options
  • Save epaule/15b49602a787649c84b2f58a23d85713 to your computer and use it in GitHub Desktop.
Save epaule/15b49602a787649c84b2f58a23d85713 to your computer and use it in GitHub Desktop.
filter fasta file by size (less than)
#!/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