exodb 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd0cec2b7ef4791ab9686827bf8d31409152af2a
4
- data.tar.gz: 117c7eb770d5473a76909af778017f2557288982
3
+ metadata.gz: f59876f64775ac85fda8bbb7db9a06e253ab39b8
4
+ data.tar.gz: 978e13f8048b2cabea0cfe4fc96a9da6e42b97fe
5
5
  SHA512:
6
- metadata.gz: 6b7cd7602e7bda8da25c1799e5fbc0fd3221e04397b52a54cb4c1b5b2691b6cfea96d1e114bfc1f218529d747614544876da7eb78d8258ef3ee41a082d22eee2
7
- data.tar.gz: 5699679e8fb8834af7c4e7f42ca2f399c549c015b1fa07781240a9a9f76d01a56951ba72af04645254232d588a6c1c9424034f23ec03791098bd57a0e3d5bf3c
6
+ metadata.gz: ceca94da8429c39dee7e1baa9d96f5a88f8860cbf1c185ee2439845d0c93d3a63605bc4d2e6bc7c33c3e1d5c0c424e1d37a1f7557ce8a96baa303ca692a78f55
7
+ data.tar.gz: 1d20bb30b30b1aea8a612abd255c02f985a2b6fdcc6dd38431f387c2fc3335e56fd5261b38adefb58655d064cb6fef074e11d725af871768269b4bef2b44e9ee
@@ -17,6 +17,8 @@ gem 'mongoid', '~> 3.1'
17
17
 
18
18
  #Internal library
19
19
  require 'open-uri'
20
+ require 'net/http'
21
+ require 'uri'
20
22
  require 'json'
21
23
 
22
24
  #External library
@@ -11,12 +11,14 @@
11
11
 
12
12
  module Exodb
13
13
 
14
- module LocationField
14
+ module GenomeLocationField
15
15
 
16
16
  extend ActiveSupport::Concern
17
17
 
18
18
  included do
19
19
  field :location, type: Hash #{chromosome: '', start: x, stop: x}
20
+ field :strand, type: String
21
+
20
22
  index({location: 1}, background: true)
21
23
  end
22
24
 
@@ -73,7 +75,19 @@ module Exodb
73
75
  self[:location]['stop']
74
76
  end
75
77
 
76
- alias_method :end, :stop
78
+ # get the start position of gene rely on the genome
79
+ #
80
+ # @return [Integer] start position of gene
81
+ def begin
82
+ self[:strand] == '+' ? self[:location]['start'] : self[:location]['stop']
83
+ end
84
+
85
+ # get the start position of gene rely on the genome
86
+ #
87
+ # @return [Integer] start position of gene
88
+ def end
89
+ self[:strand] == '+' ? self[:location]['stop'] : self[:location]['start']
90
+ end
77
91
 
78
92
  # get the chromosome
79
93
  #
@@ -28,14 +28,14 @@ module Exodb
28
28
  PATTERN = /(?<gene>[A-Z0-9]+)-?(?<position>[0-9,]*|[is]?)(?<to>[A-Z=]*)/
29
29
  SILENTSIGN = '='
30
30
 
31
- include Exodb::LocationField
31
+ include Exodb::GenomeLocationField
32
32
 
33
33
  field :reference, type: String
34
34
  field :alternate, type: String
35
35
 
36
36
  end
37
37
 
38
- class Incidence
38
+ class Occurrent
39
39
 
40
40
  include Mongoid::Document
41
41
 
@@ -50,19 +50,18 @@ module Exodb
50
50
 
51
51
  class Generef < Reference
52
52
 
53
- include Exodb::LocationField
53
+ include Exodb::GenomeLocationField
54
54
 
55
55
  field :sequence, type: String
56
56
  field :chrrefseq, type: String # refseq id of chromomose
57
- field :strand, type: String
58
57
  field :psuedo, type: Boolean
59
58
  field :genomeref, type: String
60
59
 
61
60
  index({sequence: 'text'}, background: true)
62
61
 
63
62
  has_many :genes
64
- embeds_many :splices
65
- embeds_many :incidences
63
+ embeds_many :isoforms
64
+ embeds_many :occurrents
66
65
 
67
66
  validates_format_of :chrrefseq, with: /\A(urn:miriam:refseq)/
68
67
 
@@ -114,7 +113,7 @@ module Exodb
114
113
 
