Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for subfeatures.

git-svn-id: svn+ssh://rubyforge.org/var/svn/bio-graphics@22 a2f46d20-7dc0-45cf-9d05-bfa4e4ff58eb
  • Loading branch information...
commit 3313fc4901f090da95d8eb4a648afb4b13856cd9 1 parent ff16da3
jandot authored
Showing with 1,926 additions and 2,648 deletions.
  1. +29 −17 trunk/README.DEV
  2. +16 −0 trunk/Rakefile
  3. +87 −47 trunk/TUTORIAL
  4. +1 −1  trunk/bio-graphics.gemspec
  5. +0 −28 trunk/doc/classes/Bio.html
  6. +1 −151 trunk/doc/classes/Bio/Graphics.html
  7. +3 −243 trunk/doc/classes/Bio/Graphics/Panel.html
  8. +16 −5 trunk/doc/classes/Bio/Graphics/Panel.src/M000006.html
  9. +5 −54 trunk/doc/classes/Bio/Graphics/Panel.src/M000007.html
  10. +18 −18 trunk/doc/classes/Bio/Graphics/Panel/Ruler.html
  11. +6 −14 trunk/doc/classes/Bio/Graphics/Panel/Ruler.src/M000009.html
  12. +10 −41 trunk/doc/classes/Bio/Graphics/Panel/Ruler.src/M000010.html
  13. +45 −6 trunk/doc/classes/Bio/Graphics/Panel/Ruler.src/M000013.html
  14. +3 −253 trunk/doc/classes/Bio/Graphics/Panel/Track.html
  15. +12 −12 trunk/doc/classes/Bio/Graphics/Panel/Track.src/M000008.html
  16. +26 −27 trunk/doc/classes/Bio/Graphics/Panel/Track.src/M000009.html
  17. +30 −31 trunk/doc/classes/Bio/Graphics/Panel/Track.src/M000010.html
  18. +12 −28 trunk/doc/classes/Bio/Graphics/Panel/Track.src/M000012.html
  19. +25 −36 trunk/doc/classes/Bio/Graphics/Panel/Track.src/M000013.html
  20. +3 −257 trunk/doc/classes/Bio/Graphics/Panel/Track/Feature.html
  21. +24 −143 trunk/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000015.html
  22. +5 −5 trunk/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.html
  23. +18 −0 trunk/doc/classes/ImageMap.html
  24. +10 −10 trunk/doc/classes/ImageMap/ImageMapElement.html
  25. +5 −6 trunk/doc/classes/ImageMap/ImageMapElement.src/M000004.html
  26. +1 −1  trunk/doc/created.rid
  27. +81 −46 trunk/doc/files/README_DEV.html
  28. +144 −77 trunk/doc/files/TUTORIAL.html
  29. +39 −1 trunk/doc/files/lib/bio-graphics_rb.html
  30. +11 −6 trunk/doc/files/lib/bio/graphics/feature_rb.html
  31. +1 −1  trunk/doc/files/lib/bio/graphics/image_map_rb.html
  32. +8 −1 trunk/doc/files/lib/bio/graphics/panel_rb.html
  33. +1 −1  trunk/doc/files/lib/bio/graphics/ruler_rb.html
  34. +1 −1  trunk/doc/files/lib/bio/graphics/track_rb.html
  35. +0 −9 trunk/doc/fr_class_index.html
  36. +0 −7 trunk/doc/fr_file_index.html
  37. +0 −17 trunk/doc/fr_method_index.html
  38. +2 −2 trunk/doc/index.html
  39. +26 −1 trunk/lib/bio-graphics.rb
  40. +271 −267 trunk/lib/bio/graphics/feature.rb
  41. +203 −212 trunk/lib/bio/graphics/panel.rb
  42. +1 −1  trunk/lib/bio/graphics/ruler.rb
  43. +352 −369 trunk/lib/bio/graphics/subfeature.rb
  44. +135 −142 trunk/lib/bio/graphics/track.rb
  45. +2 −8 trunk/lib/feature.rb
  46. +1 −1  trunk/samples/arkdb_features.rb
  47. +32 −24 trunk/samples/glyph_showcase.rb
  48. +19 −0 trunk/samples/protein_domains.rb
  49. +21 −8 trunk/samples/subfeatures.rb
  50. +4 −0 trunk/scripts/clones.txt
  51. +23 −0 trunk/scripts/data.gff
  52. BIN  trunk/scripts/data.png
  53. +91 −0 trunk/scripts/gff2png.rb
  54. +12 −0 trunk/scripts/transcript_data.gff
  55. +3 −3 trunk/test/unit/test_creation.rb
  56. +30 −8 trunk/test/unit/test_draw.rb
  57. +1 −1  trunk/test/unit/test_subfeatures.rb
