Class: Bio::Assembly::Ace::Read

Inherits:
Read
  • Object
show all
Defined in:
lib/bio-assembly/ace.rb

Overview

extend Read class to add ace specific methods for read objects

Defined Under Namespace

Classes: BaseSequence

Instance Attribute Summary collapse

Attributes inherited from Read

#clear_range_from, #clear_range_to, #from, #name, #orientation, #seq, #to

Instance Method Summary collapse

Methods inherited from Read

#<=>, #==, #initialize, #num_bases

Constructor Details

This class inherits a constructor from Bio::Assembly::Read

Instance Attribute Details

#base_sequencesObject

Returns the value of attribute base_sequences.



176
177
178
# File 'lib/bio-assembly/ace.rb', line 176

def base_sequences
  @base_sequences
end

Instance Method Details

#add_base_sequence(from, to, read_name) ⇒ Object



218
219
220
221
# File 'lib/bio-assembly/ace.rb', line 218

def add_base_sequence(from, to, read_name)
  @base_sequences = Array.new if @base_sequences.nil?
  @base_sequences.push BaseSequence.new(from, to, read_name)
end

#to_aceObject



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/bio-assembly/ace.rb', line 178

def to_ace
  ace += ""
  # holds BS data for reads
  bs_str = ""
  # holds RD, QA, and DS data for reads 
  rest_str = ""
  ace += to_ace_af
  bs_str += to_ace_bs
  rest_str = to_ace_rest

  # compile data in correct order
  ace += bs_str
  ace += "\n"
  ace += rest_str
  ace
end

#to_ace_afObject



205
206
207
# File 'lib/bio-assembly/ace.rb', line 205

def to_ace_af
  ['AF', name, orientation, from].join(' ') + "\n"
end

#to_ace_bsObject



195
196
197
198
199
200
201
202
203
# File 'lib/bio-assembly/ace.rb', line 195

def to_ace_bs
  bs_str = ""
  unless base_sequences.nil?
    base_sequences.each do |bs|
      bs_str += ['BS', bs.from, bs.to, bs.read_name].join(' ') + "\n"
    end
  end
  bs_str
end

#to_ace_restObject



209
210
211
212
213
214
215
216
# File 'lib/bio-assembly/ace.rb', line 209

def to_ace_rest
  rest_str = ""
  rest_str += ['RD', name, num_bases, 0, 0].join(' ') + "\n"
  rest_str += seq.to_s.gsub(Regexp.new(".{1,50}"), "\\0\n")  + "\n"
  rest_str += ['QA', clear_range_from, clear_range_to, clear_range_from, clear_range_to].join(' ') + "\n"
  rest_str += ['DS', 'CHROMAT_FILE:', name, 'PHD_FILE:', "#{name}.phd.1", 'TIME:', Time.now].join(' ') + "\n"
  rest_str
end