115
114
  # Download incident data from TCGA
116
115
  #
117
- def dl_incidence!
116
+ def dl_occurrent!
118
117
 
119
118
  if self.get_xref('urn:miriam:hgnc.symbol')
120
119
 
@@ -124,7 +123,7 @@ module Exodb
124
123
  f.each_line {|line| cancerstudies.push(line.chomp.split("\t")[0])}
125
124
  }
126
125
 
127
- incidents = {}
126
+ occurrents = {}
128
127
  totalcase = {}
129
128
 
130
129
  cancerstudies.each do |study|
@@ -137,7 +136,7 @@ module Exodb
137
136
  end
138
137
  end
139
138
 
140
- incidents[study] = {} if !incidents.has_key?(study)
139
+ occurrents[study] = {} if !occurrents.has_key?(study)
141
140
 
142
141
  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|
143
142
  f.each_line do |line|
@@ -145,8 +144,8 @@ module Exodb
145
144
 
146
145
  if dat[5] == 'Missense_Mutation'
147
146
 
148
- incidents[study][dat[7].split(/(\d+)/)[1]] = [] if !incidents[study].has_key?(dat[7].split(/(\d+)/)[1])
149
- incidents[study][dat[7].split(/(\d+)/)[1]].push(dat[2])
147
+ occurrents[study][dat[7].split(/(\d+)/)[1]] = [] if !occurrents[study].has_key?(dat[7].split(/(\d+)/)[1])
148
+ occurrents[study][dat[7].split(/(\d+)/)[1]].push(dat[2])
150
149
 
151
150
  end
152
151
 
@@ -156,11 +155,11 @@ module Exodb
156
155
  end
157
156
  end
158
157
 
159
- self.incidences.clear if self.incidences
158
+ self.occurrents.clear if self.occurrents
160
159
 
161
- incidents.each_pair do |cancertype, v|
160
+ occurrents.each_pair do |cancertype, v|
162
161
  v.each_pair do |position, occur|
163
- self.incidences << Incidence.new({cancertype: cancertype, position: position, occur: occur.uniq.sort, casenumber: totalcase[cancertype]})
162
+ self.occurrents << Occurrent.new({cancertype: cancertype, position: position, occur: occur.uniq.sort, casenumber: totalcase[cancertype]})
164
163
  end
165
164
  end
166
165
 
@@ -181,7 +180,7 @@ module Exodb
181
180
  def longest_splice()
182
181
  length = 0
183
182
  longest = nil
184
- self.splices.each do |e|
183
+ self.isoforms.each do |e|
185
184
 
186
185
  if e.prot_len > length
187
186
  length = e.prot_len
@@ -197,7 +196,7 @@ module Exodb
197
196
  #
198
197
  # @return [Boolean] true if has any splices
199
198
  def has_splices?
200
- return self.splices.exists?
199
+ return self.isoforms.exists?
201
200
  end
202
201
 
203
202
  # Check if Generef has sequence
@@ -231,7 +230,7 @@ module Exodb
231
230
 
232
231
  end
233
232
 
234
- class Splice
233
+ class Isoform
235
234
 
236
235
  include Mongoid::Document
237
236
 
@@ -375,7 +374,7 @@ module Exodb
375
374
 
376
375
  seqlen = self.get_cds_seq(pos).length
377
376
  if seqlen != 0
378
- return [(seqlen - 1) / 3, (seqlen - 1) % 3]
377
+ return [((seqlen - 1) / 3) + 1, ((seqlen - 1) % 3) + 1]
379
378
  else
380
379
  return []
381
380
  end
@@ -22,29 +22,56 @@ module Exodb
22
22
  class Gene < Region
23
23
 
24
24
  include Mongoid::Versioning
25
- include Exodb::LocationField
25
+ include Exodb::GenomeLocationField
26
26
 
27
27
  field :symbol, type: String
28
28
  field :loh, type: Boolean
29
29
 
30
- embeds_many :aacids
30
+ embeds_many :changes
31
31
  belongs_to :generef
32
32
  belongs_to :cell
33
33
 
34
34
  index({'symbol' => 1, 'aacids.position' => 1}, background: true)
35
35
  end
36
36
 
37
- class Aacid < Region
37
+ class Change
38
38
 
