CodonUsage 0.0.2 → 0.0.3

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: c81861b670bfb00e551e74e27364d805e6066756
4
- data.tar.gz: 3d75b58dffeda5c14730397f9d10d3234c0b531c
3
+ metadata.gz: 0a89803143edeaa5265427c0dd488316edc14db6
4
+ data.tar.gz: c424a5147e438be4a1b8c2778ff447f76893cf79
5
5
  SHA512:
6
- metadata.gz: 5e7b96acb769897a6ca3fa145a3b9938f5b6aebe1a75f2c19796505879aa4fe1ef6a0abc4dc88bb5b0ba89ca6955004dbab051b3d286218ef5ff15fd8dd304fb
7
- data.tar.gz: 246d3a96f59b6bd630c0a9ea6523b1cf3c794f228431d69f4f9e2da6890243cb42fbbfe54d3e722f765b0168707d6c46870c9ee5ced3c72115519304d300ad4c
6
+ metadata.gz: 7e1ac446a4110eb234b024051266162cfff09e4476b066f29b99b92725f5efed3db27d2b86973b3e593b276f112ab06a814ccf0c12acfee6d01da3624745650d
7
+ data.tar.gz: c08e00d0b6ccbd88864b4b467ebd08e5d1d4449e4d586c8f6161edc7b60861cca7ef4238e14b9262bdb38c02162dc6a53b8e1699d354e00979088cb0377c2544
data/README.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CodonUsage
2
- A ruby gem that parse Codon Usage table provided by: http://www.kazusa.or.jp/codon/
2
+ A ruby gem that parses Codon Usage table provided by: http://www.kazusa.or.jp/codon/ that output the information in a hash or JSON forma formatt
3
+
4
+ ## Version
5
+ 0.0.3
6
+
7
+ ## Disclaimer
8
+ I write this gem because bioruby doesn't provide any library for me to do this job, and this is my first ruby gem. Hope this gem can help people in the bioinformatics field! :)
9
+
10
+ ## Before start
11
+ * Please use Ruby 1.9.3 or above
3
12
 
4
13
  ## Installation
5
14
  $ gem install CodonUsage
@@ -10,10 +19,11 @@ A ruby gem that parse Codon Usage table provided by: http://www.kazusa.or.jp/cod
10
19
  p foo.getURL
11
20
  p foo.getHash
12
21
  p foo.to_json
22
+ p foo.getCodonTable
13
23
 
14
- for species, "9606" is homo sapiens ID.
24
+ for the argument "species", default value = "9606" which is the ID of Homo sapiens (Human).
15
25
 
16
- for aa, it is the codon translation table, default = "1":
26
+ for the arguement "aa", it is the genetic code, default value = "1":
17
27
  * 1: Standard
18
28
  * 2: Vertebrate Mitochondrial
19
29
  * 3: Yeast Mitochondrial
@@ -28,7 +38,6 @@ for aa, it is the codon translation table, default = "1":
28
38
  * 14: Flatworm Mitochondrial
29
39
  * 15: Blepharisma Nuclear Code
30
40
 
31
-
32
41
  ## Contributing
33
42
 
34
43
  1. Fork it ( http://github.com/proxhotdog/CodonUsage/fork )
@@ -1,3 +1,7 @@
1
+ #Author: proxhotdog
2
+ #Email: hotdogcheng@gmail.com
3
+ #License: GPL v3
4
+
1
5
  require "open-uri"
2
6
  require "csv"
3
7
  require "json"
@@ -19,6 +23,7 @@ module CodonUsage
19
23
  #14: Flatworm Mitochondrial
20
24
  #15: Blepharisma Nuclear Code
21
25
  @url = "#{host}#{species}&aa=#{aa}&style=N"
26
+ @codonPreferenceTable = {}
22
27
  @codonTable = {}
23
28
  end
24
29
 
@@ -31,27 +36,35 @@ module CodonUsage
31
36
  codonTable = {}
32
37
  codonList = []
33
38
  prefList = []
39
+ aminoAcidList = []
34
40
  open(@url) {|url|
35
41
  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}/)
42
+ tableString<<line.gsub(/\( +/, '').gsub(/\)[ |\n]/, "\n").gsub(/ +/, "\t").gsub(/\n\t/,"\n") if line.match(/^[A|U|G|C]{3}/) # Quick & dirty way to change that table to tab-delimited format just like CSV file
37
43
  }
38
44
  }
39
45
  CSV.parse(tableString, {:col_sep => "\t"}).each {|codon|
40
- codonList.push(codon[0])
41
- prefList.push(codon[2])
46
+ codonList.push(codon[0]) # extract the triplet
47
+ prefList.push(codon[2]) # extract the fraction, also known as codon preference
48
+ aminoAcidList.push(codon[1]) # extract the coding amino acid since different organisms have different codon table
42
49
  }
43
- @codonTable = Hash[codonList.zip(prefList)]
50
+ @codonPreferenceTable = Hash[codonList.zip(prefList)]
51
+ @codonTable = Hash[codonList.zip(aminoAcidList)]
52
+ return 0
53
+ end
54
+
55
+ def getCodonTable
56
+ fetch
44
57
  return @codonTable
45
58
  end
46
59
 
47
60
  def getHash
48
61
  fetch
49
- return @codonTable
62
+ return @codonPreferenceTable
50
63
  end
51
64
 
52
65
  def to_json
53
66
  fetch
54
- return @codonTable.to_json
67
+ return @codonPreferenceTable.to_json # just simply use built-in json library, only available Ruby 1.9.3+
55
68
  end
56
69
  end
57
70
  end
@@ -1,3 +1,3 @@
1
1
  module CodonUsage
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -23,4 +23,7 @@ describe CodonUsage::KazusaDB do
23
23
  it "#to_json working?" do
24
24
  p CodonUsage::KazusaDB.new(species: "83332").to_json
25
25
  end
26
+ it "#getCodonTable working?" do
27
+ p CodonUsage::KazusaDB.new(species: "83332").getCodonTable
28
+ end
26
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CodonUsage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - proxhotdog