Class: Exodb::Generef
- Includes:
- GeneLocationField
- Defined in:
- lib/exodb/datamodel/generef.rb
Constant Summary collapse
- @@expanding =
500
Class Method Summary collapse
-
.expanding ⇒ Object
oid = “chrrefseq:start..stop”.
Instance Method Summary collapse
-
#can_translated? ⇒ Boolean
Check if Generef can translate.
-
#dl_occurrent! ⇒ Object
Download incident data from TCGA.
-
#dl_symbol! ⇒ Object
Download gene symbol from HGNC service.
-
#has_sequence? ⇒ Boolean
Check if Generef has sequence.
-
#has_splices? ⇒ Boolean
(also: #has_isoforms?)
Check that this gene has any splice variant.
-
#longest_splice ⇒ Object
(also: #longest_isoform)
return longest splice of this gene.
-
#symbol ⇒ String
Get gene symbol.
Methods included from GeneLocationField
#begin, #chromosome, #dl_seq!, #end, #get_splice, #location=, #location_str, #start, #stop, #to_seq, #whole_seq
Methods included from XrefsField
Class Method Details
.expanding ⇒ Object
oid = “chrrefseq:start..stop”
41 42 43 |
# File 'lib/exodb/datamodel/generef.rb', line 41 def self. return @@expanding end |
Instance Method Details
#can_translated? ⇒ Boolean
Check if Generef can translate
172 173 174 |
# File 'lib/exodb/datamodel/generef.rb', line 172 def can_translated?() return self.has_sequence? && self.has_splices? && self.longest_splice != nil ? true : false end |
#dl_occurrent! ⇒ Object
Download incident data from TCGA
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/exodb/datamodel/generef.rb', line 79 def dl_occurrent! if self.get_xref('urn:miriam:hgnc.symbol') cancerstudies = [] open("http://www.cbioportal.org/public-portal/webservice.do?cmd=getCancerStudies") {|f| f.each_line {|line| cancerstudies.push(line.chomp.split("\t")[0])} } occurrents = {} totalcase = {} cancerstudies.each do |study| totalcase[study] = 0 if !totalcase.has_key?(study) open("http://www.cbioportal.org/public-portal/webservice.do?cmd=getCaseLists&cancer_study_id=#{study}") do |f| f.each_line do |line| totalcase[study] += line.chomp.split(/\t/)[4].split(' ').length if line =~ /\tSequenced Tumors\t/ end end occurrents[study] = {} if !occurrents.has_key?(study) open("http://www.cbioportal.org/public-portal/webservice.do?cmd=getMutationData&genetic_profile_id=#{study}_mutations&gene_list=#{self.get_xref('urn:miriam:hgnc.symbol').id}") do |f| f.each_line do |line| dat = line.chomp.split(/\t/) if dat[5] == 'Missense_Mutation' occurrents[study][dat[7].split(/(\d+)/)[1]] = [] if !occurrents[study].has_key?(dat[7].split(/(\d+)/)[1]) occurrents[study][dat[7].split(/(\d+)/)[1]].push(dat[2]) end end end end self.occurrents.clear if self.occurrents occurrents.each_pair do |cancertype, v| v.each_pair do |position, occur| self.occurrents << Occurrent.new({cancertype: cancertype, position: position, occur: occur.uniq.sort, casenumber: totalcase[cancertype]}) end end self.save! end end |
#dl_symbol! ⇒ Object
Download gene symbol from HGNC service
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/exodb/datamodel/generef.rb', line 47 def dl_symbol! baseuri = "http://rest.genenames.org/search" query = "" if self.get_xref('urn:miriam:refseq') query = "#{baseuri}/refseq_accession/#{self.chrrefseq.id.split('.')[0]}" elsif self.get_xref('urn:miriam:ncbigene') query = "" end if !query.empty? response = JSON.parse(open(query, 'Accept' => 'application/json').read)['response'] if !response['docs'].empty? response['docs'].each do |e| self.add_to_set(:xrefs, "urn:miriam:hgnc:#{e["hgnc_id"]}") self.add_to_set(:xrefs, "urn:miriam:hgnc.symbol:#{e["symbol"]}") end self.save! end end end |
#has_sequence? ⇒ Boolean
Check if Generef has sequence
165 166 167 |
# File 'lib/exodb/datamodel/generef.rb', line 165 def has_sequence?() return self[:sequence] ? true : false end |
#has_splices? ⇒ Boolean Also known as: has_isoforms?
Check that this gene has any splice variant
156 157 158 |
# File 'lib/exodb/datamodel/generef.rb', line 156 def has_splices? return self.isoforms.exists? end |
#longest_splice ⇒ Object Also known as: longest_isoform
return longest splice of this gene
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/exodb/datamodel/generef.rb', line 136 def longest_splice() length = 0 longest = nil self.isoforms.each do |e| if e.prot_len > length length = e.prot_len longest = e end end return longest end |
#symbol ⇒ String
Get gene symbol
179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/exodb/datamodel/generef.rb', line 179 def symbol if self.get_xref('urn:miriam:hgnc.symbol') return self.get_xref('urn:miriam:hgnc.symbol').id elsif self.xrefs && !self.xrefs.empty? return self.xrefs.sort[0].id else return 'nosymbol' end end |