39
- field :position, type: Integer # position referenced to the first codon from the longest splice variant
39
+ include Mongoid::Document
40
+ include Mongoid::Timestamps
41
+
42
+ embedded_in :gene
43
+ has_many :variants
44
+
45
+ end
46
+
47
+ class Onexon < Change
48
+
49
+ field :aaposition, type: Integer # position referenced to the first codon from the longest splice variant
40
50
  field :refcodon, type: String
41
51
  field :refaa, type: String
42
52
  field :altcodon, type: Hash
43
53
  field :inhcodon, type: Hash
44
54
  field :isoform, type: Array
45
55
 
46
- embedded_in :gene
47
- has_many :variants
56
+ end
57
+
58
+ class Aa < Onexon
59
+
60
+ end
61
+
62
+ class Lossgain < Onexon
63
+
64
+ end
65
+
66
+ class Offexon < Change
67
+
68
+ end
69
+
70
+ class Splice < Offexon
71
+
72
+ end
73
+
74
+ class Utr < Offexon
48
75
 
49
76
  end
50
77
 
@@ -99,7 +99,6 @@ module Exodb
99
99
  position = splice.get_prot_pos(variant.start)
100
100
  aacid.isoform.push("#{generef.get_xref()}:p.#{mainsplice.get_codon(position[0]).translate}#{position[0]}") if !position.empty?
101
101
  end
102
- aacid.save!
103
102
  gene.save!
104
103
  end
105
104
  end
@@ -17,7 +17,7 @@ module Exodb
17
17
  include Mongoid::Versioning
18
18
  include Mongoid::Timestamps
19
19
 
20
- include Exodb::LocationField
20
+ include Exodb::GenomeLocationField
21
21
 
22
22
  #max_versions 5
23
23
 
@@ -74,11 +74,7 @@ module Exodb
74
74
 
75
75
  end
76
76
 
77
- class SV < Variant #
78
-
79
- end
80
-
81
- class Indel < Variant
77
+ class Indel < Variant #
82
78
 
83
79
  end
84
80
 
@@ -14,5 +14,9 @@ module Exodb
14
14
  class CreateUserError < Exception
15
15
 
16
16
  end
17
+
18
+ class InvalidResponse < Exception
19
+
20
+ end
17
21
 
18
22
  end
@@ -68,16 +68,16 @@ module Exodb
68
68
  # @param [String] database that user created
69
69
  def create_rwuser(username)
70
70
 
71
- create_user(username, Mongoid.session.options[:database], "readWrite")
71
+ create_user(username, Mongoid.session(:default).options[:database], "readWrite")
72
72
 
73
73
  end
74
74
 
75
75
  # To create a read-only user
76
76
  #
77
77
  # @param (see #create_rwuser)
78
- def create_ruser(username)
78
+ def create_rouser(username)
79
79
 
80
- create_user(username, Mongoid.session.options[:database], "read")
80
+ create_user(username, Mongoid.session(:default).options[:database], "read")
81
81
 
82
82
  end
83
83
 
@@ -11,6 +11,7 @@
11
11
 
12
12
  require 'exodb/utils/upload_generef.rb'
13
13
  require 'exodb/utils/upload_var.rb'
14
+ require 'exodb/utils/ensemblrest.rb'
14
15
 
15
16
  module Exodb
16
17
 
@@ -140,13 +140,13 @@ module Exodb
140
140
 
141
141
  v[:childs].each do |child|
142
142
 
143
- rna = Splice.new()
143
+ rna = Isoform.new()
144
144
  data = genes[child]
145
145
  rna.xrefs = data[:xrefs]
146
146
  rna.exon = data[:exon].sort
147
147
  rna.cds = data[:cds].sort
148
148
 
149
- gene.splices.push(rna)
149
+ gene.isoforms.push(rna)
150
150
 
151
151
  end
152
152
 
@@ -51,6 +51,16 @@ module Exodb
51
51
 
52
52
  end
53
53
  end
54
+
55
+ def load_variant_from_ann(annfile)
56
+
57
+ File.open(annfile).each do |line|
58
+ record = line.chomp.split("\t")
59
+ p record
60
+ end
61
+
62
+ end
63
+
54
64
  end
55
65
 
56
66
  end
@@ -11,5 +11,5 @@
11
11
 
12
12
 
13
13
  module Exodb
14
- VERSION = "0.0.2"
14
+ VERSION = "0.1.0"
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Natapol Pornputtapong