rbbt-phgx 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,79 @@
1
+ require 'rbbt/util/open'
2
+ require 'rbbt/tsv'
3
+ require 'nokogiri'
4
+ require 'digest/md5'
5
+ require 'net/http/post/multipart'
6
+
7
+ module CHASM
8
+
9
+ class NotDone < StandardError; end
10
+
11
+ URL="http://www.cravat.us/ClassifierSelect1"
12
+ ASTERISK = "*"[0]
13
+
14
+ # Hash of samples pointing to mutations specified in Ensembl Transcript ID
15
+ def self.predict(mutations_by_sample, options = {})
16
+ options = Misc.add_defaults options, :chosendb => "CHASM", :emailbox => 'dev@null.org', :analysistype => 'driver', :inputfile => nil
17
+ mutationbox = []
18
+ i = 1
19
+ mutations_by_sample.each do |sample,mutations|
20
+ mutations.each do |mutation|
21
+ mutationbox << [i, sample].concat(mutation.split(":"))
22
+ end
23
+ i += 1
24
+ end
25
+
26
+ options[:mutationbox] = mutationbox.collect{|line| line * "\t"} * "\n"
27
+ post_data = options.collect{|k,v| [k,v] * "="} * "&"
28
+
29
+ Log.debug "Querying CHASM for: #{mutationbox.length} mutations in #{mutations_by_sample.length} samples"
30
+
31
+ tries = 0
32
+ nocache = false
33
+ begin
34
+ doc = nil
35
+ TmpFile.with_file(post_data) do |post_file|
36
+ Log.medium "Updating cache:" if nocache == :update
37
+
38
+ url = URI.parse(URL)
39
+ req = Net::HTTP::Post::Multipart.new url.path, options
40
+ res = Net::HTTP.start(url.host, url.port) do |http|
41
+ http.request(req)
42
+ end
43
+ job_id = JSON.parse(res.body)["jobId"]
44
+ puts job_id
45
+ end
46
+ end
47
+ end
48
+
49
+ def self.chunked_predict(mutations, max = 1000)
50
+ flattened_mutations = mutations.collect{|g,list| list = [list] unless Array === list; list.collect{|m| [g,m] } }.flatten(1)
51
+ chunks = flattened_mutations.length.to_f / max
52
+ chunks = chunks.ceil
53
+
54
+ Log.debug("Mutation Assessor ran with #{chunks} chunks of #{ max } mutations") if chunks > 1
55
+ num = 1
56
+ Misc.divide(flattened_mutations, chunks).inject(nil) do |acc, list|
57
+ Log.debug("Mutation Assessor ran with #{chunks} chunks: chunk #{num}") if chunks > 1
58
+ unflattened_mutations = {}
59
+ list.each{|g,m| next if g.nil?; unflattened_mutations[g] ||= []; unflattened_mutations[g] << m}
60
+ if acc.nil?
61
+ acc = predict(unflattened_mutations)
62
+ else
63
+ acc = TSV.setup(acc.merge(predict(unflattened_mutations)))
64
+ end
65
+ num += 1
66
+ acc
67
+ end
68
+ end
69
+ end
70
+
71
+
72
+ __END__
73
+
74
+ name="mutationbox" 1 NP_001135977 R641W 1
75
+ name="inputfile"
76
+ name="analysistype" driver
77
+ name="chosendb" CHASM
78
+ name="cancertype" Breast
79
+ name="emailbox" mikisvaz@gmail.com
@@ -7,7 +7,7 @@ module KEGG
7
7
  self.subdir = "share/kegg"
8
8
 
9
9
 
10
- KEGG.claim KEGG.root.find, :rake, Rbbt.share.install.KEGG.Rakefile.find(:lib)
10
+ KEGG.claim KEGG.root, :rake, Rbbt.share.install.KEGG.Rakefile.find(:lib)
11
11
 
12
12
  def self.names
13
13
  @@names ||= KEGG.pathways.tsv :fields => ["Pathway Name"], :persist => true, :type => :single, :unnamed => true
@@ -5,5 +5,5 @@ module Matador
5
5
  self.pkgdir = "phgx"
6
6
  self.subdir = "share/matador"
7
7
 
8
- Matador.claim Matador.root.find, :rake, Rbbt.share.install.Matador.Rakefile.find(:lib)
8
+ Matador.claim Matador.root, :rake, Rbbt.share.install.Matador.Rakefile.find(:lib)
9
9
  end
@@ -5,7 +5,7 @@ module Pina
5
5
  self.pkgdir = "phgx"
6
6
  self.subdir = "share/pina"
7
7
 
8
- Pina.claim Pina.root.find, :rake, Rbbt.share.install.Pina.Rakefile.find(:lib)
8
+ Pina.claim Pina.root, :rake, Rbbt.share.install.Pina.Rakefile.find(:lib)
9
9
  end
10
10
 
11
11
  if defined? Entity and defined? Gene and Entity === Gene
@@ -5,5 +5,5 @@ module STITCH
5
5
  self.pkgdir = "phgx"
