sylfy 0.0.1 → 0.0.2

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: fec1ae6720ecca288865a0c0a8bd253d2f481bf6
4
- data.tar.gz: ada91cc532a9db9407b92de2faa0ff5d86dbfbc6
3
+ metadata.gz: cd2c538ef9a50e980f048613f58adc04c6d74a32
4
+ data.tar.gz: fbf52a043c05cec06323f1283e391e42aaea7ef5
5
5
  SHA512:
6
- metadata.gz: 16e08840e6475b057133c99368088934ec175c346ec9f7cd48116dacd1bafd1c053c686305c7cd2e9ea3a1403170daf33ad17ca19b2b134020b0f0a0c11824f9
7
- data.tar.gz: 83b3160f785c137fa7c76bbefb0b923f9fbfd823a3a1af6592a9996c9a552d65a3d0234b1708711b3c11400f07d9af8b46eda7d3b845e742fc5c78df0785552b
6
+ metadata.gz: 574c26d637131356a91c70420285bea69ce79ae1259a5769e158a972225e0a6431ef9d4aae57f4bc74dab2ad3dd02b333f065aab442d28735aa9c9c419a12490
7
+ data.tar.gz: c6c5f9cc4c6c59b72027bd30a6d2edc2281a6646ca5ad62969ffe0785f27a969ba6b591c7095a48a3ccc70f9dac978631413e441ef5d8ab96a869bf66fd8f07c
@@ -0,0 +1,62 @@
1
+ #
2
+ # UniSysDB library in Ruby
3
+ # Copyright (C) 2012
4
+ #
5
+ # @author Natapol Pornputtapong <natapol@chalmers.se>
6
+ #
7
+
8
+ module Sylfy
9
+
10
+ module Service
11
+
12
+ module KEGGREST
13
+
14
+ module_function
15
+
16
+ def conv(id, targetdb = nil)
17
+
18
+ help = %Q(
19
+ help: conv(id, targetdb = nil)
20
+ help:
21
+ help:
22
+ help: targetdb = <database>
23
+ help: For gene identifiers:
24
+ help: <kegg_db> = <org>
25
+ help: <org> = KEGG organism code or T number
26
+ help: <outside_db> = ncbi-gi | ncbi-geneid | uniprot
27
+ help:
28
+ help: For chemical substance identifiers:
29
+ help: <kegg_db> = drug | compound | glycan
30
+ help: <outside_db> = pubchem | chebi
31
+ help:
32
+ help: return a Hash
33
+ )
34
+ if id == :help
35
+ puts help
36
+ return {}
37
+ else
38
+
39
+ begin
40
+ doc = URI.parse("#{@@baseuri}/conv/#{targetdb}/#{id}").read().strip()
41
+ result = {}
42
+
43
+ doc.split(/\n/).each do |line|
44
+ dat = line.chomp.split(/\t/)
45
+ result[dat[0]] = [] if !result.has_key?(dat[0])
46
+ result[dat[0]].push(dat[1])
47
+ end
48
+
49
+ return result
50
+
51
+ rescue OpenURI::HTTPError
52
+ raise Sylfy::Service::DataNotFound, "Query not found."
53
+ end
54
+
55
+ end
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+
62
+ end
@@ -0,0 +1,89 @@
1
+ #
2
+ # UniSysDB library in Ruby
3
+ # Copyright (C) 2012
4
+ #
5
+ # @author Natapol Pornputtapong <natapol@chalmers.se>
6
+ #
7
+
8
+ module Sylfy
9
+
10
+ module Service
11
+
12
+ module KEGGREST
13
+
14
+ module_function
15
+ # Method for setting inchi data member
16
+ #
17
+ # == Parameters:
18
+ # inchi::
19
+ # input inchi string
20
+ def find(database, query=nil, option=nil)
21
+
22
+ help = "
23
+ help: find(database, query, option=nil)
24
+ help:
25
+ help: type#1
26
+ help:
27
+ help: database = <database>
28
+ help: <database> = pathway | module | disease | drug | environ | ko | genome |
29
+ help: <org> | compound | glycan | reaction | rpair | rclass | enzyme |
30
+ help: genes | ligand
31
+ help: <org> = KEGG organism code or T number
32
+ help:
33
+ help: <option> = formula | exact_mass | mol_weight only for <database> = compound | drug
34
+ help:
35
+ help: return a List
36
+ "
37
+
38
+ result_tag = {
39
+ :pathway => [:NAME],
40
+ :module => [:NAME],
41
+ :disease => [:NAME],
42
+ :drug => [:NAME],
43
+ :environ => [:NAME],
44
+ :ko => [:NAME, :DEFINITION],
45
+ :genome => [:NAME, :DEFINITION],
46
+ :compound => [:NAME],
47
+ :glycan => [:NAME, :COMPOSITION, :CLASS],
48
+ :reaction => [:NAME, :DEFINITION],
49
+ :rpair => [:NAME],
50
+ :rclass => [:NAME, :DEFINITION],
51
+ :enzyme => [:NAME]
52
+ }
53
+ result_tag.default = [:NAME, :DEFINITION, :ORTHOLOGY]
54
+ result = {}
55
+ if database == :help
56
+ puts help
57
+ return result
58
+ else
59
+ begin
60
+ if ['compound', 'drug'].include?(database.to_s) && option != nil &&
61
+ ['formula', 'exact_mass' 'mol_weight'].include?(option.to_s)
62
+ URI.parse("#{@@baseuri}/find/#{database}/#{query}/#{option}").read().strip().each do |line|
63
+ dat = line.chomp.split(/\t/)
64
+ result[dat[0]] = { option.to_sym => dat[1]}
65
+ end
66
+ else
67
+ URI.parse("#{@@baseuri}/find/#{database}/#{query}").read().strip().each do |line|
68
+ dat = line.chomp.split(/\t/)
69
+ result[dat[0]] = {}
70
+ info = dat[1].split('; ')
71
+ info.each_index {|ind| result[dat[0]][result_tag[database.to_sym][ind]] = info[ind]}
72
+ end
73
+ end
74
+
75
+ return result
76
+ rescue OpenURI::HTTPError
77
+ raise Unisys::ServiceException, "Query not found."
78
+ end
79
+
80
+ end
81
+
82
+ end
83
+
84
+ end
85
+
86
+ end
87
+
88
+ end
89
+
@@ -0,0 +1,61 @@
1
+ #
2
+ # UniSysDB library in Ruby
3
+ # Copyright (C) 2012
4
+ #
5
+ # @author Natapol Pornputtapong <natapol@chalmers.se>
6
+ #
7
+
8
+ module Sylfy
9
+
10
+ module Service
11
+
12
+ module KEGGREST
13
+
14
+ module_function
15
+ # Method for setting inchi data member
16
+ #
17
+ # == Parameters:
18
+ # inchi::
19
+ # input inchi string
20
+ def link(id, targetdb = nil)
21
+
22
+ help = "
23
+ help: link(id, targetdb = nil)
24
+ help:
25
+ help: targetdb = pathway | brite | module | disease | drug | environ | ko | genome | <org> | compound | glycan | reaction | rpair | rclass | enzyme
26
+ help:
27
+ help: id = KEGG database entries involving the following databases: pathway | brite | module | disease | drug | environ | ko | genome |
28
+ help: <org> | compound | glycan | reaction | rpair | rclass | enzyme
29
+ help: <org> = KEGG organism code or T number
30
+ help:
31
+ help: <option> = aaseq | ntseq | mol | kcf | image
32
+ "
33
+ if id == :help
34
+ puts help
35
+ return {}
36
+ else
37
+
38
+ begin
39
+ doc = URI.parse("#{@@baseuri}/link/#{targetdb}/#{id}").read().strip()
40
+ result = {}
41
+
42
+ doc.each do |line|
43
+ dat = line.chomp.split(/\t/)
44
+ result[dat[0]] = result.has_key?(dat[0]) ? result[dat[0]].push(dat[1]) : [dat[1]]
45
+ end
46
+
47
+ return result
48
+ rescue OpenURI::HTTPError
49
+ raise Sylfy::Service::DataNotFound, "Query not found."
50
+ end
51
+
52
+
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,72 @@
1
+ #
2
+ # UniSysDB library in Ruby
3
+ # Copyright (C) 2012
4
+ #
5
+ # @author Natapol Pornputtapong <natapol@chalmers.se>
6
+ #
7
+
8
+ module Sylfy
9
+
10
+ module Service
11
+
12
+ module KEGGREST
13
+
14
+ module_function
15
+
16
+ def list(param)
17
+
18
+ help = %Q(
19
+ help: list(param)
20
+ help:
21
+ help: type#1
22
+ help:
23
+ help: param = \"<database>\"
24
+ help: <database> = pathway | brite | module | disease | drug | environ | ko | genome |
25
+ help: <org> | compound | glycan | reaction | rpair | rclass | enzyme | organism
26
+ help:
27
+ help: <org> = KEGG organism code or T number
28
+ help:
29
+ help:
30
+ help: type#2
31
+ help:
32
+ help: param = \"<database>/<org>\"
33
+ help: <database> = pathway | module
34
+ help: <org> = KEGG organism code
35
+ help:
36
+ help: type#3
37
+ help:
38
+ help: param = \"<dbentries>\"
39
+ help: <dbentries> = KEGG database entries involving the following databases: pathway | brite | module | disease | drug | environ | ko | genome |
40
+ help: <org> | compound | glycan | reaction | rpair | rclass | enzyme | organism
41
+ help:
42
+ help: return a List
43
+ )
44
+
45
+ if param == :help
46
+ puts help
47
+ return {}
48
+ else
49
+
50
+ begin
51
+ doc = URI.parse("#{@@baseuri}/list/#{param.to_s}").read().strip()
52
+ result = {}
53
+
54
+ doc.each do |line|
55
+ dat = line.chomp.split(/\t/, 2)
56
+ result[dat[0]] = dat[1]
57
+ end
58
+
59
+ return result
60
+ rescue OpenURI::HTTPError
61
+ raise Sylfy::Service::DataNotFound, "Data not found."
62
+ end
63
+
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+ end
70
+
71
+ end
72
+
@@ -0,0 +1,130 @@
1
+ #
2
+ # UniSysDB library in Ruby
3
+ # Copyright (C) 2012
4
+ #
5
+ # @author Natapol Pornputtapong <natapol@chalmers.se>
6
+ #
7
+ require 'open-uri'
8
+ require 'net/http'
9
+ require 'rexml/document'
10
+
11
+ module Unisys
12
+
13
+ module Service
14
+
15
+ module RESTKegg
16
+
17
+ module_function
18
+
19
+ def get(id, option = nil)
20
+
21
+ help = "
22
+ help: get(id, targetdb = nil)
23
+ help:
24
+ help: <dbentries> = KEGG database entries involving the following databases: pathway | brite | module | disease | drug | environ | ko | genome |
25
+ help: <org> | compound | glycan | reaction | rpair | rclass | enzyme
26
+ help: <org> = KEGG organism code or T number
27
+ help:
28
+ help: <option> = aaseq | ntseq | mol | kcf | image
29
+ "
30
+ if id == :help
31
+ puts help
32
+ return []
33
+ else
34
+
35
+ if option != nil && ['aaseq', 'ntseq', 'mol', 'kcf', 'image'].include?(option.to_s)
36
+ text = "#{id}/#{option}"
37
+ else
38
+ text = "#{id}"
39
+ end
40
+
41
+ begin
42
+ doc = URI.parse("#{@@baseuri}/get/#{text}").read().strip()
43
+
44
+ rescue OpenURI::HTTPError
45
+ raise Unisys::ServiceException, "Query not found."
46
+ end
47
+
48
+ doc = "\n\n\n#{doc}" if option != nil && option.to_sym == :mol
49
+
50
+ return doc
51
+ end
52
+
53
+ end
54
+
55
+ def getSmallMolecule(id)
56
+ #:id, :dataPrimarySource, :xrefs, :relations :inchi, :formula, :smiles, :inchiKey :names :relatype :terminal
57
+ doc = get(id)
58
+
59
+ rel_conv = {"Same as" => 'obo.internal:is_a'}
60
+ ref_conv = {"PubChem:" => "urn:miriam:pubchem.substance:", "ChEBI:" => "urn:miriam:obo.chebi:", "CAS:" => "urn:miriam:cas:", "3DMET:" => "urn:miriam:3dmet:", "KNApSAcK:" => "urn:miriam:knapsack:", "PDB-CCD:" => "urn:miriam:pdb-ccd:", "DrugBank:" => "urn:miriam:drugbank:", "LIPIDMAPS:" => "urn:miriam:lipidmaps:", "LipidBank:" => "urn:miriam:lipidbank:", "GlycomeDB:" => "urn:miriam:glycomedb:" }
61
+
62
+ result = {}
63
+ result[:names] = []
64
+ result[:xrefs] = []
65
+ result[:relations] = []
66
+
67
+ field = ""
68
+ content = ""
69
+ doc.split(/\n/).each do |line|
70
+
71
+ if line =~ /^(\p{Upper}+) +(.*)/
72
+ field = $1.to_sym
73
+ content = $2.chomp
74
+ elsif line =~ /^ +(.*)/
75
+ content = $1.chomp
76
+ end
77
+
78
+ case field
79
+ when :ENTRY
80
+ dat = content.split(/ +/)
81
+ result[:dataPrimarySource] = "#{Unisys::kegg_miriam[dat[0][0]]}:#{dat[0]}"
82
+ when :NAME
83
+ result[:names].push(content[0..-2])
84
+ when :FORMULA
85
+ result[:formula] = content
86
+ when :COMPOSITION
87
+ result[:formula] = content
88
+ when :MASS
89
+
90
+ when :CLASS
91
+
92
+ when :REMARK
93
+ dat = content.split(/: /)
94
+
95
+ result[:relations].push({:relatype => rel_conv[dat[0]]}, :terminal => "#{Unisys::kegg_miriam[dat[1][0]]}:#{dat[1]}")
96
+ when :REFERENCE
97
+
98
+
99
+ when :REACTION
100
+
101
+ when :PATHWAY
102
+
103
+ when :ENZYME
104
+
105
+ when :ORTHOLOGY
106
+
107
+ when :DBLINKS
108
+ dat = content.split(/ /)
109
+ if ref_conv.has_key?(dat[0])
110
+ dat[1..-1].each do |item|
111
+ result[:xrefs].push("#{ref_conv[dat[0]]}#{item}")
112
+ end
113
+ end
114
+ when :NODE
115
+
116
+ when :EDGE
117
+
118
+ end
119
+
120
+ #result.push(line.chomp.split(/\t/))
121
+ end
122
+
123
+ return result
124
+ end
125
+
126
+ end
127
+
128
+ end
129
+
130
+ end
@@ -0,0 +1,50 @@
1
+ #
2
+ # UniSysDB library in Ruby
3
+ # Copyright (C) 2012
4
+ #
5
+ # @author Natapol Pornputtapong <natapol@chalmers.se>
6
+ #
7
+ require 'open-uri'
8
+ require 'net/http'
9
+ require 'rexml/document'
10
+
11
+
12
+ require 'sylfy/service/keggrest/conv'
13
+ require 'sylfy/service/keggrest/find'
14
+ require 'sylfy/service/keggrest/link'
15
+ require 'sylfy/service/keggrest/list'
16
+
17
+ module Sylfy
18
+
19
+ module Service
20
+
21
+
22
+ # http://rest.kegg.jp/<operation>/<argument>/<argument2 or option>
23
+ # <operation> = info | list | find | get | conv | link
24
+ # <argument> = <database> | <dbentries>
25
+
26
+ module KEGGREST
27
+
28
+ @@baseuri = "http://rest.kegg.jp"
29
+
30
+ @@db = [:pathway, :brite, :module, :disease, :drug, :environ,
31
+ :ko, :genome, :compound, :glycan, :reaction, :rpair,
32
+ :rclass, :enzyme, :genomes, :genes, :ligand, :kegg, :organism]
33
+
34
+ module_function
35
+
36
+
37
+ end
38
+
39
+ end
40
+ end
41
+
42
+ #require '../unisys.rb'
43
+
44
+ #p Unisys::Service::RESTKegg.list('hsa:10458+ece:Z5100')
45
+ #p Unisys::Service::RESTKegg.find(:genes, 'shiga+toxin')
46
+ #p Unisys::Service::RESTKegg.conv('hsa:10458+ece:Z5100','ncbi-gi')
47
+ #p Unisys::Service::RESTKegg.get(:G00092)
48
+ #Unisys::Service::RESTKegg.getSmallMolecule(:G00092)
49
+ #p Unisys::Service::RESTKegg.link('hsa:10458+ece:Z5100', 'pathway')
50
+
data/lib/sylfy/version.rb CHANGED
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Sylfy
11
- VERSION = "0.0.1"
11
+ VERSION = "0.0.2"
12
12
  end
