Skip to content

Instantly share code, notes, and snippets.

@gisleDK
Created January 24, 2014 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gisleDK/8594338 to your computer and use it in GitHub Desktop.
Save gisleDK/8594338 to your computer and use it in GitHub Desktop.
Prodigal GFF output and hmmsearch domtblout Merger to GFF
#!/usr/bin/env ruby
require 'pp'
prodigal_file = ARGV[0]
hmmsearch_file = ARGV[1]
hash_id = {}
File.open(hmmsearch_file) do |ios|
ios.each_line do |line|
line.chomp!
fields = line.split "\t"
hash_id[fields[0]] = [fields[1],fields[2]]
end
end
File.open(prodigal_file) do |ios|
ios.each_line do |line|
if line[0] != '#'
fields = line.split "\t"
attributes = fields.last.split ";"
hash_id.each do |key, val|
if fields[0] == key
attributes[2] = val[0]
attributes[3] = val[1]
end
end
fields[-1] = attributes.join ";"
line = fields.join "\t"
puts line
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment