Class | String
In: | lib/bio/shell/plugin/seq.rb
Parent: | Object

### Methods

fill fold skip step to_aaseq to_naseq

### Public Instance methods

fill(fill_column = 80, indent = 0, separater = ' ', prefix = '', first_line_only = true)

folding with conscious about word boundaries with prefix string

[Source]

         # File lib/bio/shell/plugin/seq.rb, line 208
    208:   def fill(fill_column = 80, indent = 0, separater = ' ', prefix = '', first_line_only = true)
    209:
    210:     # size : allowed length of the actual text
    211:     unless (size = fill_column - indent) > 0
    212:       warn "Error: indent > fill_column (indent is set to 0)"
    213:       size = fill_column
    214:       indent = 0
    215:     end
    216:
    217:     n = pos = 0
    218:     ary = []
    219:     while n < self.length
    220:       pos = self[n, size].rindex(separater)
    221:
    222:       if self[n, size].length < size    # last line of the folded str
    223:         pos = nil
    224:       end
    225:
    226:       if pos
    227:         ary << self[n, pos+separater.length]
    228:         n += pos + separater.length
    229:       else                              # line too long or the last line
    230:         ary << self[n, size]
    231:         n += size
    232:       end
    233:     end
    234:     str = ary.join("\n")
    235:
    236:     str[0,0] = prefix + ' ' * (indent - prefix.length)
    237:     if first_line_only
    238:       head = ' ' * indent
    239:     else
    240:       head = prefix + ' ' * (indent - prefix.length)
    241:     end
    242:     str.gsub!("\n", "\n#{head}")
    243:
    244:     return str.chomp
    245:   end

fold(fill_column = 72, indent = 0)

folding both line end justified

[Source]

         # File lib/bio/shell/plugin/seq.rb, line 190
    190:   def fold(fill_column = 72, indent = 0)
    191:     str = ''
    192:
    193:     # size : allowed length of the actual text
    194:     unless (size = fill_column - indent) > 0
    195:       warn "Error: indent > fill_column (indent is set to 0)"
    196:       size = fill_column
    197:       indent = 0
    198:     end
    199:
    200:     0.step(self.length - 1, size) do |n|
    201:       str << ' ' * indent + self[n, size] + "\n"
    202:     end
    203:
    204:     return str
    205:   end

skip(window_size, step_size = 1) {|[self[i, window_size], i + 1, i + window_size]| ...}

[Source]

         # File lib/bio/shell/plugin/seq.rb, line 171
    171:   def skip(window_size, step_size = 1)
    172:     i = 0
    173:     0.step(self.length - window_size, step_size) do |i|
    174:       yield [self[i, window_size], i + 1, i + window_size]
    175:     end
    176:     from = i + step_size
    177:     to  = [self.length, i + step_size + window_size].min
    178:     yield [self[from, window_size], from + 1, to] if from + 1 <= to
    179:   end

step(window_size) {|self[i, window_size]| ...}

[Source]

         # File lib/bio/shell/plugin/seq.rb, line 163
    163:   def step(window_size)
    164:     i = 0
    165:     0.step(self.length - window_size, window_size) do |i|
    166:       yield self[i, window_size]
    167:     end
    168:     yield self[i + window_size .. -1] if i + window_size < self.length
    169:   end

to_aaseq()

[Source]

         # File lib/bio/shell/plugin/seq.rb, line 185
    185:   def to_aaseq
    186:     Bio::Sequence::AA.new(self)
    187:   end

to_naseq()

[Source]

         # File lib/bio/shell/plugin/seq.rb, line 181
    181:   def to_naseq
    182:     Bio::Sequence::NA.new(self)
    183:   end

[Validate]