pipet 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,8 +1,10 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
+ gem 'thor'
3
4
 
4
5
  group :development do
5
6
  gem 'rspec', '2.14.1'
6
7
  gem 'bundler', '1.3.5'
7
8
  gem 'jeweler', '1.8.6'
9
+ gem 'pry'
8
10
  end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) [2013] [Austin G. Davis-Richardson]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a
6
+ copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included
14
+ in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ class NCBINT < Database
2
+
3
+ name 'ncbi/nt'
4
+ url 'ftp://ftp.ncbi.nih.gov/blast/db/FASTA/nt.gz'
5
+ description 'NCBI non-redundant nucleotide database'
6
+ md5 'f77aff452dd1ba6b0e26b8d6b97b0a62'
7
+
8
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/bin/pipet ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'pipet'))
4
+
5
+ Pipet::CLI.start
data/lib/database.rb ADDED
@@ -0,0 +1,12 @@
1
+ class Database
2
+ class << self
3
+
4
+ ##
5
+ # Returns a list of all objects that inherited from Database
6
+ #
7
+ def all
8
+ ObjectSpace.each_object(Class).select { |klass| klass < self }
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,79 @@
1
+ ##
2
+ # Database
3
+ #
4
+ # Creates a DSL for defining Databases
5
+ # which can be downloaded using `pipet pull`
6
+ #
7
+
8
+ class Database
9
+
10
+ class << self
11
+
12
+ ##
13
+ # Specify the URL of a database
14
+ #
15
+ def url(url=nil)
16
+ @url ||= url
17
+ end
18
+
19
+ ##
20
+ # Specify MD5 checksum of database
21
+ #
22
+ def md5(val=nil)
23
+ @md5 ||= val
24
+ end
25
+
26
+ ##
27
+ # Provide a description for the database
28
+ #
29
+ def description(val=nil)
30
+ @description ||= val
31
+ end
32
+
33
+ ##
34
+ # Name the database. This is used be `pipet pull`
35
+ #
36
+ def name(val=nil)
37
+ @name ||= val
38
+ end
39
+
40
+ ##
41
+ # Define type of database. This is like a tag.
42
+ # For example,
43
+ #
44
+ # type :nucleotide
45
+ # for a database of nucleotide sequences
46
+ #
47
+ # type :structure
48
+ # for a database of protein structures
49
+ #
50
+ def type(val=nil)
51
+ @type ||= val
52
+ end
53
+
54
+ ##
55
+ # Make sure all required attributes have been defined.
56
+ #
57
+ def validate
58
+ required_attributes = [
59
+ :name,
60
+ :md5,
61
+ :description,
62
+ :type
63
+ ]
64
+
65
+ required_attributes.map do |ra|
66
+ self.send(ra)
67
+ end.include? nil
68
+
69
+ end
70
+
71
+ ##
72
+ # Downloads the database, checks the MD5 sum.
73
+ #
74
+ def pull
75
+ `wget #{@url}`
76
+ end
77
+
78
+ end # class << self
79
+ end
data/lib/pipet.rb CHANGED
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ %w{database database_dsl}.each do |f|
5
+ require File.join(File.dirname(__FILE__), "#{f}.rb")
6
+ end
7
+
8
+
9
+ SOURCES = Dir.glob(File.join(File.dirname(__FILE__), '..', 'Sources', '*.rb'))
10
+
11
+ SOURCES.each do |sf|
12
+ require sf
13
+ end
14
+
15
+ Dir.glob(File.join(File.dirname(__FILE__), 'pipet', '*.rb')).each { |f| require f }
data/lib/pipet/cli.rb ADDED
@@ -0,0 +1,6 @@
1
+ module Pipet
2
+ class CLI < Thor
3
+ end
4
+ end
5
+
6
+ Dir.glob(File.join(File.dirname(__FILE__), 'tasks', '*.rb')).each { |f| require f }
@@ -0,0 +1,15 @@
1
+ module Pipet
2
+ class CLI
3
+
4
+ desc 'list', 'list all available databases'
5
+
6
+ def list
7
+ databases = Database.all
8
+
9
+ databases.each do |db|
10
+ puts "#{db.name}"
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module Pipet
2
+ class CLI
3
+
4
+ desc 'pull', 'download a database'
5
+
6
+ def pull(name)
7
+ match = Database.all.keep_if { |x| x.name == name }.first
8
+ match.pull
9
+ end
10
+
11
+ end
12
+ end
data/pipet.gemspec CHANGED
@@ -5,23 +5,35 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "pipet"
8
- s.version = "0.0.0"
8
+ s.version = "0.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Austin Richardson"]
12
12
  s.date = "2013-07-18"
13
13
  s.description = "Pipet is a package manager for bioinformatics databases that allows users to easily retrieve databases from their sources using the command line. Pipet also checks for database integrity via checksum"
14
14
  s.email = "harekrishna@gmail.com"
15
+ s.executables = ["pipet"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt"
18
+ ]
15
19
  s.files = [
16
20
  ".rspec",
17
21
  ".rvmrc",
18
22
  "Gemfile",
23
+ "LICENSE.txt",
19
24
  "Rakefile",
25
+ "Sources/ncbi_nt.rb",
20
26
  "VERSION",
27
+ "bin/pipet",
28
+ "lib/database.rb",
29
+ "lib/database_dsl.rb",
21
30
  "lib/pipet.rb",
31
+ "lib/pipet/cli.rb",
32
+ "lib/pipet/tasks/list.rb",
33
+ "lib/pipet/tasks/pull.rb",
22
34
  "pipet.gemspec",
23
35
  "readme.md",
24
- "spec/.pipet_spec.rb.swp",
36
+ "spec/database_spec.rb",
25
37
  "spec/pipet_spec.rb",
26
38
  "spec/spec_helper.rb"
27
39
  ]
