Permalink
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...
jandot
jandot committed Nov 16, 2007
1 parent ff16da3 commit 3313fc4901f090da95d8eb4a648afb4b13856cd9
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

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -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
@@ -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
@@ -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
@@ -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>
Oops, something went wrong.

0 comments on commit 3313fc4

Please sign in to comment.