Module Ensembl::Core::Sliceable
In: lib/ensembl/core/activerecord.rb
lib/ensembl/core/transform.rb

DESCRIPTION

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.

Methods

length   project   seq   slice   start   stop   strand   transform  

Public Instance methods

DESCRIPTION

The Sliceable#length method returns the length of the feature (based on seq_region_start and seq_region_end.


Arguments:none
Returns:sequence

[Source]

     # File lib/ensembl/core/activerecord.rb, line 152
152:       def length
153:         return self.stop - self.start + 1
154:       end

DESCRIPTION

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.

USAGE

 # Get a contig slice in cow and project to scaffold level
 # (i.e. going from a high rank coord system to a lower rank coord
 # system)
 original_feature = Gene.find(85743)
 target_slices = original_feature.project('scaffold')

Arguments:

  • coord_system_name:: name of coordinate system to project coordinates to
Returns:an array consisting of Slices and, if necessary, Gaps

[Source]

     # File lib/ensembl/core/activerecord.rb, line 184
184:       def project(coord_system_name)
185:         return self.slice.project(coord_system_name)
186:       end

DESCRIPTION

The Sliceable#seq method takes the coordinates on a reference, transforms onto the seqlevel coordinate system if necessary, and retrieves the sequence.


Arguments:none
Returns:sequence

[Source]

     # File lib/ensembl/core/activerecord.rb, line 112
112:       def seq
113:         return self.slice.seq
114:       end

DESCRIPTION

The Sliceable#slice method takes the coordinates on a reference and creates a Ensembl::Core::Slice object.


Arguments:none
Returns:Ensembl::Core::Slice object

[Source]

     # File lib/ensembl/core/activerecord.rb, line 88
 88:       def slice
 89:         start, stop, strand = nil, nil, nil
 90:         if self.class.column_names.include?('seq_region_start')
 91:           start = self.seq_region_start
 92:         end
 93:         if self.class.column_names.include?('seq_region_end')
 94:           stop = self.seq_region_end
 95:         end
 96:         if self.class.column_names.include?('seq_region_strand')
 97:           strand = self.seq_region_strand
 98:         else #FIXME: we shouldn't do this, but can't #project if no strand given

 99:           strand = 1
100:         end
101:       
102:         return Ensembl::Core::Slice.new(self.seq_region, start, stop, strand)
103:       end

DESCRIPTION

The Sliceable#start method is a convenience method and returns self.seq_region_start.


Arguments:none
Returns:sequence

[Source]

     # File lib/ensembl/core/activerecord.rb, line 122
122:       def start
123:         return self.seq_region_start
124:       end

DESCRIPTION

The Sliceable#stop method is a convenience method and returns self.seq_region_end.


Arguments:none
Returns:sequence

[Source]

     # File lib/ensembl/core/activerecord.rb, line 132
132:       def stop
133:         return self.seq_region_end
134:       end

DESCRIPTION

The Sliceable#strand method is a convenience method and returns self.seq_region_strand.


Arguments:none
Returns:sequence

[Source]

     # File lib/ensembl/core/activerecord.rb, line 142
142:       def strand
143:         return self.seq_region_strand
144:       end

DESCRIPTION

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.

USAGE

 # Get a gene in cow and transform to scaffold level
 # (i.e. going from a high rank coord system to a lower rank coord
 # system)
 # Cow scaffold Chr4.10 lies on Chr4 from 8030345 to 10087277 on the
 # reverse strand
 source_gene = Gene.find(2408)
 target_gene = source_gene.transform('scaffold')
 puts source_gene.seq_region.name   #--> 4
 puts source_gene.seq_region_start  #--> 8104409
 puts source_gene.seq_region_end    #--> 8496477
 puts source_gene.seq_region_strand #--> -1
 puts target_gene.seq_region.name   #--> Chr4.003.10
 puts target_gene.seq_region_start  #--> 1590800
 puts target_gene.seq_region_end    #--> 1982868
 puts target_gene.seq_region_strand #--> 1

Arguments:

  • coord_system_name:: name of coordinate system to transform to coordinates to
Returns:nil or an object of the same class as self

[Source]

    # File lib/ensembl/core/transform.rb, line 68
68:       def transform(coord_system_name)
69:         #-
70:         # There are two things I can do:
71:         # (1) just use project
72:         # (2) avoid doing all the calculations in project if the source slice
73:         #     covers multiple target slices, and _then_ go for project.
74:         # Let's go for nr 1 for the moment and optimize later.
75:         #+
76: 
77:         if self.slice.seq_region.coord_system.name == coord_system_name
78:           return self
79:         end
80: 
81:         target_slices = self.slice.project(coord_system_name)
82:         if target_slices.length > 1
83:           return nil
84:         else
85:           clone = self.clone
86:           clone.seq_region_id = target_slices[0].seq_region.id
87:           clone.seq_region_start = target_slices[0].start
88:           clone.seq_region_end = target_slices[0].stop
89: 
90:           clone.seq_region_strand = target_slices[0].strand * self.strand
91: 
92:           return clone
93:         end
94:       end

[Validate]