parse_fasta 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52fd64de58ca27a7eb5b4ba2df44e8b8eaf43045
4
- data.tar.gz: 902fe63af8592d8cbc0a1e78d251e365f5344f0b
3
+ metadata.gz: c235357c072f2b4042b7723dd0c3eb686d5fc60d
4
+ data.tar.gz: 7f1d7ba7d306774fe35b79f9ec6f773265e7c93e
5
5
  SHA512:
6
- metadata.gz: c5d2182d18621b3673b9d773f4f4e7b53792a7b95ebce30075758b82fcc50e5f1d2c1a140c7f5303d5f4955308960a6744c388620dab549298db1771ec389ca6
7
- data.tar.gz: fee110a5e55546a901c33649695385a0856b44c4d64ef5a1b14650ed23adef892998cc02b1805ebb94d8bf42ed8b5afa3558193f3826c4e82826130517869265
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
- # @param gap_char [String] the character to treat as a gap
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
@@ -1,3 +1,3 @@
1
1
  module ParseFasta
2
- VERSION = "2.4.1"
2
+ VERSION = "2.4.2"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parse_fasta
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moore