gene_ontology 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: '03399bf5f91610a8fa66a1c410cf7366da691aad'
4
+ data.tar.gz: 561304a916e6839afba04eebba5cd02f27d5fa86
5
+ SHA512:
6
+ metadata.gz: ae6e94c568240a3550ff0779488d82e178d8e26711b0db1959f284bb774b786e7750f291de1faa34b41704faf1e93f5c38dbaa81ca9fd4db7d788636a48f1662
7
+ data.tar.gz: af7118dfb8b6921bfe24ed607e210b2c7e3b4c28b9611c600a92a7693572e9426c78578f9c52876a379b79cb676c3cf9ebd323755bed5c1c8d61a786e93aad23
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ go.obo
@@ -0,0 +1,55 @@
1
+ # GeneOntology
2
+
3
+ Parses gene ontology .obo files, links terms through `is_a` and provides
4
+ methods to find levels and traverse the tree.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'gene_ontology'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install gene_ontology
21
+
22
+ ## Usage
23
+
24
+ ```
25
+ require 'gene_ontology'
26
+
27
+ # download from http://purl.obolibrary.org/obo/go.obo
28
+ go = GeneOntology.from_file("go.obo")
29
+
30
+ go.header # => a GeneOntology::Header object
31
+ go.id_to_term # => a hash from GO id to the GeneOntology::Term
32
+
33
+ some_term = go.id_to_term.values.first
34
+
35
+ # traverse the tree upwards, beginning with the current Term
36
+ some_term.each do |term|
37
+ term.name =~ /Plasma Membrane/i
38
+ end
39
+ some_term.level # => how many levels down from the top 3
40
+ # molecular_function, biol comp. etc are level 0
41
+ ```
42
+
43
+ ## Testing
44
+
45
+ ```
46
+ rake test
47
+ ```
48
+
49
+ Note: will download http://purl.obolibrary.org/obo/go.obo to a tempfile unless
50
+ 'go.obo' is already in package root. Just for testing.
51
+
52
+ ## License
53
+
54
+ [MIT License](https://opensource.org/licenses/MIT) -- see LICENSE for
55
+ copyright info.
data/Rakefile CHANGED
@@ -1,46 +1,10 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
3
 
4
- require 'jeweler'
5
- Jeweler::Tasks.new do |gem|
6
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
7
- gem.name = "gene_ontology"
8
- gem.homepage = "http://github.com/princelab/gene_ontology"
9
- gem.license = "MIT"
10
- gem.summary = %Q{parses gene ontology (GO) .obo files and provides tree traversal methods}
11
- gem.description = %{Parses gene ontology (GO) .obo files, links terms through is_a and provides methods
12
- to find levels and traverse the tree.}
13
- gem.email = "jtprince@gmail.com"
14
- gem.authors = ["John T. Prince"]
15
- gem.add_development_dependency "spec-more", ">= 0"
16
- gem.add_development_dependency "bundler", "~> 1.0.0"
17
- gem.add_development_dependency "jeweler", "~> 1.5.2"
18
- gem.add_development_dependency "rcov", ">= 0"
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
19
8
  end
20
- Jeweler::RubygemsDotOrgTasks.new
21
9
 
22
- require 'rake/testtask'
23
- Rake::TestTask.new(:spec) do |spec|
24
- spec.libs << 'lib' << 'spec'
25
- spec.pattern = 'spec/**/*_spec.rb'
26
- spec.verbose = true
27
- end
28
-
29
- require 'rcov/rcovtask'
30
- Rcov::RcovTask.new do |spec|
31
- spec.libs << 'spec'
32
- spec.pattern = 'spec/**/*_spec.rb'
33
- spec.verbose = true
34
- end
35
-
36
- task :default => :spec
37
-
38
- require 'rake/rdoctask'
39
- Rake::RDocTask.new do |rdoc|
40
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
-
42
- rdoc.rdoc_dir = 'rdoc'
43
- rdoc.title = "gene_ontology #{version}"
44
- rdoc.rdoc_files.include('README*')
45
- rdoc.rdoc_files.include('lib/**/*.rb')
46
- end
10
+ task :default => :test
@@ -0,0 +1,27 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "gene_ontology/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gene_ontology"
8
+ spec.version = GeneOntology::VERSION
9
+ spec.authors = ["John T. Prince"]
10
+ spec.email = ["jtprince@gmail.com"]
11
+
12
+ spec.summary = %q{Parses gene ontology .obo files}
13
+ spec.description = %q{Parses gene ontology .obo files, links terms through `is_a` and provides methods to find levels and traverse the tree.}
14
+ spec.homepage = "https://github.com/princelab/gene_ontology"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.0"
27
+ end
@@ -1,12 +1,30 @@
1
+ require 'gene_ontology/version'
1
2
 
2
- # typical usage:
3
- #
4
- # terms = GeneOntology.new.from_file(filename)
5
3
  class GeneOntology
6
4
 
5
+ EXPECTED_HEADER_FIELDS = %i(
6
+ format-version
7
+ date
8
+ saved-by
9
+ auto-generated-by
10
+ synonymtypedef
11
+ systematic_synonym
12
+ default-namespace
13
+ remark
14
+ ontology
15
+ subsetdefs
16
+ other
17
+ )
18
+
7
19
  attr_accessor :header
8
20
  attr_accessor :id_to_term
9
21
 
22
+ class << self
23
+ def from_file(filename)
24
+ new.from_file(filename)
25
+ end
26
+ end
27
+
10
28
  # returns self
11
29
  def from_file(filename)
12
30
  File.open(filename) do |io|
@@ -35,7 +53,7 @@ class GeneOntology
35
53
  # turns is_a links from strings to actual GeneOntology objects
36
54
  # returns id_to_term
37
55
  def self.link!(terms)
38
- id_to_term = {}
56
+ id_to_term = {}
39
57
  terms.each {|term| id_to_term[term.id] = term }
40
58
  terms.each do |term|
41
59
  term.is_a.map! {|id| id_to_term[id] }
@@ -74,12 +92,36 @@ class GeneOntology
74
92
  # process...)
75
93
  class Term
76
94
  include Enumerable
77
- attr_accessor *%w(id level alt_id intersection_of replaced_by created_by creation_date disjoint_from relationship name namespace def subset comment is_obsolete synonym xref consider is_a).map(&:to_sym)
95
+
96
+ FIELDS = %i(
97
+ id
98
+ level
99
+ alt_id
100
+ intersection_of
101
+ replaced_by
102
+ created_by
103
+ creation_date
104
+ disjoint_from
105
+ relationship
106
+ name
107
+ namespace
108
+ def
109
+ subset
110
+ comment
111
+ is_obsolete
112
+ synonym
113
+ xref
114
+ consider
115
+ is_a
116
+ property_value
117
+ )
118
+
119
+ attr_accessor(*FIELDS)
78
120
 
79
121
  PLURAL = [:synonym, :xref, :consider, :is_a]
80
122
  def initialize
81
123
  PLURAL.each {|k| self.send("#{k}=", []) }
82
- self
124
+ @level = nil
83
125
  end
84
126
 
85
127
  def inspect
@@ -89,7 +131,7 @@ class GeneOntology
89
131
  # starting with that term, traverses upwards in the tree
90
132
  def each(&block)
91
133
  block.call(self)
92
- is_a.each do |term|
134
+ is_a.each do |term|
93
135
  term.each(&block)
94
136
  end
95
137
  end
@@ -108,9 +150,10 @@ class GeneOntology
108
150
  # returns the number of levels below the top (top 3 categories [mf, bp,
109
151
  # cc] are at level 0)
110
152
  def find_level
111
- if @level ; @level
153
+ if @level
154
+ @level
112
155
  else
113
- @level =
156
+ @level =
114
157
  if @is_a.size == 0 ; 0
115
158
  else
116
159
  @is_a.map {|term| term.find_level }.min + 1
@@ -121,7 +164,7 @@ class GeneOntology
121
164
 
122
165
  # subsetdefs is an array, other is a hash for any key/value pairs not
123
166
  # already defined here
124
- Header = Struct.new( *%w(format-version date saved-by auto-generated-by synonymtypedef systematic_synonym default-namespace remark ontology subsetdefs other).map(&:to_sym) )
167
+ Header = Struct.new(*EXPECTED_HEADER_FIELDS)
125
168
  class Header
126
169
  def initialize(*args)
127
170
  super(*args)
@@ -0,0 +1,3 @@
1
+ class GeneOntology
2
+ VERSION = "0.1.1"
3
+ end
metadata CHANGED
@@ -1,110 +1,95 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gene_ontology
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - John T. Prince
9
8
  autorequire:
10
- bindir: bin
9
+ bindir: exe
11
10
  cert_chain: []
12
-
13
- date: 2011-05-24 00:00:00 -06:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: spec-more
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "0"
25
- type: :development
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
11
+ date: 2017-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
- prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
33
- - - ~>
34
- - !ruby/object:Gem::Version
35
- version: 1.0.0
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
36
20
  type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: jeweler
40
21
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ~>
45
- - !ruby/object:Gem::Version
46
- version: 1.5.2
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
47
34
  type: :development
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: rcov
51
35
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
58
48
  type: :development
59
- version_requirements: *id004
60
- description: |-
61
- Parses gene ontology (GO) .obo files, links terms through is_a and provides methods
62
- to find levels and traverse the tree.
63
- email: jtprince@gmail.com
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: Parses gene ontology .obo files, links terms through `is_a` and provides
56
+ methods to find levels and traverse the tree.
57
+ email:
58
+ - jtprince@gmail.com
64
59
  executables: []
65
-
66
60
  extensions: []
67
-
68
- extra_rdoc_files:
69
- - LICENSE
70
- - README.rdoc
71
- files:
72
- - .document
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".document"
64
+ - ".gitignore"
73
65
  - LICENSE
74
- - README.rdoc
66
+ - README.md
75
67
  - Rakefile
76
- - VERSION
68
+ - gene_ontology.gemspec
77
69
  - lib/gene_ontology.rb
78
- - spec/gene_ontology_spec.rb
79
- - spec/spec_helper.rb
80
- has_rdoc: true
81
- homepage: http://github.com/princelab/gene_ontology
82
- licenses:
70
+ - lib/gene_ontology/version.rb
71
+ homepage: https://github.com/princelab/gene_ontology
72
+ licenses:
83
73
  - MIT
74
+ metadata: {}
84
75
  post_install_message:
85
76
  rdoc_options: []
86
-
87
- require_paths:
77
+ require_paths:
88
78
  - lib
89
- required_ruby_version: !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
92
81
  - - ">="
93
- - !ruby/object:Gem::Version
94
- version: "0"
95
- required_rubygems_version: !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
98
86
  - - ">="
99
- - !ruby/object:Gem::Version
100
- version: "0"
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
101
89
  requirements: []
102
-
103
90
  rubyforge_project:
104
- rubygems_version: 1.6.2
91
+ rubygems_version: 2.6.11
105
92
  signing_key:
106
- specification_version: 3
107
- summary: parses gene ontology (GO) .obo files and provides tree traversal methods
108
- test_files:
109
- - spec/gene_ontology_spec.rb
110
- - spec/spec_helper.rb
93
+ specification_version: 4
94
+ summary: Parses gene ontology .obo files
95
+ test_files: []
@@ -1,23 +0,0 @@
1
- = gene_ontology
2
-
3
- Parses gene ontology .obo files, links terms through is_a and provides methods
4
- to find levels and traverse the tree.
5
-
6
- == Examples
7
-
8
- go = GeneOntology.new.from_file("gene_ontology.obo")
9
- go.header # => a GeneOntology::Header object
10
- go.id_to_term # => a hash from GO id to the GeneOntology::Term
11
- some_term = go.id_to_term.values.first
12
-
13
- # traverse the tree upwards, beginning with the current Term
14
- some_term.each do |term|
15
- term.name =~ /Plasma Membrane/i
16
- end
17
- some_term.level # => how many levels down from the top 3
18
- # molecular_function, biol comp. etc are level 0
19
-
20
- == Copyright
21
-
22
- See LICENSE
23
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.1
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "GeneOntology" do
4
- it "fails" do
5
- should.flunk "hey buddy, you should probably rename this file and start specing for real"
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- require 'rubygems'
2
- require 'bacon'
3
-
4
- $LOAD_PATH.unshift(File.dirname(__FILE__))
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- require 'gene_ontology'
7
-
8
- Bacon.summary_on_exit