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 +4 -4
- data/README.md +13 -4
- data/lib/CodonUsage/kazusaDB.rb +19 -6
- data/lib/CodonUsage/version.rb +1 -1
- data/spec/CodonUsage_spec.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a89803143edeaa5265427c0dd488316edc14db6
|
4
|
+
data.tar.gz: c424a5147e438be4a1b8c2778ff447f76893cf79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
24
|
+
for the argument "species", default value = "9606" which is the ID of Homo sapiens (Human).
|
15
25
|
|
16
|
-
for aa, it is the
|
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 )
|
data/lib/CodonUsage/kazusaDB.rb
CHANGED
@@ -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
|
-
@
|
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 @
|
62
|
+
return @codonPreferenceTable
|
50
63
|
end
|
51
64
|
|
52
65
|
def to_json
|
53
66
|
fetch
|
54
|
-
return @
|
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
|
data/lib/CodonUsage/version.rb
CHANGED
data/spec/CodonUsage_spec.rb
CHANGED