Guest User

Untitled

a guest
Sep 11th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 1.86 KB | None | 0 0
  1. # Begin script
  2. #-------------
  3. #!/usr/bin/ruby
  4.  
  5. require 'rubygems'
  6. require 'ruby-debug' #For debugging only
  7.  
  8. #7/17/12  Evalue Picker
  9. #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
  10. #that occur with an evalue hit of that order of magnitude.
  11.  
  12. blaster = File.open("GenDB_Blaster_Output.txt")
  13.  
  14. #define variables for later use
  15. hitlist = []
  16.  
  17.  
  18. =begin
  19.   For the Eval list, I chose to store them in a key value pair (array)
  20.  
  21.  
  22.   So it would look like
  23.  
  24.    array = {
  25.     "6e10" => "1"
  26.     "4e10" => "2"
  27.    }
  28.  
  29.   That way I could check if the key existed, if not, create the entry, otherwise just add one to the keys value
  30. =end
  31.  
  32. Eval_list = {}
  33.  
  34. #Each line of blaster file create the variable named bar
  35. blaster.each { |bar|
  36.   bar.chomp! #Strip white space
  37.  
  38.   fields_from_blaster = bar.split("\t", 12)
  39.  
  40.   seqh = {
  41.     'contig'    => fields_from_blaster[0],
  42.     'hit'       => fields_from_blaster[1],
  43.     '%ID'       => fields_from_blaster[2],
  44.     'len'       => fields_from_blaster[3],
  45.     '#mismatch' => fields_from_blaster[4],
  46.     '#gaps'     => fields_from_blaster[5],
  47.     'qstart'    => fields_from_blaster[6],
  48.     'qend'      => fields_from_blaster[7],
  49.     'hstart'    => fields_from_blaster[8],
  50.     'hend'      => fields_from_blaster[9],
  51.     'Eval'      => fields_from_blaster[10],
  52.     'score'     => fields_from_blaster[11]
  53.   }
  54.  
  55.   hitlist << seqh  
  56.  
  57.   #determine if an evalue has already been in the array
  58.  
  59.   evalue = seqh["Eval"] #shortcut
  60.  
  61.   if Eval_list[evalue].nil? #If there is NOT an entry for this evalue, we want to add it
  62.     Eval_list[evalue] = 1
  63.   else #There is an entry for this evalue so we need to add one to its value
  64.     Eval_list[evalue] = Eval_list[evalue] + 1
  65.   end  
  66. }
  67.  
  68. Eval_list.each do |ev, freq|
  69. puts "#{ev}\t#{freq}\n"
  70. end
Add Comment
Please, Sign In to add comment