6
6
  self.subdir = "share/stitch"
7
7
 
8
- STITCH.claim STITCH.root.find, :rake, Rbbt.share.install.STITCH.Rakefile.find(:lib)
8
+ STITCH.claim STITCH.root, :rake, Rbbt.share.install.STITCH.Rakefile.find(:lib)
9
9
  end
@@ -5,7 +5,7 @@ module STRING
5
5
  self.pkgdir = "phgx"
6
6
  self.subdir = "share/string"
7
7
 
8
- STRING.claim STRING.root.find, :rake, Rbbt.share.install.STRING.Rakefile.find(:lib)
8
+ STRING.claim STRING.root, :rake, Rbbt.share.install.STRING.Rakefile.find(:lib)
9
9
  end
10
10
 
11
11
  if defined? Entity and defined? Gene and Entity === Gene
@@ -0,0 +1,14 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
+ require 'rbbt/mutation/chasm'
3
+
4
+ class TestCHASM < Test::Unit::TestCase
5
+
6
+ def test_predict_aminoacid_mutation
7
+ sample_mutations = {
8
+ "Sample_1" => ["ENST00000531739:R641W"]
9
+
10
+ }
11
+ ddd CHASM.predict(sample_mutations, :cancertype => "Breast")
12
+ end
13
+ end
14
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-phgx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-21 00:00:00.000000000 Z
12
+ date: 2013-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rbbt-util
@@ -36,6 +36,7 @@ extra_rdoc_files:
36
36
  files:
37
37
  - LICENSE
38
38
  - lib/phgx.rb
39
+ - lib/rbbt/mutation/chasm.rb
39
40
  - lib/rbbt/mutation/fireDB.rb
40
41
  - lib/rbbt/mutation/mutation_assessor.rb
41
42
  - lib/rbbt/mutation/oncodriveFM.rb
@@ -67,17 +68,18 @@ files:
67
68
  - share/install/lib/rake_helper.rb
68
69
  - share/install/software/OncodriveFM
69
70
  - test/rbbt/sources/test_matador.rb
70
- - test/rbbt/sources/test_pharmagkb.rb
71
- - test/rbbt/sources/test_stitch.rb
72
71
  - test/rbbt/sources/test_cancer.rb
72
+ - test/rbbt/sources/test_stitch.rb
73
+ - test/rbbt/sources/test_pharmagkb.rb
73
74
  - test/rbbt/sources/test_kegg.rb
74
- - test/rbbt/mutation/test_snps_and_go.rb
75
- - test/rbbt/mutation/test_fireDB.rb
76
- - test/rbbt/mutation/test_sift.rb
77
- - test/rbbt/mutation/test_polyphen.rb
78
- - test/rbbt/mutation/test_mutation_assessor.rb
79
75
  - test/rbbt/mutation/test_oncodriveFM.rb
76
+ - test/rbbt/mutation/test_polyphen.rb
77
+ - test/rbbt/mutation/test_chasm.rb
78
+ - test/rbbt/mutation/test_sift.rb
80
79
  - test/rbbt/mutation/test_transFIC.rb
80
+ - test/rbbt/mutation/test_snps_and_go.rb
81
+ - test/rbbt/mutation/test_mutation_assessor.rb
82
+ - test/rbbt/mutation/test_fireDB.rb
81
83
  - test/test_helper.rb
82
84
  homepage: http://github.com/mikisvaz/rbbt-phgx
83
85
  licenses: []
@@ -105,15 +107,16 @@ specification_version: 3
105
107
  summary: Pharmaco-genomics for the Ruby Bioinformatics Toolkit (rbbt)
106
108
  test_files:
107
109
  - test/rbbt/sources/test_matador.rb
108
- - test/rbbt/sources/test_pharmagkb.rb
109
- - test/rbbt/sources/test_stitch.rb
110
110
  - test/rbbt/sources/test_cancer.rb
111
+ - test/rbbt/sources/test_stitch.rb
112
+ - test/rbbt/sources/test_pharmagkb.rb
111
113
  - test/rbbt/sources/test_kegg.rb
112
- - test/rbbt/mutation/test_snps_and_go.rb
113
- - test/rbbt/mutation/test_fireDB.rb
114
- - test/rbbt/mutation/test_sift.rb
115
- - test/rbbt/mutation/test_polyphen.rb
116
- - test/rbbt/mutation/test_mutation_assessor.rb
117
114
  - test/rbbt/mutation/test_oncodriveFM.rb
115
+ - test/rbbt/mutation/test_polyphen.rb
116
+ - test/rbbt/mutation/test_chasm.rb
117
+ - test/rbbt/mutation/test_sift.rb
118
118
  - test/rbbt/mutation/test_transFIC.rb
119
+ - test/rbbt/mutation/test_snps_and_go.rb
120
+ - test/rbbt/mutation/test_mutation_assessor.rb
121
+ - test/rbbt/mutation/test_fireDB.rb
119
122
  - test/test_helper.rb