Replace any character not allowed in a MiGA name for underscore (_). This results in a MiGA-compliant name EXCEPT for empty strings, that results in empty strings.
# File lib/miga/common/format.rb, line 146 def miga_name gsub(/[^A-Za-z0-9_]/, '_') end
Is the string a MiGA-compliant name?
# File lib/miga/common/format.rb, line 152 def miga_name? !(self !~ /^[A-Za-z0-9_]+$/) end
Replace {{variables}} using the vars
hash
# File lib/miga/common/format.rb, line 178 def miga_variables(vars) o = self.dup vars.each { |k, v| o.gsub!("{{#{k}}}", v.to_s) } o end
Replace underscores by spaces or other symbols depending on context
# File lib/miga/common/format.rb, line 158 def unmiga_name gsub(/_(str|sp|subsp|pv)__/, '_\1._') .gsub(/g_c_(content)/, 'G+C \1') .gsub(/g_c_(skew)/, 'G-C \1') .gsub(/a_t_(skew)/, 'A-T \1') .gsub(/x_content/, &:capitalize) .gsub(/(^|_)([sl]su|a[an]i)(_|$)/, &:upcase) .gsub(/^trna_/, 'tRNA ') .gsub(/tRNA aa/, 'tRNA AA') .tr('_', ' ') end
Wraps the string with fixed Integer width
.
# File lib/miga/common/format.rb, line 172 def wrap_width(width) gsub(/([^\n\r]{1,#{width}})/, "\\1\n") end