def self.transcript(args)
args = {
:height => 10,
:utr_fill_color => 'black',
:utr_stroke => "black",
:utr_stroke_width => 1,
:exon_fill_color => 'red',
:exon_stroke => "black",
:exon_stroke_width => 1,
:line_color => 'black',
:line_width => 1,
:exon_style => "fill-opacity:0.4;",
:utr_style => "",
:line_style => "",
:block_gaps => "",
:gap_marker => ""
}.merge!(args)
composite = []
if not args[:utrs].empty?
x,width = args[:strand] == '-' ? args[:utrs].shift : args[:utrs].pop
composite += Glyph.directed(:x => x,
:y => args[:y],
:width => width,
:strand => args[:strand],
:height => args[:height],
:fill_color => args[:utr_fill_color],
:stroke =>args[:utr_stroke],
:stroke_width => args[:utr_stroke_width],
:style => args[:utr_style] )
args[:utrs].each do |utr|
composite << Bio::Graphics::Primitive.new(:rectangle, {
:x => utr.first,
:width => utr.last,
:y => args[:y],
:height => args[:height],
:fill_color => args[:utr_fill_color],
:stroke =>args[:utr_stroke],
:stroke_width => args[:utr_stroke_width],
:style => args[:utr_style]} )
end
else
points = nil
x,width = args[:strand] == '-' ? args[:exons].shift : args[:exons].pop
composite += Glyph.directed(:x => x,
:y => args[:y],
:width => width,
:strand => args[:strand],
:height => args[:height],
:fill_color => args[:exon_fill_color],
:stroke =>args[:exon_stroke],
:stroke_width => args[:exon_stroke_width],
:style => args[:exon_style] )
end
args[:exons].each do |exon|
composite << Bio::Graphics::Primitive.new(:rectangle, {
:x => exon[0],
:width => exon[1],
:y => args[:y],
:height => args[:height],
:fill_color => args[:exon_fill_color],
:stroke =>args[:exon_stroke],
:stroke_width => args[:exon_stroke_width],
:style => args[:exon_style]} )
end
if args[:gap_marker] == "angled" and not args[:block_gaps].empty?
args[:block_gaps].each do |gap|
points = "#{gap.first},#{args[:y] + (args[:height]/2) } #{gap.first + (gap.last/2)},#{args[:y]} #{gap.first + gap.last},#{args[:y] + (args[:height]/2)}"
composite << Bio::Graphics::Primitive.new(:polyline, {
:points => points,
:stroke => args[:line_color],
:stroke_width => args[:line_width],
:fill => "none",
:line_style => args[:line_style]})
end
else
composite << Bio::Graphics::Primitive.new(:line, {
:x1 => args[:x],
:x2 => "#{args[:x] + args[:width]}",
:y1 => args[:y] + (args[:height]/2),
:y2 => args[:y] + (args[:height]/2),
:stroke => args[:line_color],
:stroke_width => args[:line_width],
:line_style => args[:line_style]})
end
composite
end