View
46 trunk/README.DEV
@@ -7,25 +7,27 @@ This README is mainly meant to explain how the code works (rather than how to _u
I've tried to document as much as possible in the code itself, see for example the comments that accompany the setting of the defaults for Bio::Graphics in the panel.rb file. However, the bigger picture can not be explained that way.
=== The files
-There's one file for each class: panel, track, feature, ruler and image_map. See the tutorial on a breakdown what each of these do. All of these except the image_map make up a picture. The image_map is used to describe the HTML map that can be created to make a picture clickable.
+There's one file for each class: panel, track, feature, subfeature, ruler and image_map. See the tutorial on a breakdown what each of these do. All of these except the image_map make up a picture. The image_map is used to describe the HTML map that can be created to make a picture clickable.
Classes are embedded in each other: instead of
Bio::Graphics::Panel
Bio::Graphics::Ruler
Bio::Graphics::Track
Bio::Graphics::Feature
+ Bio::Graphics::SubFeature
we have:
Bio::Graphics::Panel
Bio::Graphics::Panel::Ruler
Bio::Graphics::Panel::Track
Bio::Graphics::Panel::Track::Feature
+ Bio::Graphics::Panel::Track::Feature::SubFeature
There's a reason for this. A track can only exist within the confines of a panel (i.e. a panel is a container for tracks), and a feature can only exist within the confines of a track. In addition, there are quite some instances where information from the panel is necessary for the track, and from the track for the features.
=== The workflow
==== 1. Creating the panel
The user has to start with a
- my_panel = Bio::Graphics::Panel.new(length, width, clickable, display_start, display_stop)
+ my_panel = Bio::Graphics::Panel.new(length, width, clickable, display_start, display_stop, verticle)
When this happens, among other things, the instance variable @tracks is created that will later contain the actual Track objects. In addition, there's @number_of_feature_rows. You'll later see that each Track object also has its @number_of_feature_rows. The panel needs this information to know how far it has to go down before it can start drawing a track: the first track will be just below the ruler, but the vertical coordinates of the second one depend on the height of all the ones that were drawn previously. And _that_ in turn is defined by the number of times a feature would overlap with another one and therefore had to be _bumped_ down.
@@ -37,9 +39,12 @@ So this covered the Panel#initialize...
==== 2. Adding tracks to the panel
Because tracks are inherently part of a panel and cannot exist on their own, they can only be created by using a Panel method rather than a Track method.
- my_track_1 = my_panel.add_track(name, label = false, feature_colour = [0,0,1], feature_glyph = 'generic')
+ my_track_1 = my_panel.add_track(name, label = false, feature_glyph = :generic, feature_colour = [0,0,1])
+Feature_glyph and feature_colour are the default values to use for all features in this track.
-This creates a new Track object and adds it to the @tracks array of the Panel object. Several instance variables are set for the Track object, including @features (which is an array of Feature objects for that track) and @number_of_feature_rows. Every time a feature cannot be drawn because it would overlap with another one, it will be 'bumped' down until it can be drawn. This effectively results in _rows_ that contain the features. The @number_of_feature_rows is just the number of rows (to be able to calculate the height of the track afterwards).
+The feature_glyph can either be one of the approved symbols (:generic, :spliced, ...; see documentation Bio::Graphics::Panel#add_track) or a hash. The keys of the hash refer to the types of subfeature; the values are these symbols again. For how that's used, see below (5. Drawing the thing).
+
+This creates a new Track object and adds it to the @tracks array of the Panel object. Several instance variables are set for the Track object, including @features (which is an array of Feature objects for that track) and @number_of_feature_rows. Every time a feature cannot be drawn because it would overlap with another one, it will be 'bumped' down until it can be drawn. This effectively results in _rows_ that contain the features. The @number_of_feature_rows is just this number of rows (to be able to calculate the height of the track afterwards).
------------------------------------------------------
******* **** ********* ***** *****
@@ -49,29 +54,33 @@ This creates a new Track object and adds it to the @tracks array of the Panel ob
The Panel#add_track method returns the Track object itself, because the latter has to be accessible to be able to assign features to it.
==== 3. Adding features to a track
-Same thing as adding a track to a panel: the feature can only be added by the user by using the Track#add_feature method. Parameters are the name of the feature, the location and the link.
+Same thing as adding a track to a panel: the feature can only be added by the user by using the Track#add_feature method. Arguments are a Bio::Feature object (which itself has a type and location), a label, and the glyph and colour. The glyph can either be one of the approved symbols, or a hash (see 2. Adding tracks to the panel).
-The location of a feature can be something like 'complement(join(10..20,50..70))'. To be able to parse this, I use the Bio::Locations object from bioruby (see http://www.bioruby.org). A Bio::Locations (plural) object contains one or more Bio::Location (singular) objects, which are the subfeatures: 10..20 and 50..70. It's these Bio::Location objects we use to calculate the ultimate start and stop of the feature.
+The location of a Bio::Feature object can be something like 'complement(join(10..20,50..70))'. To be able to parse this, I use the Bio::Locations object from bioruby (see http://www.bioruby.org). A Bio::Locations (plural) object contains one or more Bio::Location (singular) objects, which are the subfeatures: 10..20 and 50..70. It's these Bio::Location objects we use to calculate the ultimate start and stop of the feature.
The Track#add_feature method returns the Track object itself.
-Now let's look at the other end: the Feature object that gets created. In the Feature#initialize method, you'll notice, apart from the obvious variables, the following instances variables: @pixel_range_collection, @chopped_at_start, @chopped_at_stop, @hidden_subfeatures_at_start and @hidden_subfeatures_at_stop. Let's take these one by one:
+Now let's look at the other end: the Feature object that gets created. In the Feature#initialize method, you'll notice, apart from the obvious variables, the following instances variables: @subfeatures, @left_pixel_of_subfeatures and @right_pixel_of_subfeatures. The @subfeatures thing is quite important. In some cases (e.g. mRNAs that consist of 5'UTR, CDS and 3'UTR), we will want to make a distinction between the UTRs and the CDS for drawing (see TUTORIAL). To make this possible, we will have Feature#new always create an Array of SubFeature objects. Often this array will only contain one object. Drawing of the glyphs is done on a subfeature-by-subfeature basis.
+The @left_pixel_of_subfeatures and @right_pixel_of_subfeatures just represent the outermost pixels for this feature.
+
+==== 4. Creating subfeatures (done automatically by Feature#new)
+For each subfeature#new several instance variables are created: @pixel_range_collection, @chopped_at_start, @chopped_at_stop, @hidden_subfeatures_at_start and @hidden_subfeatures_at_stop. Let's take these one by one:
===== @pixel_range_collection
Now _this_ is the crucial bit: it will hold the information on what pixels (on the horizontal axis) should be covered. This means that any part of the feature that does not fall within the view is _not_ in this collection. Basically, for every subfeature (e.g. exon for a gene), the location of that subfeature is compared to the region of the view. If a subfeature is not in the view at all, its positions are discarded (but other stuff does happen, see below); if a subfeature is at the left of the picture but actually extends outwith the view, the start pixel will become 1. You get the picture. Also see the mini diagrams in the code itself.
-These start and stop positions are used to create Bio::Graphics::Panel::Track::PixelRange objects. Unspliced objects will have an array @pixel_range_collection with just one element.
+These start and stop positions are used to create Bio::Graphics::Panel::Track::Feature::SubFeature::PixelRange objects. Unspliced objects will have an array @pixel_range_collection with just one element.
===== @chopped_at_start and @chopped_at_stop
-Suppose you've got a directed feature (so one with an arrow), and the 3' end falls outside of the view. What would happen, is that the 3' end that's out of view would be chopped of (that's good), but also that the end of the glyph (which is _not_ the end of the feature) becomes an arrow. I don't want that. Instead, the arrow should be removed.
+Suppose you've got a directed feature (so one with an arrow), and the 3' end falls outside of the view. What would happen, is that the 3' end that's out of view would be chopped of (that's good), but also that the end of the glyph (which is _not_ the end of the feature) becomes an arrow. We don't want that; instead, the arrow should be removed.
That's where the @chopped_at_start and @chopped_at_stop come in. If these are set to true (while building the @pixel_range_collection), the arrow is not drawn.
===== @hidden_subfeatures_at_start and @hidden_subfeatures_at_stop
For spliced features, it might be that one or more of the subfeatures (e.g. exons) lies outwith the view. We normally draw e.g. genes by drawing the exons as boxes and connecting them with small lines. The drawing code itself (see later) takes all exons within view and draws those connections. However, if an exon is outside of the viewing area, this line is not drawn. The @hidden_subfeatures_at_start and @hidden_subfeatures_at_stop are just flags to capture this.
-==== 4. Drawing the thing
-The Cairo library (http://cairographics.org) is used for the actual drawing. The main concepts in the Cairo drawing model are (please also see http://cairographics.org/tutorial):
+==== 5. Drawing the thing
+The Cairo and Pango libraries (http://cairographics.org, http://www.pango.org) are used for the actual drawing. The main concepts in the Cairo drawing model are (please also see http://cairographics.org/tutorial):
* *source*: the _paint_ you'll be using
* *destination*: the _surface_ (Cairo::ImageSurface) that you want to draw onto
* *mask*: controls where you apply the source to the destination. Stuff like 'line_to'.
@@ -79,7 +88,7 @@ The Cairo library (http://cairographics.org) is used for the actual drawing. The
From the cairo tutorial: "Before you can start to draw something with cairo, you need to create the context. <SNIP> When you create a cairo context, it must be tied to a specific surface - for example, an image surface if you want to create a PNG file." So that's what we have to do: create a Cairo::ImageSurface and connect a Cairo::Context to it.
-Now let's walk through the code itself...
+Now let's walk through the drawing code itself...
When a user draws a panel, the first thing that happens, is the creation of a Cairo::ImageSurface (the _destination_). To be able to do this, we need to know the dimensions. But there's a slight problem: we can't know the height of the picture until it's actually drawn. The way we'll circumvent this, is that we create a really high picture (called "huge_panel_drawing") that we'll crop afterwards.
@@ -92,9 +101,10 @@ There's a small issue when you actually start drawing the ticks. Most of the tim
The ruler height @height consists of the height of the ruler itself plus the height of the numbers.
===== Drawing the tracks
-Drawing each track starts out with the general header: a line above it and the title. Obviously, the more challenging part is drawing the features themselves.
+Drawing each track starts out with the general header: a line above it and the title. We also 'translate' the track down to not let it overlap with previously drawn tracks. Obviously, the more challenging part is drawing the features themselves.
-First thing we have to do, is figure out what the *vertical* *coordinates* of the glyph should be (i.e. the row). To keep track of what parts of the screen are already occupied by features (so that we know when a new feature has to be bumped down), I make use of a *grid*. The grid is basically a hash with the keys being the row number, and the values arrays of ranges. (These ranges use basepair units rather than pixels, but that's completely arbitrary.) For each feature, we first check if we can draw it at the top of the track (i.e. row 1) and if we can't move it down a row at a time until there's room for it.
+===== Drawing the (sub)features.
+First thing we have to do, is figure out what the *vertical* *coordinates* of the glyph should be (i.e. the row). To keep track of what parts of the screen are already occupied by features (so that we know when a new feature has to be bumped down), we make use of a *grid*. The grid is basically a hash with the keys being the row number, and the values arrays of ranges. (These ranges use basepair units rather than pixels, but that's completely arbitrary.) For each feature, we first check if we can draw it at the top of the track (i.e. row 1) and if we can't move it down a row at a time until there's room for it.
So for example, suppose we've already drawn two features that have the following positions: 100..150 and 200..225. The grid would then look like this:
@@ -105,11 +115,13 @@ If we'd like to draw a new feature from 125..175 (which overlaps the first of th
grid = { 1 => [(100..150),(200..225)],
2 => [(125..175)] }
-So now we know what the vertical coordinates of the glyph should be. Next step is to check if there's reasons we would like to *change* *the* *requested* *glyph* *type* *from* *directed* *to* *undirected*. If the user asks for directed glyphs (i.e. ones with an arrow at the end), but the view is zoomed _way_ out, there's no way the arrow will be visible. If we'd try to draw that arrow anyway, it would become bigger than the feature itself. Another reason would be if the feature's 3' end extends outwith the picture.
+So now we know what the vertical coordinates of the glyph should be.
+
+The actual drawing is redirected to the subfeatures. Next step is to check if there's reasons we would like to *change* *the* *requested* *glyph* *type* *from* *directed* *to* *undirected*. If the user asks for directed glyphs (i.e. ones with an arrow at the end), but the view is zoomed _way_ out, there's no way the arrow will be visible. If we'd try to draw that arrow anyway, it would become bigger than the feature itself. Another reason would be if the feature's 3' end extends outwith the picture.
Finally, we can *draw*. The actual drawing bit should be quite self-explanatory (_move_to_, _line_to_, ...).
-For the spliced features (_spliced_ itself and _directed_spliced_), we first draw the components (i.e. the exons) keeping track of the start and stop positions of the gaps (i.e. introns). We then add the connections in those gaps. In addition, we draw a line that extends to the side of the picture if there are exons out of view. This flag was set when the feature was created (see above: @hidden_subfeatures_at_start and @hidden_subfeatures_at_stop).
+For the spliced features (:spliced and :directed_spliced), we first draw the components (i.e. the exons) keeping track of the start and stop positions of the gaps (i.e. introns). We then add the connections in those gaps. In addition, we draw a line that extends to the side of the picture if there are exons out of view. This flag was set when the feature was created (see above: @hidden_subfeatures_at_start and @hidden_subfeatures_at_stop).
When the user wants a clickable map, we also have to record that this region should be added to the image map.
@@ -118,4 +130,4 @@ When everything has been drawn, we finally know the number of rows for that trac
===== Finalizing the panel
So now we have a huge panel (see "huge_panel_drawing" above) which is way to high. This is converted to a panel of the right size by creating a new panel (i.e. the cairo destination), and then using the huge panel as a source to be transferred on that new destination.
-And we just write the PNG to a file. If the user wanted a clickable map, also create the HTML file.
+And we just write the PNG to a file. If the user wanted a clickable map, also create the HTML file.
View
16 trunk/Rakefile
@@ -18,6 +18,22 @@ desc "Create RDoc documentation"
file 'doc/index.html' => file_list do
puts "######## Creating RDoc documentation"
system "rdoc --title 'Bio::Graphics documentation' -m TUTORIAL TUTORIAL README.DEV lib/"
+ tmp_file = File.open('doc/tmp.html', 'w')
+ File.open('doc/files/TUTORIAL.html').each do |line|
+ line.chomp!
+ if line =~ /<\/body>/
+ tmp_file.puts '<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">'
+ tmp_file.puts '</script>'
+ tmp_file.puts '<script type="text/javascript">'
+ tmp_file.puts '_uacct = "UA-2131816-4";'
+ tmp_file.puts 'urchinTracker();'
+ tmp_file.puts '</script>'
+ tmp_file.puts line
+ else
+ tmp_file.puts line
+ end
+ end
+ File.move('doc/tmp.html', 'doc/files/TUTORIAL.html')
end
desc "An alias for creating the RDoc documentation"
View
134 trunk/TUTORIAL
@@ -11,9 +11,13 @@ Homepage: http://bio-graphics.rubyforge.org
(If you'd like to know how the code itself works, please see the README.DEV)
== Overview and terms used
-This Bio::Graphics library allows for drawing overviews of genomic regions, similar to the pictures drawn by gbrowse[http://www.gmod.org/wiki/index.php/Gbrowse]. Basically, it allows creating simple images that display features on a linear map. The code is based on the equivalent code in the bioperl[http://www.bioperl.org/wiki/Main_Page] project.
+This Bio::Graphics library allows for drawing overviews of genomic regions, similar to the pictures drawn by gbrowse[http://www.gmod.org/wiki/index.php/Gbrowse]. Basically, it allows creating simple images that display features on a linear map, including the position of subdomains in a protein (see picture). It's now also possible to create vertical pictures.
-Any Bio::Graphics image consists of the following parts (nomenclature identical to that from bioperl):
+link:images/protein_domains.png
+
+link:images/vertical.png
+
+Any Bio::Graphics image consists of the following parts (concepts and nomenclature identical to that from bioperl[http://www.bioperl.org/wiki/Main_Page]):
* one panel: container of all tracks
* one or more tracks: container of the features. Multiple tracks can exist in the same graphic to allow for differential visualization of different feature types (e.g. genes as blue rectangles and polymorphisms as red triangles)
* one or more features in each track: these are the actual features that you want to display (e.g. 'gene 1', 'SNP 123445')
@@ -35,7 +39,7 @@ Below is an annotated version of the picture at the top of the page. The whole p
link:images/terms.png
-As a feature can only exist within the confines of a track and a track can only exist within the confines of a panel, these classes are encapsuled. This means that the Track class is not Bio::Graphics::Track, but Bio::Graphics::Panel::Track; the same goes for Bio::Graphics::Panel::Track::Feature.
+As a feature can only exist within the confines of a track and a track can only exist within the confines of a panel, these classes are encapsulated. This means that the Track class is not Bio::Graphics::Track, but Bio::Graphics::Panel::Track; the same goes for Bio::Graphics::Panel::Track::Feature.
== Glyphs
@@ -50,56 +54,76 @@ The code below was used to create the picture showing all the different glyphs m
For an explanation of the arguments with each method for this example, see the Bio::Graphics::Panel and Bio::Graphics::Panel::Track object documentation.
1 # Load the library
- 2 require 'bio-graphics' # or require_gem 'bio-graphics'
- 3
+ 2 require 'bio-graphics' # or require_gem 'bio-graphics' or gem 'bio-graphics'
+ 3
4 # Create the panel
- 5 my_panel = Bio::Graphics::Panel.new(500, 600, true, 1, 500)
+ 5 my_panel = Bio::Graphics::Panel.new(500, 1000, false)
6
7 # Create the tracks
- 8 generic_track = my_panel.add_track('generic')
- 9 directed_track = my_panel.add_track('directed',[0,1,0],'directed_generic')
- 10 triangle_track = my_panel.add_track('triangle',[1,0,0],'triangle')
- 11 spliced_track = my_panel.add_track('spliced',[1,0,0],'spliced')
- 12 directed_spliced_track = my_panel.add_track('directed_spliced',[1,0,1],'directed_spliced')
- 13
- 14 # Add features to each track
- 15 generic_track.add_feature('clone1','250..375', 'http://www.newsforge.com')
- 16 generic_track.add_feature('clone2','54..124', 'http://www.thearkdb.org')
- 17 generic_track.add_feature('clone3','100..449', 'http://www.google.com')
- 18
- 19 directed_track.add_feature('marker1','50..60', 'http://www.google.com')
- 20 directed_track.add_feature('marker2','complement(80..120)', 'http://www.sourceforge.net')
- 21
- 22 triangle_track.add_feature('snp1','56')
- 23 triangle_track.add_feature('snp2','103','http://digg.com')
- 24
- 25 spliced_track.add_feature('gene1','join(34..52,109..183)','http://news.bbc.co.uk')
- 26 spliced_track.add_feature('gene2','complement(join(170..231,264..299,350..360,409..445))')
- 27 spliced_track.add_feature('gene3','join(134..152,209..283)')
- 28
- 29 directed_spliced_track.add_feature('gene4','join(34..52,109..183)', 'http://www.vrtnieuws.net')
- 30 directed_spliced_track.add_feature('gene5','complement(join(170..231,264..299,350..360,409..445))')
- 31 directed_spliced_track.add_feature('gene6','join(134..152,209..283)')
- 32
- 33 # Draw the thing
- 34 my_panel.draw('glyph_showcase.png')
+ 8 generic_track = my_panel.add_track('generic', false)
+ 9 line_track = my_panel.add_track('line', false, :line, [0,0,1])
+ 10 line_with_handles_track = my_panel.add_track('line_with_handles', false, :line_with_handles, [1,0,0])
+ 11 directed_track = my_panel.add_track('directed', false, :directed_generic, [0,1,0])
+ 12 triangle_track = my_panel.add_track('triangle', false, :triangle, [1,0,0])
+ 13 spliced_track = my_panel.add_track('spliced', false, :spliced, [1,0,0])
+ 14 directed_spliced_track = my_panel.add_track('directed_spliced', false, :directed_spliced, [1,0,1])
+ 15 composite_track = my_panel.add_track('composite_features', false, { 'utr' => :line, 'cds' => :directed_spliced})
+ 16
+ 17 # Add features to each track
+ 18 generic_track.add_feature(Bio::Feature.new('clone', '250..375'), 'anonymous', 'http://www.newsforge.com')
+ 19 generic_track.add_feature(Bio::Feature.new('clone', '54..124'), 'anonymous', 'http://www.thearkdb.org')
+ 20 generic_track.add_feature(Bio::Feature.new('clone', '100..449'), 'anonymous', 'http://www.google.com')
+ 21
+ 22 line_track.add_feature(Bio::Feature.new('utr', 'complement(200..320)'), 'anonymous')
+ 23 line_track.add_feature(Bio::Feature.new('utr', '355..480'), 'anonymous', 'http://www.zdnet.co.uk')
+ 24
+ 25 line_with_handles_track.add_feature(Bio::Feature.new('utr', 'complement(200..320)'), 'anonymous')
+ 26 line_with_handles_track.add_feature(Bio::Feature.new('utr', '355..480', 'http://www.zdnet.co.uk'), 'anonymous')
+ 27
+ 28 directed_track.add_feature(Bio::Feature.new('primer', '50..60', 'http://www.google.com'), 'anonymous')
+ 29 directed_track.add_feature(Bio::Feature.new('primer', 'complement(80..120)'), 'anonymous', 'http://www.sourceforge.net')
+ 30
+ 31 triangle_track.add_feature(Bio::Feature.new('snp', '56'), 'anonymous')
+ 32 triangle_track.add_feature(Bio::Feature.new('snp', '103','http://digg.com'), 'anonymous')
+ 33
+ 34 spliced_track.add_feature(Bio::Feature.new('spliced', 'join(34..52,109..183)'), 'anonymous','http://news.bbc.co.uk')
+ 35 spliced_track.add_feature(Bio::Feature.new('spliced', 'complement(join(170..231,264..299,350..360,409..445))'), 'anonymous')
+ 36 spliced_track.add_feature(Bio::Feature.new('spliced', 'join(134..152,209..283)'), 'anonymous')
+ 37
+ 38 directed_spliced_track.add_feature(Bio::Feature.new('cds', 'join(34..52,109..183)'), 'anonymous', 'http://www.vrtnieuws.net')
+ 39 directed_spliced_track.add_feature(Bio::Feature.new('cds', 'complement(join(170..231,264..299,350..360,409..445))'), 'anonymous', 'http://bioinformatics.roslin.ac.uk')
+ 40 directed_spliced_track.add_feature(Bio::Feature.new('cds', 'join(134..152,209..283)'), 'anonymous')
+ 41
+ 42 utr5 = Bio::Feature.new('utr', '100..150')
+ 43 cds = Bio::Feature.new('cds', 'join(150..225, 250..275, 310..330)')
+ 44 utr3 = Bio::Feature.new('utr', '330..375')
+ 45
+ 46 transcript = Bio::Feature.new('transcript', 'join(100..150, 150..225, 250..275, 310..330, 330..375)', [], nil, [utr5,cds,utr3])
+ 47 composite_track.add_feature(transcript, 'my_transcript')
+ 48
+ 49 # Draw the thing
+ 50 my_panel.draw('glyph_showcase.png')
Let's walk through this:
* Line 2: load the actual library code. Make sure that the library is in your RUBYLIB path.
* Line 5: Create the panel, which is nothing more than the canvas you'll be working on. The following parameters were used:
* The sequence is 500 bp long.
- * The width of the picture will be 600 points.
- * A HTML page will be created to make hyperlinks possible (the _true_)
- * The picture will be zoomed in from bp 1 to 500 (i.e. completely zoomed out).
-* Lines 8-12: Create the different tracks. Parameters are:
- * name.
- * colour. At the moment in RGB. (This will probably change to colour names in the future).
- * type. See the picture above and Bio::Graphics::Panel::Track#new for allowed values.
-* Lines 15-31: Add features to each track. Parameters are:
+ * The width of the picture will be 1000 points.
+* Lines 8-15: Create the different tracks. Parameters are:
* name.
- * location. This should be a location parsable by bioruby's[http://www.bioruby.org] Bio::Locations object.
+ * flag if feature labels should be drawn (here: false)
+ * the default glyph for features in this track. This can be overridden on a feature-by-feature basis. See the picture above and Bio::Graphics::Panel::Track#new for allowed values.
+ * the default colour for features in this track. This can also be overridden on a feature-by-feature basis. At the moment in RGB. (This will probably change to colour names in the future).
+* Lines 18-47: Add features to each track. Parameters are:
+ * a Bio::Feature object. (See bioruby documentation at http://www.bioruby.org)
+ * the label to be used (here: all are 'anonymous')
* link.
-* Line 34: Create the actual picture. If the third parameter to the initial Panel#new call (in line 5) is 'true', a HTML file is created as well.
+* Line 50: Create the actual picture. If the third parameter to the initial Panel#new call (in line 5) is 'true', a HTML file is created as well.
+
+That's pretty clear, but what's happening with the composite_track (on lines 15 and 42-47)?
+
+To set the glyph for a feature (or the default glyph in a track), you normally use a symbol, like :generic or :directed_spliced. For composite features, however, we've made it possible to have different subfeatures drawn in different ways. In this example: we want to draw the UTRs as thin lines, while the CDS is big boxes connected with thin lines.
+How does this work? See lines 42 to 47. If the feature you're adding to a track has subfeatures, you can use the type of the subfeature to direct the glyph to use. In the example above: the utr5 and utr3 have 'utr' as the first argument in the Bio::Feature#new, and the cds object has 'cds'. The transcript that gets created in line 46 takes these three Bio::Feature objects as subfeatures (the last argument). Now up in line 15 we set the glyph of this track to the hash {'utr' => :line, 'cds' => :directed_spliced}. What this does, is it takes each subfeature in turn, and draws it using the glyph that matches its type.
=== Hyperlinks
There are no graphic formats that are inherently clickable (SVG is a special case and the _display_ of it is not the SVG itself). Therefore, in case the user wants a clickable graphic, an accompanying HTML file is created with the same name as the picture but obviously the .html extension. This file contains the map and will display a clickable picture when loaded in a webbrowser.
@@ -108,10 +132,26 @@ There are no graphic formats that are inherently clickable (SVG is a special cas
Development of the library is at http://rubyforge.org/projects/bio-graphics/
There are different ways to install the library.
-* Export for SVN (for the latest development version): "svn checkout svn://rubyforge.org/var/svn/bio-graphics"
-* As a rubygem: download the bio-graphics-1.0.gem from the website, and do "gem install bio-graphics-1.0.gem"
+* The easy way: gem install bio-graphics
+* The hard (but cutting-edge) way: from SVN: svn checkout svn://rubyforge.org/var/svn/bio-graphics
== Prerequisites
You'll need to have the following installed to use this library:
-* bioruby (http://www.bioruby.org), to parse the feature locations. On linux systems, type "gem install bio".
-* cairo (http://cairographics.org), to do the actual drawing. On Ubuntu, type "sudo apt-get install libcairo-ruby".
+* bioruby (http://www.bioruby.org), to parse the feature locations.
+* cairo (http://cairographics.org), to do the actual drawing.
+* pango (http://www.pango.org), to do the high level text drawing.
+
+=== Ubuntu
+
+* gem install bio
+* sudo apt-get install libcairo-ruby
+
+=== Windows (thanks to Naohisa Goto)
+
+Install Ruby-GNOME2 Win32 GUI Installer, which contains rcairo-1.2.6. Get it from ruby-gnome2.sourceforge.jp/?News_20070212_1 (ruby-gnome2-0.16.0-1-i386-mswin32.exe)
+
+During installation, check the "Register enviroment variables" option.
+
+=== Mac OSX (thanks to Ed Allen)
+
+We haven't figured out yet how to install cairo and pango separately on a Mac. However, if you install Why The Lucky Stiff‘s Shoes GUI for Ruby toolkit, you get the pango and ruby-pango bindings for free. Get it from code.whytheluckystiff.net/shoes/wiki/DownloadShoes
View
2  trunk/bio-graphics.gemspec
@@ -2,7 +2,7 @@ require 'rubygems'
spec = Gem::Specification.new do |s|
s.name = 'bio-graphics'
- s.version = "1.2"
+ s.version = "1.3"
s.author = "Jan Aerts"
s.email = "jan.aerts@bbsrc.ac.uk"
View
28 trunk/doc/classes/Bio.html
@@ -55,22 +55,6 @@
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
- <a href="../files/lib/bio/graphics/feature_rb.html">
- lib/bio/graphics/feature.rb
- </a>
- <br />
- <a href="../files/lib/bio/graphics/track_rb.html">
- lib/bio/graphics/track.rb
- </a>
- <br />
- <a href="../files/lib/bio/graphics/ruler_rb.html">
- lib/bio/graphics/ruler.rb
- </a>
- <br />
- <a href="../files/lib/bio/graphics/panel_rb.html">
- lib/bio/graphics/panel.rb
- </a>
- <br />
</td>
</tr>
@@ -84,18 +68,6 @@
<div id="contextContent">
- <div id="description">
- <h1>bio/graphics/panel - panel class</h1>
-<table>
-<tr><td valign="top">Copyright:</td><td>Copyright (C) 2007 Jan Aerts &lt;jan.aerts@bbsrc.ac.uk&gt;
-
-</td></tr>
-<tr><td valign="top">License:</td><td>The Ruby License
-
-</td></tr>
-</table>
-
- </div>
</div>
View
152 trunk/doc/classes/Bio/Graphics.html
@@ -55,22 +55,6 @@
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
- <a href="../../files/lib/bio/graphics/feature_rb.html">
- lib/bio/graphics/feature.rb
- </a>
- <br />
- <a href="../../files/lib/bio/graphics/track_rb.html">
- lib/bio/graphics/track.rb
- </a>
- <br />
- <a href="../../files/lib/bio/graphics/ruler_rb.html">
- lib/bio/graphics/ruler.rb
- </a>
- <br />
- <a href="../../files/lib/bio/graphics/panel_rb.html">
- lib/bio/graphics/panel.rb
- </a>
- <br />
</td>
</tr>
@@ -84,82 +68,6 @@
<div id="contextContent">
- <div id="description">
- <h1>DESCRIPTION</h1>
-<p>
-The <a href="Graphics.html">Bio::Graphics</a> set of objects allow for
-creating simple images that display features on a linear map. A picture
-consists of:
-</p>
-<ul>
-<li>one <b>panel</b>: container of all tracks
-
-</li>
-<li>one or more <b>tracks</b>: container of the features. Multiple tracks can
-exist in the same graphic to allow for differential visualization of
-different feature types (e.g. genes as blue rectangles and polymorphisms as
-red triangles)
-
-</li>
-<li>one or more <b>features</b> in each track: these are the actual features
-that you want to display (e.g. &#8216;gene 1&#8217;, &#8216;SNP
-123445&#8217;)
-
-</li>
-<li>a <b>ruler</b> on top of the panel: is added automatically
-
-</li>
-</ul>
-<p>
-Schematically:
-</p>
-<pre>
- panel
- +-&gt; track 1
- | +-&gt; feature 1
- | +-&gt; feature 2
- | +-&gt; feature 3
- +-&gt; track 2
- | +-&gt; feature 4
- | +-&gt; feature 5
- +-&gt; ruler
-</pre>
-<h1>USAGE</h1>
-<pre>
- # Create a panel for something with a length of 653. This could be a
- # sequence of 653 bp, but also a genetic map of 653 cM.
- g = Bio::Graphics::Panel.new(653)
-
- # Add the first track (e.g. 'genes')
- track1 = g.add_track('genes')
-
- # And put features in that track
- track1.add_feature('gene1',250,375)
- track1.add_feature('gene2',54,124)
- track1.add_feature('gene3',100,500)
-
- # Add a second track (e.g. 'polymorphisms')
- track2 = g.add_track('polymorphisms',, false, 'red','triangle')
-
- # And put features on this one
- track2.add_feature('polymorphism 1',56,56)
- track2.add_feature('polymorphism 2',103,103)
-
- # Create the actual image as SVG text
- g.draw('my_picture.png')
-</pre>
-<h1>FUTURE PROSPECTS</h1>
-<p>
-Any help from other developers is welcomed to work on these features:
-</p>
-<ul>
-<li>Would be nice if this module would be easily accessible from any object
-that implements bioruby&#8216;s Bio::Map::ActsAsMap.
-
-</li>
-</ul>
-
- </div>
</div>
@@ -175,68 +83,10 @@
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
- Class <a href="Graphics/Panel.html" class="link">Bio::Graphics::Panel</a><br />
+ Module <a href="Graphics/Panel.html" class="link">Bio::Graphics::Panel</a><br />
</div>
- <div id="constants-list">
- <h3 class="section-bar">Constants</h3>
-
- <div class="name-list">
- <table summary="Constants">
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">DEFAULT_PANEL_WIDTH</td>
- <td>=</td>
- <td class="context-item-value">800</td>
- <td width="3em">&nbsp;</td>
- <td class="context-item-desc">
-The defaults
-
-</td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">TRACK_HEADER_HEIGHT</td>
- <td>=</td>
- <td class="context-item-value">12</td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">FEATURE_HEIGHT</td>
- <td>=</td>
- <td class="context-item-value">10</td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">FEATURE_V_DISTANCE</td>
- <td>=</td>
- <td class="context-item-value">5</td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">FEATURE_ARROW_LENGTH</td>
- <td>=</td>
- <td class="context-item-value">5</td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">RULER_TEXT_HEIGHT</td>
- <td>=</td>
- <td class="context-item-value">10</td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">RULER_MIN_DISTANCE_TICKS_PIXEL</td>
- <td>=</td>
- <td class="context-item-value">5</td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">FONT</td>
- <td>=</td>
- <td class="context-item-value">['Georgia', 1, 1]</td>
- <td width="3em">&nbsp;</td>
- <td class="context-item-desc">
-consecutive ticks. This is used for the calculation of tick distance.
-
-</td>
- </tr>
- </table>
- </div>
- </div>
View
246 trunk/doc/classes/Bio/Graphics/Panel.html
@@ -5,7 +5,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <title>Class: Bio::Graphics::Panel</title>
+ <title>Module: Bio::Graphics::Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
@@ -49,37 +49,15 @@
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
- <td><strong>Class</strong></td>
+ <td><strong>Module</strong></td>
<td class="class-name-in-header">Bio::Graphics::Panel</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
- <a href="../../../files/lib/bio/graphics/feature_rb.html">
- lib/bio/graphics/feature.rb
- </a>
- <br />
- <a href="../../../files/lib/bio/graphics/track_rb.html">
- lib/bio/graphics/track.rb
- </a>
- <br />
- <a href="../../../files/lib/bio/graphics/ruler_rb.html">
- lib/bio/graphics/ruler.rb
- </a>
- <br />
- <a href="../../../files/lib/bio/graphics/panel_rb.html">
- lib/bio/graphics/panel.rb
- </a>
- <br />
</td>
</tr>
- <tr class="top-aligned-row">
- <td><strong>Parent:</strong></td>
- <td>
- Object
- </td>
- </tr>
</table>
</div>
<!-- banner header -->
@@ -90,28 +68,10 @@
<div id="contextContent">
- <div id="description">
- <p>
-The <a href="Panel.html">Bio::Graphics::Panel</a> class describes the
-complete graph and contains all tracks. See <a
-href="../Graphics.html">Bio::Graphics</a> documentation for explanation of
-interplay between different classes.
-</p>
-
- </div>
</div>
- <div id="method-list">
- <h3 class="section-bar">Methods</h3>
-
- <div class="name-list">
- <a href="#M000006">add_track</a>&nbsp;&nbsp;
- <a href="#M000007">draw</a>&nbsp;&nbsp;
- <a href="#M000005">new</a>&nbsp;&nbsp;
- </div>
- </div>
</div>
@@ -123,217 +83,17 @@ <h3 class="section-bar">Methods</h3>
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
- Class <a href="Panel/Ruler.html" class="link">Bio::Graphics::Panel::Ruler</a><br />
-Class <a href="Panel/Track.html" class="link">Bio::Graphics::Panel::Track</a><br />
+ Module <a href="Panel/Track.html" class="link">Bio::Graphics::Panel::Track</a><br />
</div>
- <div id="attribute-list">
- <h3 class="section-bar">Attributes</h3>
-
- <div class="name-list">
- <table>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">clickable</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">display_start</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">display_stop</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">height</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">image_map</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">length</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">number_of_feature_rows</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">rescale_factor</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">tracks</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">width</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- </table>
- </div>
- </div>
<!-- if method_list -->
- <div id="methods">
- <h3 class="section-bar">Public Class methods</h3>
-
- <div id="method-M000005" class="method-detail">
- <a name="M000005"></a>
-
- <div class="method-heading">
- <a href="Panel.src/M000005.html" target="Code" class="method-signature"
- onclick="popupCode('Panel.src/M000005.html');return false;">
- <span class="method-name">new</span><span class="method-args">(length, width = DEFAULT_PANEL_WIDTH, clickable = false, display_start = nil, display_stop = nil)</span>
- </a>
- </div>
-
- <div class="method-description">
- <p>
-Create a <a href="Panel.html#M000005">new</a> <a
-href="Panel.html">Bio::Graphics::Panel</a> object
-</p>
-<pre>
- g = Bio::Graphics::Panel.new(456)
-</pre>
-<p>
-The height of the image is calculated automatically depending on how many
-tracks and features it contains. The width of the image defaults to 800 pt
-but can be set manually by using a second argument:
-</p>
-<pre>
- g = Bio::Graphics::Panel.new(456, 400)
-</pre>
-<p>
-See also: Bio::Graphics::Track, BioExt::Graphics::Feature
-</p>
-<hr size="1"></hr><p>
-<b>Arguments</b>:
-</p>
-<ul>
-<li><em>length</em> :: length of the thing you want to visualize, e.g for
-visualizing a sequence that is 3.24 kb long, use 324.
-
-</li>
-<li><em>width</em> :: width of the resulting image in pt. This should be a
-string and not an integer. Default = &#8216;800&#8217; (Notice the
-quotes&#8230;).
-
-</li>
-<li><em>clickable</em> :: whether the picture should have clickable glyphs or
-not (default: false) If set to true, a html file will be created with the
-map.
-
-</li>
-<li><em>display_start</em> :: start coordinate to be displayed (default: 1)
-
-</li>
-<li><em>display_stop</em> :: stop coordinate to be displayed (default: length
-of sequence)
-
-</li>
-</ul>
-<table>
-<tr><td valign="top"><b>Returns</b>:</td><td><a href="Panel.html">Bio::Graphics::Panel</a> object
-
-</td></tr>
-</table>
- </div>
- </div>
-
- <h3 class="section-bar">Public Instance methods</h3>
-
- <div id="method-M000006" class="method-detail">
- <a name="M000006"></a>
-
- <div class="method-heading">
- <a href="Panel.src/M000006.html" target="Code" class="method-signature"
- onclick="popupCode('Panel.src/M000006.html');return false;">
- <span class="method-name">add_track</span><span class="method-args">(name, label = true, feature_colour = [0,0,1], feature_glyph = 'generic')</span>
- </a>
- </div>
-
- <div class="method-description">
- <p>
-Adds a Bio::Graphics::Track container to this panel. A panel contains a
-logical grouping of features, e.g. (for sequence annotation:) genes,
-polymorphisms, ESTs, etc.
-</p>
-<pre>
- est_track = g.add_track('ESTs')
- gene_track = g.add_track('genes')
-</pre>
-<hr size="1"></hr><p>
-<b>Arguments</b>:
-</p>
-<ul>
-<li><em>name</em> (required) :: Name of the track to be displayed (e.g.
-&#8216;genes&#8217;)
-
-</li>
-<li>_label) :: Whether the feature labels should be displayed or not
-
-</li>
-<li><em>colour</em> :: Colour to be used to <a
-href="Panel.html#M000007">draw</a> the features within the track. Default =
-&#8216;blue&#8216;
-
-</li>
-<li><em>glyph</em> :: Glyph to use for drawing the features. Options are:
-&#8216;generic&#8217;, &#8216;directed_generic&#8217;,
-&#8216;spliced&#8217;, &#8216;directed_spliced&#8217; and
-&#8216;triangle&#8217;. Triangles can be used for features whose start and
-stop positions are the same (e.g. SNPs). If you try to <a
-href="Panel.html#M000007">draw</a> a feature that is longer with triangles,
-an error will be shown.
-
-</li>
-</ul>
-<table>
-<tr><td valign="top"><b>Returns</b>:</td><td>Bio::Graphics::Track object that has just been created
-
-</td></tr>
-</table>
- </div>
- </div>
-
- <div id="method-M000007" class="method-detail">
- <a name="M000007"></a>
-
- <div class="method-heading">
- <a href="Panel.src/M000007.html" target="Code" class="method-signature"
- onclick="popupCode('Panel.src/M000007.html');return false;">
- <span class="method-name">draw</span><span class="method-args">(file_name)</span>
- </a>
- </div>
-
- <div class="method-description">
- <p>
-Create the drawing
-</p>
- </div>
- </div>
-
-
- </div>
</div>
View
21 trunk/doc/classes/Bio/Graphics/Panel.src/M000006.html
@@ -5,15 +5,26 @@
<html>
<head>
- <title>add_track (Bio::Graphics::Panel)</title>
+ <title>new (Bio::Graphics::Panel)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/panel.rb, line 139</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_track</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">label</span> = <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">feature_colour</span> = [<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">1</span>], <span class="ruby-identifier">feature_glyph</span> = <span class="ruby-value str">'generic'</span>)
- <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">push</span>(<span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">Graphics</span><span class="ruby-operator">::</span><span class="ruby-constant">Panel</span><span class="ruby-operator">::</span><span class="ruby-constant">Track</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">label</span>, <span class="ruby-identifier">feature_colour</span>, <span class="ruby-identifier">feature_glyph</span>))
- <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@tracks</span>[<span class="ruby-value">-1</span>]
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/panel.rb, line 106</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">length</span>, <span class="ruby-identifier">width</span> = <span class="ruby-constant">DEFAULT_PANEL_WIDTH</span>, <span class="ruby-identifier">clickable</span> = <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">display_start</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">display_stop</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">verticle</span> = <span class="ruby-keyword kw">false</span>)
+ <span class="ruby-ivar">@length</span> = <span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_i</span>
+ <span class="ruby-ivar">@width</span> = <span class="ruby-identifier">width</span>.<span class="ruby-identifier">to_i</span>
+ <span class="ruby-ivar">@verticle</span> = <span class="ruby-identifier">verticle</span>
+ <span class="ruby-ivar">@tracks</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
+ <span class="ruby-ivar">@number_of_feature_rows</span> = <span class="ruby-value">0</span>
+ <span class="ruby-ivar">@clickable</span> = <span class="ruby-identifier">clickable</span>
+ <span class="ruby-ivar">@image_map</span> = ( <span class="ruby-identifier">clickable</span> ) <span class="ruby-operator">?</span> <span class="ruby-constant">ImageMap</span>.<span class="ruby-identifier">new</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
+ <span class="ruby-ivar">@display_start</span> = ( <span class="ruby-identifier">display_start</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">display_start</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> ) <span class="ruby-operator">?</span> <span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">display_start</span>
+ <span class="ruby-ivar">@display_stop</span> = ( <span class="ruby-identifier">display_stop</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">display_stop</span> <span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@length</span> ) <span class="ruby-operator">?</span> <span class="ruby-ivar">@length</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">display_stop</span>
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@display_stop</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-ivar">@display_start</span>
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;[ERROR] Start coordinate to be displayed has to be smaller than stop coordinate.&quot;</span>
+ <span class="ruby-keyword kw">end</span>
+ <span class="ruby-ivar">@rescale_factor</span> = (<span class="ruby-ivar">@display_stop</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@display_start</span>).<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@width</span>
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>
View
59 trunk/doc/classes/Bio/Graphics/Panel.src/M000007.html
@@ -5,64 +5,15 @@
<html>
<head>
- <title>draw (Bio::Graphics::Panel)</title>
+ <title>add_track (Bio::Graphics::Panel)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/panel.rb, line 151</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">draw</span>(<span class="ruby-identifier">file_name</span>)
- <span class="ruby-comment cmt"># Create a panel that is huge vertically
-</span>
- <span class="ruby-identifier">huge_height</span> = <span class="ruby-value">2000</span>
-
- <span class="ruby-identifier">huge_panel_drawing</span> = <span class="ruby-keyword kw">nil</span>
- <span class="ruby-identifier">huge_panel_drawing</span> = <span class="ruby-constant">Cairo</span><span class="ruby-operator">::</span><span class="ruby-constant">ImageSurface</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1</span>, <span class="ruby-ivar">@width</span>, <span class="ruby-identifier">huge_height</span>)
-
- <span class="ruby-identifier">background</span> = <span class="ruby-constant">Cairo</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">huge_panel_drawing</span>)
- <span class="ruby-identifier">background</span>.<span class="ruby-identifier">set_source_rgb</span>(<span class="ruby-value">1</span>,<span class="ruby-value">1</span>,<span class="ruby-value">1</span>)
- <span class="ruby-identifier">background</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-ivar">@width</span>,<span class="ruby-identifier">huge_height</span>).<span class="ruby-identifier">fill</span>
-
- <span class="ruby-comment cmt"># Add ruler
-</span>
- <span class="ruby-identifier">vertical_offset</span> = <span class="ruby-value">0</span>
- <span class="ruby-identifier">ruler</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">Graphics</span><span class="ruby-operator">::</span><span class="ruby-constant">Panel</span><span class="ruby-operator">::</span><span class="ruby-constant">Ruler</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
- <span class="ruby-identifier">ruler</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">huge_panel_drawing</span>, <span class="ruby-identifier">vertical_offset</span>)
- <span class="ruby-identifier">vertical_offset</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">ruler</span>.<span class="ruby-identifier">height</span>
-
- <span class="ruby-comment cmt"># Add tracks
-</span>
- <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">track</span><span class="ruby-operator">|</span>
- <span class="ruby-identifier">track</span>.<span class="ruby-identifier">vertical_offset</span> = <span class="ruby-identifier">vertical_offset</span>
- <span class="ruby-identifier">track</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">huge_panel_drawing</span>)
- <span class="ruby-ivar">@number_of_feature_rows</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">number_of_feature_rows</span>
- <span class="ruby-identifier">vertical_offset</span> <span class="ruby-operator">+=</span> ( <span class="ruby-identifier">track</span>.<span class="ruby-identifier">number_of_feature_rows</span><span class="ruby-operator">*</span>(<span class="ruby-constant">FEATURE_HEIGHT</span><span class="ruby-operator">+</span><span class="ruby-constant">FEATURE_V_DISTANCE</span><span class="ruby-operator">+</span><span class="ruby-value">5</span>)) <span class="ruby-operator">+</span> <span class="ruby-value">10</span> <span class="ruby-comment cmt"># '10' is for the header
-</span>
- <span class="ruby-keyword kw">end</span>
-
- <span class="ruby-comment cmt"># And create a smaller version of the panel
-</span>
- <span class="ruby-identifier">height</span> = <span class="ruby-identifier">ruler</span>.<span class="ruby-identifier">height</span>
- <span class="ruby-ivar">@number_of_feature_rows</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span>
- <span class="ruby-identifier">height</span> <span class="ruby-operator">+=</span> <span class="ruby-value">20</span>
- <span class="ruby-keyword kw">end</span>
- <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt">#To correct for the track headers
-</span>
- <span class="ruby-identifier">height</span> <span class="ruby-operator">+=</span> <span class="ruby-value">10</span>
- <span class="ruby-keyword kw">end</span>
-
- <span class="ruby-identifier">resized_panel_drawing</span> = <span class="ruby-keyword kw">nil</span>
- <span class="ruby-identifier">resized_panel_drawing</span> = <span class="ruby-constant">Cairo</span><span class="ruby-operator">::</span><span class="ruby-constant">ImageSurface</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1</span>, <span class="ruby-ivar">@width</span>, <span class="ruby-identifier">height</span>)
- <span class="ruby-identifier">resizing_context</span> = <span class="ruby-constant">Cairo</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resized_panel_drawing</span>)
- <span class="ruby-identifier">resizing_context</span>.<span class="ruby-identifier">set_source</span>(<span class="ruby-identifier">huge_panel_drawing</span>, <span class="ruby-value">0</span>,<span class="ruby-value">0</span>)
- <span class="ruby-identifier">resizing_context</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-ivar">@width</span>, <span class="ruby-identifier">height</span>).<span class="ruby-identifier">fill</span>
-
- <span class="ruby-comment cmt"># And print to file
-</span>
- <span class="ruby-identifier">resized_panel_drawing</span>.<span class="ruby-identifier">write_to_png</span>(<span class="ruby-identifier">file_name</span>)
- <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@clickable</span> <span class="ruby-comment cmt"># create png and map
-</span>
- <span class="ruby-identifier">html_filename</span> = <span class="ruby-identifier">file_name</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp re">/\.[^.]+$/</span>, <span class="ruby-value str">'.html'</span>)
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/panel.rb, line 143</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_track</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">label</span> = <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">feature_colour</span> = [<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">1</span>], <span class="ruby-identifier">feature_glyph</span> = <span class="ruby-value str">'generic'</span>)
+ <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">push</span>(<span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">Graphics</span><span class="ruby-operator">::</span><span class="ruby-constant">Panel</span><span class="ruby-operator">::</span><span class="ruby-constant">Track</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">label</span>, <span class="ruby-identifier">feature_colour</span>, <span class="ruby-identifier">feature_glyph</span>))
+ <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@tracks</span>[<span class="ruby-value">-1</span>]
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>
View
36 trunk/doc/classes/Bio/Graphics/Panel/Ruler.html
@@ -95,9 +95,9 @@
<h3 class="section-bar">Methods</h3>
<div class="name-list">
- <a href="#M000009">calculate_tick_distance</a>&nbsp;&nbsp;
- <a href="#M000010">draw</a>&nbsp;&nbsp;
- <a href="#M000008">new</a>&nbsp;&nbsp;
+ <a href="#M000012">calculate_tick_distance</a>&nbsp;&nbsp;
+ <a href="#M000013">draw</a>&nbsp;&nbsp;
+ <a href="#M000011">new</a>&nbsp;&nbsp;
</div>
</div>
@@ -157,20 +157,20 @@ <h3 class="section-bar">Attributes</h3>
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
- <div id="method-M000008" class="method-detail">
- <a name="M000008"></a>
+ <div id="method-M000011" class="method-detail">
+ <a name="M000011"></a>
<div class="method-heading">
- <a href="Ruler.src/M000008.html" target="Code" class="method-signature"
- onclick="popupCode('Ruler.src/M000008.html');return false;">
+ <a href="Ruler.src/M000011.html" target="Code" class="method-signature"
+ onclick="popupCode('Ruler.src/M000011.html');return false;">
<span class="method-name">new</span><span class="method-args">(panel, colour = [0,0,0])</span>
</a>
</div>
<div class="method-description">
<p>
-Creates a <a href="Ruler.html#M000008">new</a> <a
-href="Ruler.html">Bio::Graphics::Panel::Ruler</a> object.
+Creates a <a href="Ruler.html#M000011">new</a> Bio::Graphics::Panel::Ruler
+object.
</p>
<hr size="1"></hr><p>
<b>Arguments</b>:
@@ -195,12 +195,12 @@ <h3 class="section-bar">Public Class methods</h3>
<h3 class="section-bar">Public Instance methods</h3>
- <div id="method-M000009" class="method-detail">
- <a name="M000009"></a>
+ <div id="method-M000012" class="method-detail">
+ <a name="M000012"></a>
<div class="method-heading">
- <a href="Ruler.src/M000009.html" target="Code" class="method-signature"
- onclick="popupCode('Ruler.src/M000009.html');return false;">
+ <a href="Ruler.src/M000012.html" target="Code" class="method-signature"
+ onclick="popupCode('Ruler.src/M000012.html');return false;">
<span class="method-name">calculate_tick_distance</span><span class="method-args">()</span>
</a>
</div>
@@ -209,13 +209,13 @@ <h3 class="section-bar">Public Instance methods</h3>
</div>
</div>
- <div id="method-M000010" class="method-detail">
- <a name="M000010"></a>
+ <div id="method-M000013" class="method-detail">
+ <a name="M000013"></a>
<div class="method-heading">
- <a href="Ruler.src/M000010.html" target="Code" class="method-signature"
- onclick="popupCode('Ruler.src/M000010.html');return false;">
- <span class="method-name">draw</span><span class="method-args">(panel_drawing, vertical_offset)</span>
+ <a href="Ruler.src/M000013.html" target="Code" class="method-signature"
+ onclick="popupCode('Ruler.src/M000013.html');return false;">
+ <span class="method-name">draw</span><span class="method-args">(panel_drawing)</span>
</a>
</div>
View
20 trunk/doc/classes/Bio/Graphics/Panel/Ruler.src/M000009.html
@@ -5,24 +5,16 @@
<html>
<head>
- <title>calculate_tick_distance (Bio::Graphics::Panel::Ruler)</title>
+ <title>new (Bio::Graphics::Panel::Ruler)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/ruler.rb, line 35</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">calculate_tick_distance</span>
- <span class="ruby-identifier">min_tick_distance_requirement_met</span> = <span class="ruby-keyword kw">false</span>
- <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minor_tick_distance</span> = <span class="ruby-value">1</span> <span class="ruby-comment cmt"># in basepairs.
-</span>
- <span class="ruby-keyword kw">while</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">min_tick_distance_requirement_met</span>
- <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minor_tick_distance</span><span class="ruby-operator">/</span><span class="ruby-identifier">panel</span>.<span class="ruby-identifier">rescale_factor</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-constant">RULER_MIN_DISTANCE_TICKS_PIXEL</span>
- <span class="ruby-identifier">min_tick_distance_requirement_met</span> = <span class="ruby-keyword kw">true</span>
- <span class="ruby-keyword kw">else</span>
- <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minor_tick_distance</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minor_tick_distance</span><span class="ruby-operator">*</span><span class="ruby-value">5</span>
- <span class="ruby-keyword kw">end</span>
- <span class="ruby-keyword kw">end</span>
-
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/ruler.rb, line 28</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">panel</span>, <span class="ruby-identifier">colour</span> = [<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">0</span>])
+ <span class="ruby-ivar">@panel</span> = <span class="ruby-identifier">panel</span>
+ <span class="ruby-ivar">@name</span> = <span class="ruby-value str">'ruler'</span>
+ <span class="ruby-ivar">@colour</span> = <span class="ruby-identifier">colour</span>
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>
View
51 trunk/doc/classes/Bio/Graphics/Panel/Ruler.src/M000010.html
@@ -5,55 +5,24 @@
<html>
<head>
- <title>draw (Bio::Graphics::Panel::Ruler)</title>
+ <title>calculate_tick_distance (Bio::Graphics::Panel::Ruler)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/ruler.rb, line 49</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">draw</span>(<span class="ruby-identifier">panel_drawing</span>, <span class="ruby-identifier">vertical_offset</span>)
- <span class="ruby-identifier">ruler_drawing</span> = <span class="ruby-constant">Cairo</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">panel_drawing</span>)
-
- <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">calculate_tick_distance</span>
-
- <span class="ruby-comment cmt"># Draw line
-</span>
- <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-value">0</span>,<span class="ruby-value">10</span>)
- <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">width</span>, <span class="ruby-value">10</span>)
- <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">stroke</span>
-
- <span class="ruby-comment cmt"># Draw ticks
-</span>
- <span class="ruby-comment cmt"># * Find position of first tick.
-</span>
- <span class="ruby-comment cmt"># Most of the time, we don't want the first tick on the very first
-</span>
- <span class="ruby-comment cmt"># basepair of the view. Suppose that would be position 333 in the
-</span>
- <span class="ruby-comment cmt"># sequence. Then the numbers under the major tickmarks would be:
-</span>
- <span class="ruby-comment cmt"># 343, 353, 363, 373 and so on. Instead, we want 350, 360, 370, 380.
-</span>
- <span class="ruby-comment cmt"># So we want to find the position of the first tick.
-</span>
- <span class="ruby-identifier">first_tick_position</span> = <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_start</span>
- <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">first_tick_position</span>.<span class="ruby-identifier">modulo</span>(<span class="ruby-identifier">minor_tick_distance</span>) <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
- <span class="ruby-identifier">first_tick_position</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
- <span class="ruby-keyword kw">end</span>
-
- <span class="ruby-comment cmt"># * And start drawing the rest.
-</span>
- <span class="ruby-identifier">first_tick_position</span>.<span class="ruby-identifier">step</span>(<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_stop</span>, <span class="ruby-identifier">minor_tick_distance</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">tick</span><span class="ruby-operator">|</span>
- <span class="ruby-identifier">tick_pixel_position</span> = (<span class="ruby-identifier">tick</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_start</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">rescale_factor</span>
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/ruler.rb, line 35</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">calculate_tick_distance</span>
+ <span class="ruby-identifier">min_tick_distance_requirement_met</span> = <span class="ruby-keyword kw">false</span>
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minor_tick_distance</span> = <span class="ruby-value">1</span> <span class="ruby-comment cmt"># in basepairs.
+</span>
+ <span class="ruby-keyword kw">while</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">min_tick_distance_requirement_met</span>
+ <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minor_tick_distance</span><span class="ruby-operator">/</span><span class="ruby-identifier">panel</span>.<span class="ruby-identifier">rescale_factor</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-constant">RULER_MIN_DISTANCE_TICKS_PIXEL</span>
<span class="ruby-identifier">min_tick_distance_requirement_met</span> = <span class="ruby-keyword kw">true</span>
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tick</span>.<span class="ruby-identifier">modulo</span>(<span class="ruby-identifier">major_tick_distance</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
- <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-value">0</span>, <span class="ruby-value">15</span>)
+ <span class="ruby-keyword kw">else</span>
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minor_tick_distance</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minor_tick_distance</span><span class="ruby-operator">*</span><span class="ruby-value">5</span>
- <span class="ruby-comment cmt"># Draw tick number
<span class="ruby-keyword kw">end</span>
- <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">select_font_face</span>(<span class="ruby-operator">*</span>(<span class="ruby-constant">FONT</span>))
<span class="ruby-keyword kw">end</span>
- <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">tick_pixel_position</span>.<span class="ruby-identifier">floor</span>, <span class="ruby-value">20</span> <span class="ruby-operator">+</span> <span class="ruby-constant">RULER_TEXT_HEIGHT</span>)
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">major_tick_distance</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minor_tick_distance</span> <span class="ruby-operator">*</span> <span class="ruby-value">10</span>
<span class="ruby-keyword kw">end</span></pre>
</body>
View
51 trunk/doc/classes/Bio/Graphics/Panel/Ruler.src/M000013.html
@@ -5,16 +5,55 @@
<html>
<head>
- <title>new (Bio::Graphics::Panel::Ruler)</title>
+ <title>draw (Bio::Graphics::Panel::Ruler)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/ruler.rb, line 28</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">panel</span>, <span class="ruby-identifier">colour</span> = [<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">0</span>])
- <span class="ruby-ivar">@panel</span> = <span class="ruby-identifier">panel</span>
- <span class="ruby-ivar">@name</span> = <span class="ruby-value str">'ruler'</span>
- <span class="ruby-ivar">@colour</span> = <span class="ruby-identifier">colour</span>
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/ruler.rb, line 49</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">draw</span>(<span class="ruby-identifier">panel_drawing</span>)
+ <span class="ruby-identifier">ruler_drawing</span> = <span class="ruby-constant">Cairo</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">panel_drawing</span>)
+
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">calculate_tick_distance</span>
+
+ <span class="ruby-comment cmt"># Draw line
+</span>
+ <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-value">0</span>,<span class="ruby-value">10</span>)
+ <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">width</span>, <span class="ruby-value">10</span>)
+ <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">stroke</span>
+
+ <span class="ruby-comment cmt"># Draw ticks
+</span>
+ <span class="ruby-comment cmt"># * Find position of first tick.
+</span>
+ <span class="ruby-comment cmt"># Most of the time, we don't want the first tick on the very first
+</span>
+ <span class="ruby-comment cmt"># basepair of the view. Suppose that would be position 333 in the
+</span>
+ <span class="ruby-comment cmt"># sequence. Then the numbers under the major tickmarks would be:
+</span>
+ <span class="ruby-comment cmt"># 343, 353, 363, 373 and so on. Instead, we want 350, 360, 370, 380.
+</span>
+ <span class="ruby-comment cmt"># So we want to find the position of the first tick.
+</span>
+ <span class="ruby-identifier">first_tick_position</span> = <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_start</span>
+ <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">first_tick_position</span>.<span class="ruby-identifier">modulo</span>(<span class="ruby-identifier">minor_tick_distance</span>) <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
+ <span class="ruby-identifier">first_tick_position</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
+ <span class="ruby-keyword kw">end</span>
+
+ <span class="ruby-comment cmt"># * And start drawing the rest.
+</span>
+ <span class="ruby-identifier">first_tick_position</span>.<span class="ruby-identifier">step</span>(<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_stop</span>, <span class="ruby-identifier">minor_tick_distance</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">tick</span><span class="ruby-operator">|</span>
+ <span class="ruby-identifier">tick_pixel_position</span> = (<span class="ruby-identifier">tick</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_start</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">rescale_factor</span>
+ <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">tick_pixel_position</span>.<span class="ruby-identifier">floor</span>, <span class="ruby-value">5</span>)
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tick</span>.<span class="ruby-identifier">modulo</span>(<span class="ruby-identifier">major_tick_distance</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
+ <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-value">0</span>, <span class="ruby-value">15</span>)
+
+ <span class="ruby-comment cmt"># Draw tick number
+</span>
+ <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">select_font_face</span>(<span class="ruby-operator">*</span>(<span class="ruby-constant">FONT</span>))
+ <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">set_font_size</span>(<span class="ruby-constant">RULER_TEXT_HEIGHT</span>)
+ <span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">tick_pixel_position</span>.<span class="ruby-identifier">floor</span>, <span class="ruby-value">20</span> <span class="ruby-operator">+</span> <span class="ruby-constant">RULER_TEXT_HEIGHT</span>)
<span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">show_text</span>(<span class="ruby-identifier">tick</span>.<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">to_s</span>)
<span class="ruby-keyword kw">else</span>
<span class="ruby-identifier">ruler_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-value">0</span>, <span class="ruby-value">5</span>)
View
256 trunk/doc/classes/Bio/Graphics/Panel/Track.html
@@ -5,7 +5,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <title>Class: Bio::Graphics::Panel::Track</title>
+ <title>Module: Bio::Graphics::Panel::Track</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
@@ -49,29 +49,15 @@
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
- <td><strong>Class</strong></td>
+ <td><strong>Module</strong></td>
<td class="class-name-in-header">Bio::Graphics::Panel::Track</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
- <a href="../../../../files/lib/bio/graphics/feature_rb.html">
- lib/bio/graphics/feature.rb
- </a>
- <br />
- <a href="../../../../files/lib/bio/graphics/track_rb.html">
- lib/bio/graphics/track.rb
- </a>
- <br />
</td>
</tr>
- <tr class="top-aligned-row">
- <td><strong>Parent:</strong></td>
- <td>
- Object
- </td>
- </tr>
</table>
</div>
<!-- banner header -->
@@ -82,27 +68,10 @@
<div id="contextContent">
- <div id="description">
- <p>
-The Bio::Graphics::Track class describes the container for features of the
-same type. See <a href="../../Graphics.html">Bio::Graphics</a>
-documentation for explanation of interplay between different classes.
-</p>
-
- </div>
</div>
- <div id="method-list">
- <h3 class="section-bar">Methods</h3>
-
- <div class="name-list">
- <a href="#M000012">add_feature</a>&nbsp;&nbsp;
- <a href="#M000013">draw</a>&nbsp;&nbsp;
- <a href="#M000011">new</a>&nbsp;&nbsp;
- </div>
- </div>
</div>
@@ -114,236 +83,17 @@ <h3 class="section-bar">Methods</h3>
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
- Class <a href="Track/Feature.html" class="link">Bio::Graphics::Panel::Track::Feature</a><br />
+ Module <a href="Track/Feature.html" class="link">Bio::Graphics::Panel::Track::Feature</a><br />
</div>
- <div id="attribute-list">
- <h3 class="section-bar">Attributes</h3>
-
- <div class="name-list">
- <table>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">colour</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">features</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">glyph</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">grid</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">height</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">name</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">number_of_feature_rows</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">panel</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">show_label</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- <tr class="top-aligned-row context-row">
- <td class="context-item-name">vertical_offset</td>
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
- <td class="context-item-desc"></td>
- </tr>
- </table>
- </div>
- </div>
<!-- if method_list -->
- <div id="methods">
- <h3 class="section-bar">Public Class methods</h3>
-
- <div id="method-M000011" class="method-detail">
- <a name="M000011"></a>
-
- <div class="method-heading">
- <a href="Track.src/M000011.html" target="Code" class="method-signature"
- onclick="popupCode('Track.src/M000011.html');return false;">
- <span class="method-name">new</span><span class="method-args">(panel, name, label = true, colour = [0,0,1], glyph = :generic)</span>
- </a>
- </div>
-
- <div class="method-description">
- <p>
-!!Not to be used directly. Use <a
-href="../Panel.html#M000006">Bio::Graphics::Panel.add_track</a> instead!! A
-track can not exist except within the confines of a <a
-href="../Panel.html">Bio::Graphics::Panel</a> object.
-</p>
-<hr size="1"></hr><p>
-<b>Arguments</b>:
-</p>
-<ul>
-<li><em>panel</em> (required) :: <a
-href="../Panel.html">Bio::Graphics::Panel</a> object that this track
-belongs to
-
-</li>
-<li><em>name</em> (required) :: Name of the track to be displayed (e.g.
-&#8216;genes&#8217;)
-
-</li>
-<li><em>label</em> :: Boolean: should the label for each feature be drawn or
-not
-
-</li>
-<li><em>colour</em> :: Colour to be used to <a
-href="Track.html#M000013">draw</a> the features within the track. Default =
-&#8216;blue&#8216;
-
-</li>
-<li><em>glyph</em> :: Glyph to use for drawing the features. Options are:
-:generic, :directed_generic, :spliced, :directed_spliced, :line and
-:triangle. Triangles can be used for features whose start and stop
-positions are the same (e.g. SNPs). If you try to <a
-href="Track.html#M000013">draw</a> a feature that is longer with triangles,
-an error will be shown.
-
-</li>
-</ul>
-<table>
-<tr><td valign="top"><b>Returns</b>:</td><td>Bio::Graphics::Track object
-
-</td></tr>
-</table>
- </div>
- </div>
-
- <h3 class="section-bar">Public Instance methods</h3>
-
- <div id="method-M000012" class="method-detail">
- <a name="M000012"></a>
-
- <div class="method-heading">
- <a href="Track.src/M000012.html" target="Code" class="method-signature"
- onclick="popupCode('Track.src/M000012.html');return false;">
- <span class="method-name">add_feature</span><span class="method-args">(name, location_string = '1..' + @panel.length.to_s, link = nil)</span>
- </a>
- </div>
-
- <div class="method-description">
- <p>
-Adds a <a
-href="Track/Feature.html">Bio::Graphics::Panel::Track::Feature</a> to this
-track. A track contains features of the same type, e.g. (for sequence
-annotation:) genes, polymorphisms, ESTs, etc.
-</p>
-<pre>
- est_track.add_feature('EST1','50..60')
- est_track.add_feature('EST2','52..73')
- est_track.add_feature('EST3','41..69')
- gene_track.add_feature('gene2','39..73')
-</pre>
-<p>
-For spliced features:
-</p>
-<pre>
- est_track.add_feature('EST4','join(34..53,153..191)')
-</pre>
-<p>
-Or on the complement strand:
-</p>
-<pre>
- est_track.add_feature('EST5','complement(join(34..53,153..191))')
-</pre>
-<p>
-See the documentation in Bio::Locations for a full description of how
-locations can be defined.
-</p>
-<p>
-Features are only added if they are at least partly in the displayed
-region. If a feature is completely outside of the region, it&#8216;s not
-added. If it should be only partly visible, it is added completely.
-</p>
-<hr size="1"></hr><p>
-<b>Arguments</b>:
-</p>
-<ul>
-<li><em>name</em> (required) :: Name of the feature
-
-</li>
-<li><em>location</em> :: String. Default: whole of panel, forward strand.
-
-</li>
-<li><em>link</em> :: URL to link to for this glyph
-
-</li>
-</ul>
-<table>
-<tr><td valign="top"><b>Returns</b>:</td><td>Bio::Graphics::Track::Feature object that was created or nil
-
-</td></tr>
-</table>
- </div>
- </div>
-
- <div id="method-M000013" class="method-detail">
- <a name="M000013"></a>
-
- <div class="method-heading">
- <a href="Track.src/M000013.html" target="Code" class="method-signature"
- onclick="popupCode('Track.src/M000013.html');return false;">
- <span class="method-name">draw</span><span class="method-args">(panel_drawing)</span>
- </a>
- </div>
-
- <div class="method-description">
- <p>
-Adds the track to a cairo drawing. This method should not be used directly
-by the user, but is called by <a
-href="../Panel.html#M000007">Bio::Graphics::Panel.draw</a>
-</p>
-<hr size="1"></hr><p>
-<b>Arguments</b>:
-</p>
-<ul>
-<li><em>paneldrawing</em> (required) :: the panel cairo object
-
-</li>
-</ul>
-<table>
-<tr><td valign="top"><b>Returns</b>:</td><td>FIXME: I don&#8216;t know
-
-</td></tr>
-</table>
- </div>
- </div>
-
-
- </div>
</div>
View
24 trunk/doc/classes/Bio/Graphics/Panel/Track.src/M000008.html
@@ -10,17 +10,17 @@
<link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 39</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">panel</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">label</span> = <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">colour</span> = [<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">1</span>], <span class="ruby-identifier">glyph</span> = <span class="ruby-identifier">:generic</span>)
- <span class="ruby-ivar">@panel</span> = <span class="ruby-identifier">panel</span>
- <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
- <span class="ruby-ivar">@show_label</span> = <span class="ruby-identifier">label</span>
- <span class="ruby-ivar">@colour</span> = <span class="ruby-identifier">colour</span>
- <span class="ruby-ivar">@glyph</span> = <span class="ruby-identifier">glyph</span>
- <span class="ruby-ivar">@features</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
- <span class="ruby-ivar">@number_of_feature_rows</span> = <span class="ruby-value">0</span>
- <span class="ruby-ivar">@vertical_offset</span> = <span class="ruby-value">0</span>
- <span class="ruby-ivar">@grid</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
- <span class="ruby-keyword kw">end</span></pre>
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 35</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">panel</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">label</span> = <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">colour</span> = [<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">1</span>], <span class="ruby-identifier">glyph</span> = <span class="ruby-identifier">:generic</span>)
+ <span class="ruby-ivar">@panel</span> = <span class="ruby-identifier">panel</span>
+ <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
+ <span class="ruby-ivar">@show_label</span> = <span class="ruby-identifier">label</span>
+ <span class="ruby-ivar">@colour</span> = <span class="ruby-identifier">colour</span>
+ <span class="ruby-ivar">@glyph</span> = <span class="ruby-identifier">glyph</span>
+ <span class="ruby-ivar">@features</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
+ <span class="ruby-ivar">@number_of_feature_rows</span> = <span class="ruby-value">0</span>
+ <span class="ruby-ivar">@vertical_offset</span> = <span class="ruby-value">0</span>
+ <span class="ruby-ivar">@grid</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
+ <span class="ruby-keyword kw">end</span></pre>
</body>
</html>
View
53 trunk/doc/classes/Bio/Graphics/Panel/Track.src/M000009.html
@@ -10,33 +10,32 @@
<link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 80</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_feature</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">location_string</span> = <span class="ruby-value str">'1..'</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@panel</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">link</span> = <span class="ruby-keyword kw">nil</span>)
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">link</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
- <span class="ruby-identifier">link</span> = <span class="ruby-keyword kw">nil</span>
- <span class="ruby-keyword kw">end</span>
-
- <span class="ruby-comment cmt"># Calculate the ultimate start and stop of the feature: the start
-</span>
- <span class="ruby-comment cmt"># of the first subfeature (e.g. exon) and the stop of the last one.
-</span>
- <span class="ruby-comment cmt"># The only reason we want to know these positions, is because we want
-</span>
- <span class="ruby-comment cmt"># to determine if the feature falls within the view of the image or
-</span>
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 78</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_feature</span>(<span class="ruby-identifier">feature_object</span>, <span class="ruby-identifier">label</span> = <span class="ruby-value str">'anonymous'</span>, <span class="ruby-identifier">link</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">glyph</span> = <span class="ruby-ivar">@glyph</span>, <span class="ruby-identifier">colour</span> = <span class="ruby-ivar">@colour</span>)
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">link</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
+ <span class="ruby-identifier">link</span> = <span class="ruby-keyword kw">nil</span>
+ <span class="ruby-keyword kw">end</span>
-</span>
- <span class="ruby-identifier">location_object</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">Locations</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">location_string</span>)
- <span class="ruby-identifier">start</span> = <span class="ruby-identifier">location_object</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">from</span>}.<span class="ruby-identifier">min</span>.<span class="ruby-identifier">to_i</span>
- <span class="ruby-identifier">stop</span> = <span class="ruby-identifier">location_object</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">to</span>}.<span class="ruby-identifier">max</span>.<span class="ruby-identifier">to_i</span>
-
- <span class="ruby-comment cmt"># If the feature wouldn't show because it's not in the region we're
-</span>
- <span class="ruby-comment cmt"># looking at, don't bother storing the stuff. I think this makes huge
-</span>
- <span class="ruby-comment cmt"># speed and memory differences if you've got a chromosome with
-</span>
- <span class="ruby-comment cmt"># thousands of features.
-</span>
+ <span class="ruby-comment cmt"># Calculate the ultimate start and stop of the feature: the start
+</span>
+ <span class="ruby-comment cmt"># of the first subfeature (e.g. exon) and the stop of the last one.
+</span>
+ <span class="ruby-comment cmt"># The only reason we want to know these positions, is because we want
+</span>
+ <span class="ruby-comment cmt"># to determine if the feature falls within the view of the image or
+</span>
+ <span class="ruby-comment cmt"># not (see below).
+</span>
+ <span class="ruby-identifier">start</span> = <span class="ruby-identifier">feature_object</span>.<span class="ruby-identifier">locations</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">from</span>}.<span class="ruby-identifier">min</span>.<span class="ruby-identifier">to_i</span>
+ <span class="ruby-identifier">stop</span> = <span class="ruby-identifier">feature_object</span>.<span class="ruby-identifier">locations</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">to</span>}.<span class="ruby-identifier">max</span>.<span class="ruby-identifier">to_i</span>
+
+ <span class="ruby-comment cmt"># If the feature wouldn't show because it's not in the region we're
+</span>
+ <span class="ruby-comment cmt"># looking at, don't bother storing the stuff. I think this makes huge
+</span>
+ <span class="ruby-comment cmt"># speed and memory differences if you've got a chromosome with
+</span>
+ <span class="ruby-comment cmt"># thousands of features.
+</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">stop</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_start</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">start</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_stop</span>
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
View
61 trunk/doc/classes/Bio/Graphics/Panel/Track.src/M000010.html
@@ -10,43 +10,42 @@
<link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 115</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">draw</span>(<span class="ruby-identifier">panel_drawing</span>)
- <span class="ruby-identifier">track_drawing</span> = <span class="ruby-constant">Cairo</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">panel_drawing</span>)
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 112</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">draw</span>(<span class="ruby-identifier">panel_drawing</span>)
+ <span class="ruby-identifier">track_drawing</span> = <span class="ruby-constant">Cairo</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">panel_drawing</span>)