Guest User

Untitled

a guest
Jun 24th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. #
  2. # @author Nelo Onyiah
  3.  
  4. require "rubygems"
  5. require "pp"
  6.  
  7. # Draw a promoter image (this is not yet complete and we need to think about it a bit)
  8. #
  9. # +-----+-----+-----+-----+
  10. # | |
  11. # | D E |
  12. # | +-----+ |
  13. # | F | |
  14. # + +-----+-----+ |
  15. # | | | |
  16. # +=====+ + +=====+
  17. # | A B C |
  18. # | | | |
  19. # + +-----+-----+ |
  20. # | |
  21. # +-----+-----+-----+-----+
  22. #
  23. # @since 0.2.5
  24. # @params [AlleleImage::Feature] the feature
  25. # @params [Magick::Image] the image to add the feature to
  26. # @params [Array<Num, Num>] the x and y coordinates
  27. # @returns [Magick::Image]
  28. def draw_promoter( feature, image, point )
  29. a_coord = point
  30. b_coord = [ a_coord[0] + ( @text_width * feature[:name].length / 2 ), point[1] ]
  31. c_coord = [ a_coord[0] + ( @text_width * feature[:name].length ), point[1] ]
  32. d_coord = [ b_coord[0], @top_margin ]
  33. e_coord = [ c_coord[0], @top_margin ]
  34.  
  35. promoter = Magick::Draw.new
  36.  
  37. promoter.stroke("black")
  38. promoter.stroke_width(@sequence_stroke_width)
  39. promoter.line( b_coord[0], b_coord[1], d_coord[0], d_coord[1] )
  40. promoter.draw( image )
  41.  
  42. draw_arrow( image, e_coord,
  43. :direction => feature[:orientation] == "forward" ? "east" : "west",
  44. :tail_height => e_coord[0] - d_coord[0] )
  45.  
  46. # draw_cassette_feature( image, feature, a_coord[0], d_coord[1] + ( ( b_coord[1] - d_coord[1] ) / 2 ) )
  47.  
  48. return image
  49. end
  50.  
  51. feature = { :name => "hBactP", :type => "promoter", :orientation => "forward" }
  52. image = Magick::Image.new( 200, 100 )
  53. point = [ 100, 50 ]
  54.  
  55. puts draw_promoter( feature, image, point ).write("/tmp/promoter.png")
Add Comment
Please, Sign In to add comment