bio-polyploid-tools 0.4.1 → 0.4.2

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: 8d839159cd2b8aee7e5586e5b04a4fadc1415b90
4
- data.tar.gz: 30af7856bfe87e382b0e0e8c8890507b743d8057
3
+ metadata.gz: 1cc46774ab2f15eaee35b984c144c44c122802ef
4
+ data.tar.gz: 36ab34ac34994a67bd56eb9748a6106bffd3045f
5
5
  SHA512:
6
- metadata.gz: 19893d9fcdf0a5583c1b07d5bf86e8bbc517cd6219bba0d9e0966532756c63be3765f02810758dd4488232cf68edccf55a8d22d9bb07195eb3a94825e7ffba49
7
- data.tar.gz: 80bdd7c718ab9c05155b8da99cec7ed543e938a942591acd0a53fce8cbe7e797ffb044e48b96734c795a5a9cda8b5cdd269d019766dffa0c5f498207744f9ef9
6
+ metadata.gz: 9d08e9a320ce0994620c3687915f96cb7badf54a59f8ec3fda15bdc7497638d6d2dac815d8eadb2ac9d279b0fb781cc8d4e284dd6542cdc89a0b579b183f804a
7
+ data.tar.gz: 24e83bd8221a30a89f0307bfa6079b7876ea9af135192093af89cae9fd29f643022a5b02de5152faa2f9d0846fed9077e1667460674122bb0c4b12be2cfd4c75
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: bio-polyploid-tools 0.4.1 ruby lib
5
+ # stub: bio-polyploid-tools 0.4.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "bio-polyploid-tools"
9
- s.version = "0.4.1"
9
+ s.version = "0.4.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -62,3 +62,92 @@ class Hash
62
62
  end
63
63
 
64
64
 
65
+ class Bio::NucleicAcid
66
+
67
+ IUPAC_CODES = {
68
+
69
+ 'y' => 'ct',
70
+ 'r' => 'ag',
71
+ 'w' => 'at',
72
+ 's' => 'cg',
73
+ 'k' => 'gt',
74
+ 'm' => 'ac',
75
+
76
+ 'b' => 'cgt',
77
+ 'd' => 'agt',
78
+ 'h' => 'act',
79
+ 'v' => 'acg',
80
+
81
+ 'n' => 'acgt',
82
+
83
+ 'a' => 'a',
84
+ 't' => 't',
85
+ 'g' => 'g',
86
+ 'c' => 'c',
87
+ 'u' => 'u',
88
+
89
+ 'ct' => 'y',
90
+ 'ag' => 'r',
91
+ 'at' => 'w',
92
+ 'cg' => 's',
93
+ 'gt' => 'k',
94
+ 'ac' => 'm',
95
+
96
+ 'cgt' => 'b',
97
+ 'agt' => 'd',
98
+ 'act' => 'h',
99
+ 'acg' => 'v',
100
+
101
+ 'acgt' => 'n'
102
+ }
103
+
104
+
105
+ def self.is_unambiguous(base)
106
+ "acgtACGT".match(base)
107
+ end
108
+
109
+ def self.to_IUAPC(bases)
110
+ base = IUPAC_CODES[bases.to_s.downcase.chars.sort.uniq.join]
111
+ if base == nil
112
+ p "Invalid base! #{base}"
113
+ base = 'n' #This is a patch... as one of the scripts failed here.
114
+ end
115
+ base.upcase
116
+ end
117
+
118
+ def self.is_valid(code, base)
119
+ IUPAC_CODES[code.downcase].chars.include? base.downcase
120
+ end
121
+
122
+ end
123
+
124
+ #Monkey patching to Bio::Sequence to find snps between sequences. It assumes the
125
+ #sequences are already aligned and doesn't check if a base on the first sequence is
126
+ #valid on the second.
127
+ class Bio::Sequence
128
+ def self.snps_between(seq1, seq2)
129
+ snps=0
130
+ for i in (0..seq1.size-1)
131
+ snps += 1 if seq1[i] != seq2[i]
132
+ end
133
+ snps
134
+ end
135
+ end
136
+
137
+ class String
138
+ #Monkey patching to count how many ambiguity codes are present in the string, for Nucleic Acids
139
+ def count_ambiguities
140
+ snps=0
141
+
142
+ for i in (0..self.size-1)
143
+
144
+ snps += 1 if !Bio::NucleicAcid.is_unambiguous(self[i])
145
+ end
146
+ snps
147
+ end
148
+
149
+ #Counts how many bases are uppercase
150
+ def upper_case_count
151
+ match(/[^A-Z]*/).to_s.size
152
+ end
153
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-polyploid-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo H. Ramirez-Gonzalez