Class: Bio::Graphics::Panel::Track::Feature
- Inherits:
-
Object
- Object
- Bio::Graphics::Panel::Track::Feature
- Defined in:
- lib/bio/graphics/feature.rb
Overview
The Bio::Graphics::Track::Feature class describes features to be placed on the graph. See Bio::Graphics documentation for explanation of interplay between different classes.
The position of the Feature is a Bio::Locations object to make it possible to transparently work with simple and spliced features.
Defined Under Namespace
Classes: PixelRange
Instance Attribute Summary collapse
-
#chopped_at_start ⇒ Object
Is the first subfeature incomplete?.
-
#chopped_at_stop ⇒ Object
Is the last subfeature incomplete?.
-
#hidden_subfeatures_at_start ⇒ Object
Are there subfeatures out of view at the left side of the picture?.
-
#hidden_subfeatures_at_stop ⇒ Object
Are there subfeatures out of view at the right side of the picture?.
-
#link ⇒ Object
The URL to be followed when the glyph for this feature is clicked.
-
#location ⇒ Object
The location of the feature (which is a Bio::Locations object).
-
#name ⇒ Object
The name of the feature.
-
#pixel_range_collection ⇒ Object
The array keeping the pixel ranges for the sub-features.
-
#start ⇒ Object
The start position of the feature (in bp).
-
#stop ⇒ Object
The stop position of the feature (in bp).
-
#strand ⇒ Object
The strand of the feature.
-
#track ⇒ Object
The track that this feature belongs to.
Instance Method Summary collapse
-
#initialize(track, name, location = Bio::Locations.new('1..' + track.panel.length.to_s), link = nil) ⇒ Feature
constructor
!!Not to be used directly.
Constructor Details
#initialize(track, name, location = Bio::Locations.new('1..' + track.panel.length.to_s), link = nil) ⇒ Feature
!!Not to be used directly. Use Bio::Graphics::Panel::Track.add_feature instead!! A feature can not exist except within the confines of a Bio::Graphics::Panel::Track object.
– This is necessary because the feature needs to know the colour and glyph, both of which are defined within the panel. ++
Arguments:
- panel (required)
-
Bio::Graphics::Panel::Track object that this
feature belongs to
- name (required)
-
Name of the feature
- location
-
Bio::Locations object. Default = whole panel, forward strand
- link
-
URL for clickable images
- Returns
-
Bio::Graphics::Track::Feature object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/bio/graphics/feature.rb', line 37 def initialize(track, name, location = Bio::Locations.new('1..' + track.panel.length.to_s), link = nil) @track = track @name = name @location = location @start = location.collect{|l| l.from}.min.to_i @stop = location.collect{|l| l.to}.max.to_i @strand = location[0].strand.to_i @link = link @pixel_range_collection = Array.new @chopped_at_start = false @chopped_at_stop = false @hidden_subfeatures_at_start = false @hidden_subfeatures_at_stop = false # Get all pixel ranges for the subfeatures location.each do |l| # xxxxxx [ ] if l.to < track.panel.display_start @hidden_subfeatures_at_start = true next # [ ] xxxxx elsif l.from > track.panel.display_stop @hidden_subfeatures_at_stop = true next # xxxx[xxx ] elsif l.from < track.panel.display_start and l.to > track.panel.display_start start_pixel = 1 stop_pixel = ( l.to - track.panel.display_start ).to_f / track.panel.rescale_factor @chopped_at_start = true # [ xxxx]xxxx elsif l.from < track.panel.display_stop and l.to > track.panel.display_stop start_pixel = ( l.from - track.panel.display_start ).to_f / track.panel.rescale_factor stop_pixel = track.panel.width @chopped_at_stop = true # xxxx[xxxxxxxxxx]xxxx elsif l.from < track.panel.display_start and l.to > track.panel.display_stop start_pixel = 1 stop_pixel = track.panel.width @chopped_at_start = true @chopped_at_stop = true # [ xxxxx ] else start_pixel = ( l.from - track.panel.display_start ).to_f / track.panel.rescale_factor stop_pixel = ( l.to - track.panel.display_start ).to_f / track.panel.rescale_factor end @pixel_range_collection.push(PixelRange.new(start_pixel, stop_pixel)) end end |
Instance Attribute Details
#chopped_at_start ⇒ Object
Is the first subfeature incomplete?
115 116 117 |
# File 'lib/bio/graphics/feature.rb', line 115 def chopped_at_start @chopped_at_start end |
#chopped_at_stop ⇒ Object
Is the last subfeature incomplete?
118 119 120 |
# File 'lib/bio/graphics/feature.rb', line 118 def chopped_at_stop @chopped_at_stop end |
#hidden_subfeatures_at_start ⇒ Object
Are there subfeatures out of view at the left side of the picture?
121 122 123 |
# File 'lib/bio/graphics/feature.rb', line 121 def hidden_subfeatures_at_start @hidden_subfeatures_at_start end |
#hidden_subfeatures_at_stop ⇒ Object
Are there subfeatures out of view at the right side of the picture?
124 125 126 |
# File 'lib/bio/graphics/feature.rb', line 124 def hidden_subfeatures_at_stop @hidden_subfeatures_at_stop end |
#link ⇒ Object
The URL to be followed when the glyph for this feature is clicked
107 108 109 |
# File 'lib/bio/graphics/feature.rb', line 107 def link @link end |
#location ⇒ Object
The location of the feature (which is a Bio::Locations object)
95 96 97 |
# File 'lib/bio/graphics/feature.rb', line 95 def location @location end |
#name ⇒ Object
The name of the feature
92 93 94 |
# File 'lib/bio/graphics/feature.rb', line 92 def name @name end |
#pixel_range_collection ⇒ Object
The array keeping the pixel ranges for the sub-features. Unspliced features will just have one element, while spliced features will have more than one.
112 113 114 |
# File 'lib/bio/graphics/feature.rb', line 112 def pixel_range_collection @pixel_range_collection end |
#start ⇒ Object
The start position of the feature (in bp)
98 99 100 |
# File 'lib/bio/graphics/feature.rb', line 98 def start @start end |
#stop ⇒ Object
The stop position of the feature (in bp)
101 102 103 |
# File 'lib/bio/graphics/feature.rb', line 101 def stop @stop end |
#strand ⇒ Object
The strand of the feature
104 105 106 |
# File 'lib/bio/graphics/feature.rb', line 104 def strand @strand end |
#track ⇒ Object
The track that this feature belongs to
89 90 91 |
# File 'lib/bio/graphics/feature.rb', line 89 def track @track end |