data/sylfy.gemspec CHANGED
@@ -8,15 +8,15 @@ Gem::Specification.new do |s|
8
8
  s.date = '2010-04-28'
9
9
  s.platform = Gem::Platform::RUBY
10
10
 
11
- s.summary = ""
12
- s.description = "A simple hello world gem"
11
+ s.summary = "Provides some useful functions for systems biology field."
12
+ s.description = "Systems Biology Library for Ruby"
13
13
  s.authors = ["Natapol Pornputtapong"]
14
14
  s.email = 'natapol.por@gmail.com'
15
15
 
16
- s.homepage = 'http://rubygems.org/gems/hola'
16
+ s.homepage = 'http://rubygems.org/gems/sylfy'
17
17
  s.license = 'GPL'
18
18
 
19
- s.rubyforge_project = "neography"
19
+ # s.rubyforge_project = "neography"
20
20
 
21
21
  s.files = `git ls-files`.split("\n")
22
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.require_paths = ["lib"]
25
25
 
26
26
  s.add_dependency "gsl", ">= 1.15.3"
27
+ s.add_dependency "bio", ">= 1.4.3.0001"
27
28
 
28
29
  # s.add_development_dependency "rspec", ">= 2.11"
29
30
  # s.add_development_dependency "net-http-spy", "0.2.1"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sylfy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Natapol Pornputtapong
