Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # @author Nelo Onyiah
- require "rubygems"
- require "pp"
- # Draw a promoter image (this is not yet complete and we need to think about it a bit)
- #
- # +-----+-----+-----+-----+
- # | |
- # | D E |
- # | +-----+ |
- # | F | |
- # + +-----+-----+ |
- # | | | |
- # +=====+ + +=====+
- # | A B C |
- # | | | |
- # + +-----+-----+ |
- # | |
- # +-----+-----+-----+-----+
- #
- # @since 0.2.5
- # @params [AlleleImage::Feature] the feature
- # @params [Magick::Image] the image to add the feature to
- # @params [Array<Num, Num>] the x and y coordinates
- # @returns [Magick::Image]
- def draw_promoter( feature, image, point )
- a_coord = point
- b_coord = [ a_coord[0] + ( @text_width * feature[:name].length / 2 ), point[1] ]
- c_coord = [ a_coord[0] + ( @text_width * feature[:name].length ), point[1] ]
- d_coord = [ b_coord[0], @top_margin ]
- e_coord = [ c_coord[0], @top_margin ]
- promoter = Magick::Draw.new
- promoter.stroke("black")
- promoter.stroke_width(@sequence_stroke_width)
- promoter.line( b_coord[0], b_coord[1], d_coord[0], d_coord[1] )
- promoter.draw( image )
- draw_arrow( image, e_coord,
- :direction => feature[:orientation] == "forward" ? "east" : "west",
- :tail_height => e_coord[0] - d_coord[0] )
- # draw_cassette_feature( image, feature, a_coord[0], d_coord[1] + ( ( b_coord[1] - d_coord[1] ) / 2 ) )
- return image
- end
- feature = { :name => "hBactP", :type => "promoter", :orientation => "forward" }
- image = Magick::Image.new( 200, 100 )
- point = [ 100, 50 ]
- puts draw_promoter( feature, image, point ).write("/tmp/promoter.png")
Add Comment
Please, Sign In to add comment