Class: Exodb::Cell
Class Method Summary collapse
Instance Method Summary collapse
-
#add_to_dataset(str) ⇒ Object
get the start position of gene rely on the genome.
-
#translate!(cutoff = 0) ⇒ Object
Translate variant.
Class Method Details
.translate! ⇒ Object
57 58 59 |
# File 'lib/exodb/datamodel/source.rb', line 57 def self.translate! self.where({}).each {|e| e.translate!} end |
Instance Method Details
#add_to_dataset(str) ⇒ Object
get the start position of gene rely on the genome
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/exodb/datamodel/source.rb', line 64 def add_to_dataset(str) dataset = Dataset.where('$or' => [{'oid' => str}, {'name' => str}]) if dataset.exists? self.dataset = dataset.first() #output.puts "#EXODUS:INFO This sample is added to #{dataset.first().name}." if $0 == 'pry' else #output.puts "#EXODUS:ERRO Cannot find dataset by #{str}." if $0 == 'pry' end end |
#translate!(cutoff = 0) ⇒ Object
Translate variant
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/exodb/datamodel/source.rb', line 79 def translate!(cutoff = 0) self.variants.each do |variant| Generef.cover?(variant.location_str).each do |generef| if generef.can_translated? mainsplice = generef.longest_splice position = mainsplice.get_prot_pos(variant.start) if !position.empty? gene = self.genes.find_or_create_by({symbol: generef.symbol}) gene.generef = generef aacid = gene.aacids.find_or_create_by({position: /\A[A-Z]#{position[0]}[A-Z]?\z/ =~ variant.aachange ? position[0] : variant.aachange.split(/(\d+)/)[1].to_i}) aacid.refcodon = mainsplice.get_codon(position[0]) if !aacid.refcodon aacid.refaa = mainsplice.get_codon(position[0]).translate if !aacid.refaa aacid.altcodon = {} if !aacid.altcodon aacid.altcodon[position[1]] = aacid.altcodon[position[1]] ? aacid.altcodon[position[:posincodon]] | variant.alternate : variant.alternate aacid.isoform = [] if !aacid.isoform aacid.variants.push(variant) generef.splices.each do |splice| position = splice.get_prot_pos(variant.start) aacid.isoform.push("#{generef.get_xref()}:p.#{mainsplice.get_codon(position[0]).translate}#{position[0]}") if !position.empty? end gene.save! end end end end end |