Module | Bio::RestrictionEnzyme::StringFormatting
In: | lib/bio/util/restriction_enzyme/string_formatting.rb

### Methods

add_spacing left_padding right_padding strip_cuts_and_padding strip_padding

### Included Modules

CutSymbol

### Public Instance methods

add_spacing( seq, cs = cut_symbol )

Return the sequence with spacing for alignment. Does not add whitespace around cut symbols.

Example:

      pattern = 'n^ng^arraxt^n'
      add_spacing( pattern )      # => "n^n g^a r r a x t^n"

Arguments

- `seq`: sequence with cut symbols
- `cs`: (optional) Cut symbol along the string. The reason this is definable outside of CutSymbol is that this is a utility function used to form vertical and horizontal cuts such as:

        a|t g c
         +---+
        t a c|g

Returns: | `String` sequence with single character distance between bases

[Source]

        # File lib/bio/util/restriction_enzyme/string_formatting.rb, line 38
    38:   def add_spacing( seq, cs = cut_symbol )
    39:     str = ''
    40:     flag = false
    41:     seq.each_byte do |c|
    42:       c = c.chr
    43:       if c == cs
    44:         str += c
    45:         flag = false
    46:       elsif flag
    47:         str += ' ' + c
    48:       else
    49:         str += c
    50:         flag = true
    51:       end
    52:     end
    53:     str
    54:   end

left_padding( s )

Return the ‘n’ padding on the left side of the strand

Arguments

- `s`: sequence with extraneous ‘n’ padding on the left side of the strand

Returns: | `String` the ‘n’ padding from the left side

[Source]

        # File lib/bio/util/restriction_enzyme/string_formatting.rb, line 92
    92:   def left_padding( s )
    93:     s =~ %r{^n+}
    94:     ret = $&
    95:     ret ? ret : ''  # Don't pass nil values
    96:   end

right_padding( s )

Return the ‘n’ padding on the right side of the strand

Arguments

- `s`: sequence with extraneous ‘n’ padding on the right side of the strand

Returns: | `String` the ‘n’ padding from the right side

[Source]

         # File lib/bio/util/restriction_enzyme/string_formatting.rb, line 104
    104:   def right_padding( s )
    105:     s =~ %r{n+$}
    106:     ret = $&
    107:     ret ? ret : ''  # Don't pass nil values
    108:   end

strip_cuts_and_padding( s )

Remove extraneous nucleic acid wildcards (‘n’ padding) from the left and right sides and remove cut symbols

Arguments

- `s`: sequence with extraneous ‘n’ padding and cut symbols

Returns: | `String` sequence without ‘n’ padding on the sides or cut symbols

[Source]

        # File lib/bio/util/restriction_enzyme/string_formatting.rb, line 82
    82:   def strip_cuts_and_padding( s )
    83:     strip_padding( s.tr(cut_symbol, '') )
    84:   end

strip_padding( s )

Remove extraneous nucleic acid wildcards (‘n’ padding) from the left and right sides

Arguments

- `s`: sequence with extraneous ‘n’ padding

Returns: | `String` sequence without ‘n’ padding on the sides

[Source]

        # File lib/bio/util/restriction_enzyme/string_formatting.rb, line 63
    63:   def strip_padding( s )
    64:     if s[0].chr == 'n'
    65:       s =~ %r{(n+)(.+)}
    66:       s = $2
    67:     end
    68:     if s[-1].chr == 'n'
    69:       s =~ %r{(.+?)(n+)$}
    70:       s = $1
    71:     end
    72:     s
    73:   end

[Validate]