CodonUsage 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 +7 -0
- data/.gitignore +17 -0
- data/CodonUsage.gemspec +24 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/lib/CodonUsage/kazusaDB.rb +57 -0
- data/lib/CodonUsage/version.rb +3 -0
- data/lib/CodonUsage.rb +10 -0
- data/spec/CodonUsage_spec.rb +24 -0
- data/spec/spec_helper.rb +5 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 903272496abe6a395d721a40f4d503682a62df8e
|
4
|
+
data.tar.gz: 290248d2dfb0913d68195e3bebc571400e650a75
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5abb42139512d4dafd4a91f08caaf2017614cdbd6d2d5d296328b596dbb5ecdea3ed9ba3b419e225875cbaf59fe9952fde26cfb2ef8c0b004009b6ec4842ed13
|
7
|
+
data.tar.gz: 311b7d03e4ff5f939e88885b4bdafd3d920f6dc9166d5bc3132f0c2c5a161439177789395534d647cdd0d58b8b7f4deefa3829f5bcbfd85dd555b655edf5c675
|
data/.gitignore
ADDED
data/CodonUsage.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'CodonUsage/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "CodonUsage"
|
8
|
+
spec.version = CodonUsage::VERSION
|
9
|
+
spec.authors = ["proxhotdog"]
|
10
|
+
spec.email = ["hotdogcheng@gmail.com"]
|
11
|
+
spec.summary = %q{A ruby gem that parses codon table from http://www.kazusa.or.jp/codon}
|
12
|
+
spec.description = %q{A ruby gem that parses codon table from http://www.kazusa.or.jp/codon and turn it to hash or JSON}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "GPLv3"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
24
|
+
end
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 proxhotdog
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a 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
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# CodonUsage
|
2
|
+
A ruby gem that parse Codon Usage table provided by: http://www.kazusa.or.jp/codon/
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'CodonUsage'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install CodonUsage
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
require "CodonUsage"
|
22
|
+
foo = CodonUsage::KazusaDB.new(aa = "1", species = "9606")
|
23
|
+
p foo.getURL
|
24
|
+
p foo.getHash
|
25
|
+
p foo.toJSON
|
26
|
+
|
27
|
+
|
28
|
+
for aa, it is the codon translation table, default = "1":
|
29
|
+
* 1: Standard
|
30
|
+
* 2: Vertebrate Mitochondrial
|
31
|
+
* 3: Yeast Mitochondrial
|
32
|
+
* 4: Mold, Protozoan, Coelenterate Mitochondrial and Mycoplasma/Spiroplasma
|
33
|
+
* 5: Invertebrate Mitochondrial
|
34
|
+
* 6: Ciliate Macronuclear and Dasycladacean
|
35
|
+
* 9: Echinoderm Mitochondrial
|
36
|
+
* 10: ALternative Ciliate Macronuclear
|
37
|
+
* 11: Eubacterial
|
38
|
+
* 12: Alternative Yeast
|
39
|
+
* 13: Ascidian Mitochondrial
|
40
|
+
* 14: Flatworm Mitochondrial
|
41
|
+
* 15: Blepharisma Nuclear Code
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( http://github.com/proxhotdog/CodonUsage/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
require "csv"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module CodonUsage
|
6
|
+
class KazusaDB
|
7
|
+
def initialize(host: "http://www.kazusa.or.jp/codon/cgi-bin/showcodon.cgi?species=", aa: "1", species: "9606")
|
8
|
+
#1: Standard
|
9
|
+
#2: Vertebrate Mitochondrial
|
10
|
+
#3: Yeast Mitochondrial
|
11
|
+
#4: Mold, Protozoan, Coelenterate Mitochondrial and Mycoplasma/Spiroplasma
|
12
|
+
#5: Invertebrate Mitochondrial
|
13
|
+
#6: Ciliate Macronuclear and Dasycladacean
|
14
|
+
#9: Echinoderm Mitochondrial
|
15
|
+
#10: ALternative Ciliate Macronuclear
|
16
|
+
#11: Eubacterial
|
17
|
+
#12: Alternative Yeast
|
18
|
+
#13: Ascidian Mitochondrial
|
19
|
+
#14: Flatworm Mitochondrial
|
20
|
+
#15: Blepharisma Nuclear Code
|
21
|
+
@url = "#{host}#{species}&aa=#{aa}&style=N"
|
22
|
+
@codonTable = {}
|
23
|
+
end
|
24
|
+
|
25
|
+
def getURL
|
26
|
+
return @url
|
27
|
+
end
|
28
|
+
|
29
|
+
def fetch
|
30
|
+
tableString = ""
|
31
|
+
codonTable = {}
|
32
|
+
codonList = []
|
33
|
+
prefList = []
|
34
|
+
open(@url) {|url|
|
35
|
+
url.each_line {|line|
|
36
|
+
tableString<<line.gsub(/\( +/, '').gsub(/\)[ |\n]/, "\n").gsub(/ +/, "\t").gsub(/\n\t/,"\n") if line.match(/^[A|U|G|C]{3}/)
|
37
|
+
}
|
38
|
+
}
|
39
|
+
CSV.parse(tableString, {:col_sep => "\t"}).each {|codon|
|
40
|
+
codonList.push(codon[0])
|
41
|
+
prefList.push(codon[2])
|
42
|
+
}
|
43
|
+
@codonTable = Hash[codonList.zip(prefList)]
|
44
|
+
return @codonTable
|
45
|
+
end
|
46
|
+
|
47
|
+
def getHash
|
48
|
+
fetch
|
49
|
+
return @codonTable
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_json
|
53
|
+
fetch
|
54
|
+
return @codonTable.to_json
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/CodonUsage.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
system("clear")
|
2
|
+
puts "Rspec results"
|
3
|
+
puts "================="
|
4
|
+
require 'CodonUsage'
|
5
|
+
require 'spec_helper'
|
6
|
+
|
7
|
+
describe CodonUsage::KazusaDB do
|
8
|
+
#let(:dblink) {"http://www.kazusa.or.jp/codon/cgi-bin/showcodon.cgi?species="}
|
9
|
+
it "Create object using default args" do
|
10
|
+
CodonUsage::KazusaDB.new.getURL.should == "http://www.kazusa.or.jp/codon/cgi-bin/showcodon.cgi?species=9606&aa=1&style=N"
|
11
|
+
end
|
12
|
+
it "#aa 2" do
|
13
|
+
CodonUsage::KazusaDB.new(aa: "2").getURL.should == "http://www.kazusa.or.jp/codon/cgi-bin/showcodon.cgi?species=9606&aa=2&style=N"
|
14
|
+
end
|
15
|
+
it "#species:Mycobacterium tuberculosis H37Rv" do
|
16
|
+
CodonUsage::KazusaDB.new(species: "83332").getURL.should == "http://www.kazusa.or.jp/codon/cgi-bin/showcodon.cgi?species=83332&aa=1&style=N"
|
17
|
+
end
|
18
|
+
it "#getHash working?" do
|
19
|
+
p CodonUsage::KazusaDB.new(species: "83332").getHash
|
20
|
+
end
|
21
|
+
it "#to_json working?" do
|
22
|
+
p CodonUsage::KazusaDB.new(species: "83332").to_json
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: CodonUsage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- proxhotdog
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
description: A ruby gem that parses codon table from http://www.kazusa.or.jp/codon
|
56
|
+
and turn it to hash or JSON
|
57
|
+
email:
|
58
|
+
- hotdogcheng@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- CodonUsage.gemspec
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- lib/CodonUsage.rb
|
70
|
+
- lib/CodonUsage/kazusaDB.rb
|
71
|
+
- lib/CodonUsage/version.rb
|
72
|
+
- spec/CodonUsage_spec.rb
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
homepage: ''
|
75
|
+
licenses:
|
76
|
+
- GPLv3
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.2.2
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: A ruby gem that parses codon table from http://www.kazusa.or.jp/codon
|
98
|
+
test_files:
|
99
|
+
- spec/CodonUsage_spec.rb
|
100
|
+
- spec/spec_helper.rb
|