@@ -35,18 +47,24 @@ Gem::Specification.new do |s|
35
47
  s.specification_version = 3
36
48
 
37
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<thor>, [">= 0"])
38
51
  s.add_development_dependency(%q<rspec>, ["= 2.14.1"])
39
52
  s.add_development_dependency(%q<bundler>, ["= 1.3.5"])
40
53
  s.add_development_dependency(%q<jeweler>, ["= 1.8.6"])
54
+ s.add_development_dependency(%q<pry>, [">= 0"])
41
55
  else
56
+ s.add_dependency(%q<thor>, [">= 0"])
42
57
  s.add_dependency(%q<rspec>, ["= 2.14.1"])
43
58
  s.add_dependency(%q<bundler>, ["= 1.3.5"])
44
59
  s.add_dependency(%q<jeweler>, ["= 1.8.6"])
60
+ s.add_dependency(%q<pry>, [">= 0"])
45
61
  end
46
62
  else
63
+ s.add_dependency(%q<thor>, [">= 0"])
47
64
  s.add_dependency(%q<rspec>, ["= 2.14.1"])
48
65
  s.add_dependency(%q<bundler>, ["= 1.3.5"])
49
66
  s.add_dependency(%q<jeweler>, ["= 1.8.6"])
67
+ s.add_dependency(%q<pry>, [">= 0"])
50
68
  end
51
69
  end
52
70
 
data/readme.md CHANGED
@@ -1,19 +1,29 @@
1
- = pipet
1
+ # Pipet
2
2
 
3
- Description goes here.
3
+ Bioinformatics Database "Package Manager".
4
4
 
5
- == Contributing to pipet
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
5
+ ## Example Usage
14
6
 
15
- == Copyright
7
+ ```bash
16
8
 
17
- Copyright (c) 2013 Austin Richardson. See LICENSE.txt for
18
- further details.
9
+ # List avaiable databases
10
+ darwin@beagle> pipet list
11
+ ncbi/nt
19
12
 
13
+ # Download a database
14
+ darwin@beagle> pipet pull ncbi/nt.fasta
15
+ Downloading ncbi/nt.fasta from ftp://ftp.ncbi.nih.gov/blast/db/fasta/nt.gz
16
+ Success!
17
+ nt.fasta located in ~/.pipet/ncbi/nt.fasta
18
+ ```
19
+
20
+ ## Installation
21
+
22
+ ```
23
+ # on most 'nix systems
24
+ (sudo) gem install pipet
25
+ ```
26
+
27
+ # Copyright
28
+
29
+ Copyright (c) 2013 Austin Richardson. See LICENSE.txt for details.
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Database do
4
+
5
+ let :test_db do
6
+ class TestDB < Database
7
+ url 'hello world!'
8
+ name 'hello world!'
9
+ md5 '6f5902ac237024bdd0c176cb93063dc4'
10
+ end
11
+ TestDB
12
+ end
13
+
14
+ it 'should provide a DSL for defining bioinformatics databases' do
15
+ test_db.should_not be_nil
16
+ end
17
+
18
+ it '#validate should validate attributes' do
19
+ test_db.validate.should_not be_false
20
+ end
21
+
22
+ it '#all returns a list of all classes that inherited from Database' do
23
+ Database.all.include?(test_db).should be_true
24
+ end
25
+
26
+ end
data/spec/pipet_spec.rb CHANGED
@@ -1,7 +1 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Pipet" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
6
- end
7
- end
1
+ require 'spec_helper'
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,11 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
 
4
- require 'rspec'
4
+ require 'bundler'
5
5
  require 'pipet'
6
6
 
7
- # Requires supporting files with custom matchers and macros, etc,
8
- # in ./support/ and its subdirectories.
9
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
7
+ Bundler.require :development
10
8
 
11
9
  RSpec.configure do |config|
12
10
 
13
- end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,6 +11,22 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2013-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rspec
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -59,23 +75,49 @@ dependencies:
59
75
  - - '='
60
76
  - !ruby/object:Gem::Version
61
77
  version: 1.8.6
78
+ - !ruby/object:Gem::Dependency
79
+ name: pry
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
62
94
  description: Pipet is a package manager for bioinformatics databases that allows users
63
95
  to easily retrieve databases from their sources using the command line. Pipet also
64
96
  checks for database integrity via checksum
65
97
  email: harekrishna@gmail.com
66
- executables: []
98
+ executables:
99
+ - pipet
67
100
  extensions: []
68
- extra_rdoc_files: []
101
+ extra_rdoc_files:
102
+ - LICENSE.txt
69
103
  files:
70
104
  - .rspec
71
105
  - .rvmrc
72
106
  - Gemfile
107
+ - LICENSE.txt
73
108
  - Rakefile
109
+ - Sources/ncbi_nt.rb
74
110
  - VERSION
111
+ - bin/pipet
112
+ - lib/database.rb
113
+ - lib/database_dsl.rb
75
114
  - lib/pipet.rb
115
+ - lib/pipet/cli.rb
116
+ - lib/pipet/tasks/list.rb
117
+ - lib/pipet/tasks/pull.rb
76
118
  - pipet.gemspec
77
119
  - readme.md
78
- - spec/.pipet_spec.rb.swp
120
+ - spec/database_spec.rb
79
121
  - spec/pipet_spec.rb
80
122
  - spec/spec_helper.rb
81
123
  homepage: http://github.com/audy/pipet
@@ -93,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
135
  version: '0'
94
136
  segments:
95
137
  - 0
96
- hash: -4135599796043976134
138
+ hash: -106065623171849882
97
139
  required_rubygems_version: !ruby/object:Gem::Requirement
98
140
  none: false
99
141
  requirements:
Binary file