Class: Exodb::Isoform

Inherits:
Object
  • Object
show all
Includes:
XrefsField, Mongoid::Document
Defined in:
lib/exodb/datamodel/reference.rb

Instance Method Summary collapse

Methods included from XrefsField

#get_xref

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

Parameters:

  • end (Integer)

    position to get sequence

Returns:

  • (Bio::Sequence)

    an 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

Parameters:

  • codon (Integer)

    position

Returns:

  • (Bio::Sequence)

    the codon at given position



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_seqBio::Sequence

Get spliced DNA sequence

Returns:

  • (Bio::Sequence)

    an 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

Parameters:

  • input (Array)

    array exon or cds

  • Position (Interger)

    to stop positive value for forward read negative value for complement

Returns:

  • (String)

    a string in start..end,start..end,…



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_seqBio::Sequence

Get spliced RNA sequence

Returns:

  • (Bio::Sequence)

    an 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

Parameters:

  • genomic (Integer)

    position

Returns:

  • (Array)

    Return all information of codon at given 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_seqBio::Sequence

Get spliced protein sequence

Returns:

  • (Bio::Sequence)

    an 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_lenInteger

get length of protein product

Returns:

  • (Integer)

    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_lenInteger

get length of spliced RNA

Returns:

  • (Integer)

    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