Module: Ensembl::Core::Sliceable
- Included in:
- AssemblyException, DnaAlignFeature, Exon, Gene, Intron, Karyotype, MarkerFeature, MiscFeature, OligoFeature, PredictionExon, PredictionTranscript, ProteinAlignFeature, ProteinFeature, RegulatoryFeature, RepeatFeature, SimpleFeature, Transcript
- Defined in:
- lib/bio-ensembl/core/activerecord.rb,
lib/bio-ensembl/core/transform.rb
Overview
The Sliceable mixin holds the get_slice method and can be included in any class that lends itself to having a position on a SeqRegion.
Instance Method Summary collapse
-
#length ⇒ Integer
The Sliceable#length method returns the length of the feature (based on seq_region_start and seq_region_end..
-
#project(coord_system_name) ⇒ Array<Slice,Gap>
The Sliceable#project method is used to transfer coordinates from one coordinate system to another.
-
#seq ⇒ String
The Sliceable#seq method takes the coordinates on a reference, transforms onto the seqlevel coordinate system if necessary, and retrieves the sequence.
-
#slice ⇒ Ensembl::Core::Slice
The Sliceable#slice method takes the coordinates on a reference and creates a Ensembl::Core::Slice object.
-
#start ⇒ Integer
The Sliceable#start method is a convenience method and returns self.seq_region_start.
-
#stop ⇒ Integer
The Sliceable#stop method is a convenience method and returns self.seq_region_end.
-
#strand ⇒ Numeric
The Sliceable#strand method is a convenience method and returns self.seq_region_strand.
-
#transform(coord_system_name) ⇒ Object
The #transform method is used to transfer coordinates for a feature from one coordinate system to another.
Instance Method Details
#length ⇒ Integer
The Sliceable#length method returns the length of the feature (based on seq_region_start and seq_region_end.
141 142 143 |
# File 'lib/bio-ensembl/core/activerecord.rb', line 141 def length return self.stop - self.start + 1 end |
#project(coord_system_name) ⇒ Array<Slice,Gap>
The Sliceable#project method is used to transfer coordinates from one coordinate system to another. Suppose you have a feature on a contig in human (let’s say on contig AC000031.6.1.38703) and you want to know the coordinates on the chromosome. This is a projection of coordinates from a higher ranked coordinate system to a lower ranked coordinate system. Projections can also be done from a chromosome to the contig level. However, it might be possible that more than one contig has to be included and that there exist gaps between the contigs. The output of this method therefore is an array of Slice and Gap objects.
At the moment, projections can only be done if the two coordinate systems are linked directly in the ‘assembly’ table.
168 169 170 |
# File 'lib/bio-ensembl/core/activerecord.rb', line 168 def project(coord_system_name) return self.slice.project(coord_system_name) end |
#seq ⇒ String
The Sliceable#seq method takes the coordinates on a reference, transforms onto the seqlevel coordinate system if necessary, and retrieves the sequence.
109 110 111 |
# File 'lib/bio-ensembl/core/activerecord.rb', line 109 def seq return self.slice.seq end |
#slice ⇒ Ensembl::Core::Slice
The Sliceable#slice method takes the coordinates on a reference and creates a Ensembl::Core::Slice object.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/bio-ensembl/core/activerecord.rb', line 86 def slice start, stop, strand = nil, nil, nil if self.class == Ensembl::Core::Intron or self.class.column_names.include?('seq_region_start') start = self.seq_region_start end if self.class == Ensembl::Core::Intron or self.class.column_names.include?('seq_region_end') stop = self.seq_region_end end if self.class == Ensembl::Core::Intron or self.class.column_names.include?('seq_region_strand') strand = self.seq_region_strand else #FIXME: we shouldn't do this, but can't #project if no strand given strand = 1 end return Ensembl::Core::Slice.new(self.seq_region, start, stop, strand) end |
#start ⇒ Integer
The Sliceable#start method is a convenience method and returns self.seq_region_start.
117 118 119 |
# File 'lib/bio-ensembl/core/activerecord.rb', line 117 def start return self.seq_region_start end |
#stop ⇒ Integer
The Sliceable#stop method is a convenience method and returns self.seq_region_end.
125 126 127 |
# File 'lib/bio-ensembl/core/activerecord.rb', line 125 def stop return self.seq_region_end end |
#strand ⇒ Numeric
The Sliceable#strand method is a convenience method and returns self.seq_region_strand.
133 134 135 |
# File 'lib/bio-ensembl/core/activerecord.rb', line 133 def strand return self.seq_region_strand end |
#transform(coord_system_name) ⇒ Object
The #transform method is used to transfer coordinates for a feature from one coordinate system to another. It basically creates a clone of the original feature and changes the seq_region, start position, stop position and strand.
Suppose you have a feature on a contig in human (let’s say on contig AC000031.6.1.38703) and you want to know the coordinates on the chromosome. This is a transformation of coordinates from a higher ranked coordinate system to a lower ranked coordinate system. Transformations can also be done from a chromosome to the contig level.
In contrast to the #project method of Sliceables, the coordinates of a feature can only transformed to the target coordinate system if there is no ambiguity to which SeqRegion.
For example, gene A can be transferred from the chromosome system to the clone coordinate system, whereas gene B can not.
gene A gene B
|---<=====>--------------------<=====>----------------| chromosome
|-----------| |-------| |---------| clones
|-----------| |-------| |--------|
gene_a.transform('clone') --> gene
gene_b.transform('clone') --> nil
At the moment, transformations can only be done if the two coordinate systems are linked directly in the ‘assembly’ table.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/bio-ensembl/core/transform.rb', line 66 def transform(coord_system_name) #- # There are two things I can do: # (1) just use project # (2) avoid doing all the calculations in project if the source slice # covers multiple target slices, and _then_ go for project. # Let's go for nr 1 for the moment and optimize later. #+ if self.slice.seq_region.coord_system.name == coord_system_name return self end target_slices = self.slice.project(coord_system_name) if target_slices.length > 1 return nil else clone = self.clone clone.seq_region_id = target_slices[0].seq_region.id clone.seq_region_start = target_slices[0].start clone.seq_region_end = target_slices[0].stop clone.seq_region_strand = target_slices[0].strand * self.strand return clone end end |