biocgem 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3bb2dd871af18123ded73f2f5eb4c8f8fce68722d0c8dca21d5246d22bc5b21f
4
+ data.tar.gz: '0659120b0aa7381b4aa4420768934713e88ba50ba7d5fd2e340a5623e187367a'
5
+ SHA512:
6
+ metadata.gz: aadd3f626d4e64d7c370ed2bbd55b04e63327739ca9ba27826a494a23bd9ee375b48688177a95baa160112a2713b8850df489dce4882cef540028f1c35817dd0
7
+ data.tar.gz: 9d80f99b0f415642c5edf841d18384d23545077551c10bd9927cff4baf2efa38e398d49823cec8a9fcf4152d9759ae5bc465c973639a30dbaac20051534a2301
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 kojix2
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # BiocGem
2
+
3
+ [![test](https://github.com/ruby-on-bioc/biocgem/actions/workflows/ci.yml/badge.svg)](https://github.com/ruby-on-bioc/biocgem/actions/workflows/ci.yml)
4
+
5
+ Extract the database included in the Bioconductor annotation package and use it in the Ruby gem.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ gem install biocgem
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### 1.Generate your gem
16
+
17
+ Short options
18
+
19
+ ```
20
+ biocgem new \
21
+ -n org.Hs.eg.db \
22
+ -s org.Hs.eg.sqlite \
23
+ -v 3.14.0
24
+ ```
25
+
26
+ Full options
27
+
28
+ ```sh
29
+ biocgem new --bioc_package_name org.Mm.eg.db \
30
+ --bioc_sqlite_database_name org.Mm.eg.sqlite \
31
+ --gem_icon :mouse: \
32
+ --gem_constant_name OrgMmEgDb \
33
+ --gem_require_name org_mm_eg_db \
34
+ --bioc_package_sha256sum 56f228448b50f1cea0fc15d6f61b1e94359ef885336034bf346693315390ad45 \
35
+ --bioc_version 3.14 \
36
+ --bioc_package_version 3.14.0
37
+ ```
38
+
39
+ ### 2. Install your gem
40
+
41
+ ```
42
+ cd org.Hs.eg.db
43
+ rake extdata:download
44
+ # rake test
45
+ rake install
46
+ ```
47
+
48
+ ## Development
49
+
50
+ With all due respect to the R language and Bioconductor maintainers...
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-on-bioc/biocgem.
55
+
56
+ ## License
57
+
58
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/exe/biocgem ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bioc_gem"
4
+
5
+ BiocGem::Command.new.run
@@ -0,0 +1,46 @@
1
+ require "erb"
2
+ require "fileutils"
3
+ require "tmpdir"
4
+ require_relative "parser"
5
+
6
+ module BiocGem
7
+ class Command
8
+ attr_accessor :parser
9
+
10
+ def initialize(argv = ARGV)
11
+ @argv = argv
12
+ @parser = Parser.new
13
+ end
14
+
15
+ def run
16
+ parser.parse_options(@argv)
17
+
18
+ pp config = parser.options.to_h
19
+
20
+ target = config[:bioc_package_name]
21
+
22
+ base = File.expand_path("../../template/newgem", __dir__)
23
+
24
+ Dir.mktmpdir do |tmpdir|
25
+ Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |f|
26
+ src = File.expand_path(f, base)
27
+ next unless File.file?(src)
28
+
29
+ warn " - #{f}"
30
+
31
+ str = File.read(src)
32
+ erb = ERB.new(str)
33
+ str = erb.result(binding)
34
+
35
+ trg = File.expand_path(f, tmpdir)
36
+ fname = File.basename(trg, ".tt")
37
+ fname.gsub!("new_gem_entry", config[:gem_require_name])
38
+ dirname = File.dirname(trg)
39
+ FileUtils.mkdir_p(dirname)
40
+ File.write(File.join(dirname, fname), str)
41
+ end
42
+ FileUtils.cp_r(tmpdir, target)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,12 @@
1
+ module BiocGem
2
+ Options = Struct.new(
3
+ :bioc_package_name,
4
+ :bioc_sqlite_database_name,
5
+ :gem_icon,
6
+ :gem_constant_name,
7
+ :gem_require_name,
8
+ :bioc_package_sha256sum,
9
+ :bioc_version,
10
+ :bioc_package_version
11
+ )
12
+ end
@@ -0,0 +1,62 @@
1
+ require "optparse"
2
+ require_relative "options"
3
+
4
+ module BiocGem
5
+ class Parser
6
+ attr_reader :command, :options
7
+
8
+ def initialize
9
+ @comand = nil
10
+
11
+ @options = Options.new
12
+ end
13
+
14
+ def parse_options(args = ARGV)
15
+ @command = args.shift&.to_sym
16
+
17
+ return if @command != :new
18
+
19
+ opt_parser = OptionParser.new do |parser|
20
+ parser.banner = "Usage: biocgem new [options]"
21
+
22
+ parser.on("-n", "--bioc_package_name VAL", "e.g. org.Hs.eg.db") do |v|
23
+ options[:bioc_package_name] = v
24
+ end
25
+ parser.on("-s", "--bioc_sqlite_database_name VAL", "e.g. org.Hs.eg.sqlite") do |v|
26
+ options[:bioc_sqlite_database_name] = v
27
+ end
28
+ parser.on("--gem_icon [VAL]", "e.g. :family:") do |v|
29
+ options[:gem_icon] = v
30
+ end
31
+ parser.on("--gem_constant_name [VAL]", "e.g. OrgHsEgDb") do |v|
32
+ options[:gem_constant_name] = v
33
+ end
34
+ parser.on("--gem_require_name [VAL]", "e.g. org_hs_eg_db") do |v|
35
+ options[:gem_require_name] = v
36
+ end
37
+ parser.on("--bioc_package_sha256sum [VAL]", "e.g. ") do |v|
38
+ options[:bioc_package_sha256sum] = v
39
+ end
40
+ parser.on("-v", "--bioc_version [VAL]", "e.g. 3.14") do |v|
41
+ options[:bioc_version] = v
42
+ end
43
+ parser.on("--bioc_package_version VAL", "e.g. 3.14.0") do |v|
44
+ options[:bioc_package_version] = v
45
+ end
46
+ end
47
+
48
+ opt_parser.parse!(args)
49
+
50
+ options.gem_icon = ":notes:" if options.gem_icon.nil?
51
+ if options.gem_constant_name.nil?
52
+ options.gem_constant_name = options.bioc_package_name.split(".").map(&:capitalize).join
53
+ end
54
+ if options.gem_require_name.nil?
55
+ options.gem_require_name = options.bioc_package_name.split(".").map(&:downcase).join("_")
56
+ end
57
+ options.bioc_version = "release" if options.bioc_version.nil?
58
+
59
+ options
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BiocGem
4
+ VERSION = "0.0.1"
5
+ end
data/lib/bioc_gem.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "bioc_gem/version"
4
+ require_relative "bioc_gem/command"
5
+
6
+ module BiocGem
7
+ end
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /extdata/
10
+ *.lock
11
+ *.sqlite
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in <%= config[:gem_constant_name] %>.gemspec
6
+ gemspec
7
+
8
+ gem 'rake'
9
+
10
+ gem 'test-unit'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Ruby on Bioc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ # <%= config[:bioc_package_name] %>
2
+
3
+ [![build](https://github.com/ruby-on-bioc/<%= config[:bioc_package_name] %>/actions/workflows/ci.yml/badge.svg)](https://github.com/ruby-on-bioc/<%= config[:bioc_package_name] %>/actions/workflows/ci.yml)
4
+
5
+ <%= config[:gem_icon] %> [<%= config[:bioc_package_name] %>](https://bioconductor.org/packages/<%= config[:bioc_package_name] %>/) - for Ruby
6
+
7
+ ## Installation
8
+
9
+ ```
10
+ git clone https://github.com/ruby-on-bioc/<%= config[:bioc_package_name] %>
11
+ cd <%= config[:bioc_package_name] %>
12
+ rake extdata:download
13
+ rake install
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```ruby
19
+ require '<%= config[:gem_require_name] %>'
20
+
21
+ <%= config[:gem_constant_name] %>.class # Sequel::SQLite::Database
22
+ <%= config[:gem_constant_name] %>.tables
23
+ ```
24
+
25
+ See [Sequel](https://github.com/jeremyevans/sequel) for more details.
26
+
27
+ ## Development
28
+
29
+ With all due respect to the R language and Bioconductor maintainers...
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-on-bioc/<%= config[:gem_constant_name] %>.
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ # ensure extdata files exist
13
+ task :ensure_extdata do
14
+ [bioc_sqlite_database_name, "DESCRIPTION"].each do |file|
15
+ raise "Missing file: #{file}" unless File.exist?("extdata/#{file}")
16
+ end
17
+ end
18
+
19
+ Rake::Task["build"].enhance [:ensure_extdata]
20
+
21
+ task default: :test
22
+
23
+ def bioc_version
24
+ "<%= config[:bioc_version] %>"
25
+ end
26
+
27
+ def bioc_sqlite_database_name
28
+ "<%= config[:bioc_sqlite_database_name] %>"
29
+ end
30
+
31
+ def bioc_package_name
32
+ "<%= config[:bioc_package_name] %>"
33
+ end
34
+
35
+ def bioc_package_version
36
+ "<%= config[:bioc_package_version] %>"
37
+ end
38
+
39
+ def bioc_package_sha256sum
40
+ sha256 = "<%= config[:bioc_package_sha256sum] %>"
41
+ sha256 == "" ? nil : sha256
42
+ end
43
+
44
+ def bioc_package_file_name
45
+ "#{bioc_package_name}_#{bioc_package_version}.tar.gz"
46
+ end
47
+
48
+ def download_annotation(database, src, file, sha256)
49
+ require "fileutils"
50
+ require "open-uri"
51
+ require "tmpdir"
52
+
53
+ url = "https://bioconductor.org/packages/#{bioc_version}/data/annotation/src/contrib/#{file}"
54
+ puts "Downloading #{url}"
55
+ contents = URI.open(url).read
56
+
57
+ if sha256
58
+ computed_sha256 = Digest::SHA256.hexdigest(contents)
59
+ raise "Bad hash: #{computed_sha256}" if computed_sha256 != sha256
60
+ end
61
+
62
+ Dir.chdir(Dir.mktmpdir) do
63
+ File.binwrite(file, contents)
64
+ command = "tar xf"
65
+ system "#{command} #{file}"
66
+ dest = File.expand_path("extdata", __dir__)
67
+
68
+ FileUtils.mkdir_p(dest)
69
+
70
+ FileUtils.cp("#{src}/inst/extdata/#{database}", "#{dest}/#{database}")
71
+ puts "Saved extdata/#{database}"
72
+
73
+ FileUtils.cp("#{src}/DESCRIPTION", "#{dest}/DESCRIPTION")
74
+ puts "Saved extdata/DESCRIPTION"
75
+ end
76
+ end
77
+
78
+ namespace :extdata do
79
+ desc "download #{bioc_sqlite_database_name}"
80
+ task :download do
81
+ download_annotation(bioc_sqlite_database_name,
82
+ bioc_package_name,
83
+ bioc_package_file_name,
84
+ bioc_package_sha256sum)
85
+ end
86
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sequel'
4
+ <%= config[:gem_constant_name] %> = Sequel.sqlite(
5
+ File.expand_path('../extdata/<%= config[:bioc_sqlite_database_name] %>', __dir__),
6
+ readonly: true
7
+ )
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = '<%= config[:gem_require_name] %>'
5
+ spec.version = '0.0.0'
6
+ spec.authors = ['kojix2']
7
+ spec.email = ['2xijok@gmail.com']
8
+
9
+ spec.summary = ''
10
+ spec.description = ''
11
+ spec.homepage = 'https://github.com/ruby-on-bioc/<%= config[:bioc_package_name] %>'
12
+ spec.required_ruby_version = '>= 2.6.0'
13
+
14
+ spec.files = Dir['*.{md,txt}', 'lib/**/*', 'extdata/<%= config[:bioc_sqlite_database_name] %>']
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_dependency 'sequel'
18
+ spec.add_dependency 'sqlite3'
19
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ class <%= config[:gem_constant_name] %>Test < Test::Unit::TestCase
6
+ test '<%= config[:gem_constant_name] %> is ready' do
7
+ assert_equal(Sequel::SQLite::Database, <%= config[:gem_constant_name] %>.class)
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
4
+ require '<%= config[:gem_require_name] %>'
5
+
6
+ require 'test-unit'
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: biocgem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kojix2
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-12-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: biocgem command line tools
14
+ email:
15
+ - 2xijok@gmail.com
16
+ executables:
17
+ - biocgem
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE.txt
22
+ - README.md
23
+ - exe/biocgem
24
+ - lib/bioc_gem.rb
25
+ - lib/bioc_gem/command.rb
26
+ - lib/bioc_gem/options.rb
27
+ - lib/bioc_gem/parser.rb
28
+ - lib/bioc_gem/version.rb
29
+ - template/newgem/.gitignore.tt
30
+ - template/newgem/Gemfile.tt
31
+ - template/newgem/LICENSE.txt.tt
32
+ - template/newgem/README.md.tt
33
+ - template/newgem/Rakefile.tt
34
+ - template/newgem/lib/new_gem_entry.rb.tt
35
+ - template/newgem/new_gem_entry.gemspec.tt
36
+ - template/newgem/test/new_gem_entry_test.rb.tt
37
+ - template/newgem/test/test_helper.rb.tt
38
+ homepage: https://github.com/ruby-on-bioc/biocgem
39
+ licenses:
40
+ - MIT
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.6.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.2.22
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: biocgem command line tools
61
+ test_files: []