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 +4 -4
- data/VERSION +1 -1
- data/bio-polyploid-tools.gemspec +2 -2
- data/lib/bio/BIOExtensions.rb +89 -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: 1cc46774ab2f15eaee35b984c144c44c122802ef
|
4
|
+
data.tar.gz: 36ab34ac34994a67bd56eb9748a6106bffd3045f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d08e9a320ce0994620c3687915f96cb7badf54a59f8ec3fda15bdc7497638d6d2dac815d8eadb2ac9d279b0fb781cc8d4e284dd6542cdc89a0b579b183f804a
|
7
|
+
data.tar.gz: 24e83bd8221a30a89f0307bfa6079b7876ea9af135192093af89cae9fd29f643022a5b02de5152faa2f9d0846fed9077e1667460674122bb0c4b12be2cfd4c75
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/bio-polyploid-tools.gemspec
CHANGED
@@ -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.
|
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.
|
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"]
|
data/lib/bio/BIOExtensions.rb
CHANGED
@@ -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
|