Class: Exodb::Isoform
- Inherits:
-
Object
- Object
- Exodb::Isoform
- Includes:
- XrefsField, Mongoid::Document
- Defined in:
- lib/exodb/datamodel/reference.rb
Instance Method Summary collapse
- #get_cds_join(position = 0) ⇒ Object
-
#get_cds_seq(position = 0) ⇒ Bio::Sequence
Get spliced coding region sequence.
-
#get_codon(codon_pos) ⇒ Bio::Sequence
Get the codon sequence at the giving position base on position of amino acid.
-
#get_dna_seq ⇒ Bio::Sequence
Get spliced DNA sequence.
- #get_exon_join(position = 0) ⇒ Object
-
#get_join_str(arr, position = 0) ⇒ String
join exon or cds position into a string.
-
#get_mrna_seq ⇒ Bio::Sequence
Get spliced RNA sequence.
-
#get_prot_pos(pos) ⇒ Array
convert genomic position to codon position.
-
#get_prot_seq ⇒ Bio::Sequence
Get spliced protein sequence.
-
#prot_len ⇒ Integer
get length of protein product.
-
#rna_len ⇒ Integer
get length of spliced RNA.
Methods included from XrefsField
Instance Method Details
#get_cds_join(position = 0) ⇒ Object
301 302 303 |
# File 'lib/exodb/datamodel/reference.rb', line 301 def get_cds_join(position = 0) get_join_str(self[:cds], position) end |
#get_cds_seq(position = 0) ⇒ Bio::Sequence
Get spliced coding region sequence
326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/exodb/datamodel/reference.rb', line 326 def get_cds_seq(position = 0) parent = self.generef if parent.strand == '+' join = self.get_cds_join(position) return !join.empty? ? parent.to_seq.splicing("join(#{join})") : "" else join = self.get_cds_join(-position) return !join.empty? ? parent.to_seq.splicing("join(#{join})") : "" end end |
#get_codon(codon_pos) ⇒ Bio::Sequence
Get the codon sequence at the giving position base on position of amino acid
365 366 367 |
# File 'lib/exodb/datamodel/reference.rb', line 365 def get_codon(codon_pos) return self.get_cds_seq().subseq(((codon_pos - 1) * 3) + 1 , ((codon_pos - 1) * 3) + 3) end |
#get_dna_seq ⇒ Bio::Sequence
Get spliced DNA sequence
308 309 310 311 |
# File 'lib/exodb/datamodel/reference.rb', line 308 def get_dna_seq parent = self.generef return parent.strand == '+' ? parent.to_seq.splicing("join(#{self.get_exon_join})") : parent.to_seq.splicing("complement(join(#{self.get_exon_join}))") end |
#get_exon_join(position = 0) ⇒ Object
297 298 299 |
# File 'lib/exodb/datamodel/reference.rb', line 297 def get_exon_join(position = 0) get_join_str(self[:exon], position) end |
#get_join_str(arr, position = 0) ⇒ String
join exon or cds position into a string
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/exodb/datamodel/reference.rb', line 250 def get_join_str(arr, position = 0) reducer = self.generef.start - 1 tmparr = [] found = false if position > 0 add = true arr.each do |e| if e[0] <= position && position <= e[1] tmparr.push([e[0], position]) add = false found = true else tmparr.push(e) if add end end elsif position < 0 position = position.abs add = false arr.each do |e| if e[0] <= position && position <= e[1] tmparr.push([position, e[1]]) add = true found = true else tmparr.push(e) if add end end else tmparr = arr end tmparr = [] if !found && position != 0 str = [] tmparr.each do |e| str.push("#{e[0] - reducer}..#{e[1] - reducer}") end return str.join(',') end |
#get_mrna_seq ⇒ Bio::Sequence
Get spliced RNA sequence
316 317 318 319 |
# File 'lib/exodb/datamodel/reference.rb', line 316 def get_mrna_seq parent = self.generef return parent.strand == '+' ? parent.to_seq.splicing("join(#{self.get_exon_join})").rna : parent.to_seq.splicing("complement(join(#{self.get_exon_join}))").rna end |
#get_prot_pos(pos) ⇒ Array
convert genomic position to codon position
373 374 375 376 377 378 379 380 381 382 |
# File 'lib/exodb/datamodel/reference.rb', line 373 def get_prot_pos(pos) seqlen = self.get_cds_seq(pos).length if seqlen != 0 return [((seqlen - 1) / 3) + 1, ((seqlen - 1) % 3) + 1] else return [] end end |
#get_prot_seq ⇒ Bio::Sequence
Get spliced protein sequence
342 343 344 345 |
# File 'lib/exodb/datamodel/reference.rb', line 342 def get_prot_seq parent = self.generef return parent.strand == '+' ? parent.to_seq.splicing("join(#{self.get_cds_join})").translate : parent.to_seq.splicing("complement(join(#{self.get_cds_join}))").translate end |
#prot_len ⇒ Integer
get length of protein product
357 358 359 |
# File 'lib/exodb/datamodel/reference.rb', line 357 def prot_len return self.get_prot_seq.length end |
#rna_len ⇒ Integer
get length of spliced RNA
350 351 352 |
# File 'lib/exodb/datamodel/reference.rb', line 350 def rna_len return self.get_mrna_seq.length end |