@@ -24,7 +24,21 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.15.3
27
- description: A simple hello world gem
27
+ - !ruby/object:Gem::Dependency
28
+ name: bio
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.4.3.0001
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.4.3.0001
41
+ description: Systems Biology Library for Ruby
28
42
  email: natapol.por@gmail.com
29
43
  executables: []
30
44
  extensions: []
@@ -33,9 +47,15 @@ files:
33
47
  - README.md
34
48
  - lib/sylfy.rb
35
49
  - lib/sylfy/math.rb
50
+ - lib/sylfy/service/keggrest.rb
51
+ - lib/sylfy/service/keggrest/conv.rb
52
+ - lib/sylfy/service/keggrest/find.rb
53
+ - lib/sylfy/service/keggrest/link.rb
54
+ - lib/sylfy/service/keggrest/list.rb
55
+ - lib/sylfy/service/keggrest/restKegg_get.rb
36
56
  - lib/sylfy/version.rb
37
57
  - sylfy.gemspec
38
- homepage: http://rubygems.org/gems/hola
58
+ homepage: http://rubygems.org/gems/sylfy
39
59
  licenses:
40
60
  - GPL
41
61
  metadata: {}
@@ -54,9 +74,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
74
  - !ruby/object:Gem::Version
55
75
  version: '0'
56
76
  requirements: []
57
- rubyforge_project: neography
77
+ rubyforge_project:
58
78
  rubygems_version: 2.0.3
59
79
  signing_key:
60
80
  specification_version: 4
61
- summary: ''
81
+ summary: Provides some useful functions for systems biology field.
62
82
  test_files: []