parse_fasta 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parse_fasta/core_ext/string.rb +19 -1
- data/lib/parse_fasta/version.rb +1 -1
- data/spec/parse_fasta/core_ext/string_spec.rb +8 -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: c235357c072f2b4042b7723dd0c3eb686d5fc60d
|
4
|
+
data.tar.gz: 7f1d7ba7d306774fe35b79f9ec6f773265e7c93e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3ab4bc141fdd4ed995d9931ecee923e2a81bf07ade851275f9315fe2df09b94c09d6af372bf3b229caedba618c488fac77554b3b02f60ccfbb2e5f901030cbd
|
7
|
+
data.tar.gz: 8d7bee5a8f0cf74db20616165dd0d00a4caa44eec7701e1a4a48ddf6349a6906aa05033307de01b05af8eb5b2fb5e96d7818058c744527ce5ec6cf68a7f1c6d8
|
@@ -8,6 +8,7 @@ module ParseFasta
|
|
8
8
|
# # First inclued the methods
|
9
9
|
# String.include ParseFasta::CoreExt::String
|
10
10
|
#
|
11
|
+
# # The default gap char is '-'
|
11
12
|
# "--A-C-t-g".remove_gaps #=> "ACtg"
|
12
13
|
#
|
13
14
|
# @example Change the gap character to 'n'
|
@@ -16,11 +17,28 @@ module ParseFasta
|
|
16
17
|
#
|
17
18
|
# "-N-nACTG".remove_gaps "N" #=> "--nACTG"
|
18
19
|
#
|
19
|
-
# @
|
20
|
+
# @example Passing multiple gap chars
|
21
|
+
# # First inclued the methods
|
22
|
+
# String.include ParseFasta::CoreExt::String
|
23
|
+
#
|
24
|
+
# ".A----C_t~~~~g^G3".remove_gaps '^._-~3' #=> "ACtgG"
|
25
|
+
#
|
26
|
+
# @param gap_char [String] the character(s) to treat as a gap
|
20
27
|
#
|
21
28
|
# @return [String] a string with all instances of
|
22
29
|
# gap_char_removed
|
23
30
|
def remove_gaps gap_char="-"
|
31
|
+
|
32
|
+
if gap_char.length > 1
|
33
|
+
if gap_char.include? "^"
|
34
|
+
gap_char.sub! '^', '\\^'
|
35
|
+
end
|
36
|
+
|
37
|
+
if gap_char.include? "-"
|
38
|
+
gap_char.sub! '-', '\\-'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
24
42
|
self.tr gap_char, ""
|
25
43
|
end
|
26
44
|
end
|
data/lib/parse_fasta/version.rb
CHANGED
@@ -26,6 +26,14 @@ module ParseFasta
|
|
26
26
|
|
27
27
|
expect(aln.remove_gaps "N").to eq expected
|
28
28
|
end
|
29
|
+
|
30
|
+
it "can handle multiple weird gap chars" do
|
31
|
+
# The '-' and '^' chars are treated specially by String#tr.
|
32
|
+
aln = ".A----C_t~~~~g^G3"
|
33
|
+
expected = "ACtgG"
|
34
|
+
|
35
|
+
expect(aln.remove_gaps '^._-~3').to eq expected
|
36
|
+
end
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|