Skip to content

Instantly share code, notes, and snippets.

@epaule
Created November 11, 2024 11:38
Show Gist options
  • Save epaule/314aab91945ba1cb0cf27fd0393b0d34 to your computer and use it in GitHub Desktop.
Save epaule/314aab91945ba1cb0cf27fd0393b0d34 to your computer and use it in GitHub Desktop.
remove ids from a fasta file
#!/usr/bin/env ruby
# usage: ruby remove_id_from_fasta.rb FILE_WITH_IDS FASTA_FILE
require 'bio'
ids = []
File.foreach(ARGV.shift, chomp: true) do |line|
ids << line
end
Bio::FlatFile.auto(ARGF) do |ff|
ff.each do |entry|
puts entry.seq.to_fasta(entry.definition) unless ids.include?(entry.entry_id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment