Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Begin script
- #-------------
- #!/usr/bin/ruby
- require 'rubygems'
- require 'ruby-debug' #For debugging only
- #7/17/12 Evalue Picker
- #This program will take an output from blaster and bin the E-values into orders of magnitude and then out put the number of hits
- #that occur with an evalue hit of that order of magnitude.
- blaster = File.open("GenDB_Blaster_Output.txt")
- #define variables for later use
- hitlist = []
- =begin
- For the Eval list, I chose to store them in a key value pair (array)
- So it would look like
- array = {
- "6e10" => "1"
- "4e10" => "2"
- }
- That way I could check if the key existed, if not, create the entry, otherwise just add one to the keys value
- =end
- Eval_list = {}
- #Each line of blaster file create the variable named bar
- blaster.each { |bar|
- bar.chomp! #Strip white space
- fields_from_blaster = bar.split("\t", 12)
- seqh = {
- 'contig' => fields_from_blaster[0],
- 'hit' => fields_from_blaster[1],
- '%ID' => fields_from_blaster[2],
- 'len' => fields_from_blaster[3],
- '#mismatch' => fields_from_blaster[4],
- '#gaps' => fields_from_blaster[5],
- 'qstart' => fields_from_blaster[6],
- 'qend' => fields_from_blaster[7],
- 'hstart' => fields_from_blaster[8],
- 'hend' => fields_from_blaster[9],
- 'Eval' => fields_from_blaster[10],
- 'score' => fields_from_blaster[11]
- }
- hitlist << seqh
- #determine if an evalue has already been in the array
- evalue = seqh["Eval"] #shortcut
- if Eval_list[evalue].nil? #If there is NOT an entry for this evalue, we want to add it
- Eval_list[evalue] = 1
- else #There is an entry for this evalue so we need to add one to its value
- Eval_list[evalue] = Eval_list[evalue] + 1
- end
- }
- Eval_list.each do |ev, freq|
- puts "#{ev}\t#{freq}\n"
- end
Add Comment
Please, Sign In to add comment