Class: Ruport::Data::Table
- Inherits:
-
Object
- Object
- Ruport::Data::Table
- Defined in:
- bin/peptide_hit_qvalues_to_spectral_counts_table.rb
Instance Method Summary collapse
-
#add_column_with_data(colname, array_of_data, opts = {}) ⇒ Object
returns self.
-
#to_tsv(file, opt = {}) ⇒ Object
acceptable opts:.
Instance Method Details
#add_column_with_data(colname, array_of_data, opts = {}) ⇒ Object
returns self
36 37 38 39 40 41 42 |
# File 'bin/peptide_hit_qvalues_to_spectral_counts_table.rb', line 36 def add_column_with_data(colname, array_of_data, opts={}) self.add_column(colname, opts) self.data.zip(array_of_data) do |row, newval| row[colname] = newval end self end |
#to_tsv(file, opt = {}) ⇒ Object
acceptable opts:
:header => an array of lines (each which will be commented out)
47 48 49 50 51 52 53 54 55 56 57 |
# File 'bin/peptide_hit_qvalues_to_spectral_counts_table.rb', line 47 def to_tsv(file, opt={}) delimiter = "\t" File.open(file,'w') do |out| opt[:header].each {|line| out.puts "# #{line}" } if opt[:header] out.puts self.column_names.join(delimiter) self.data.each do |row| out.puts row.to_a.join(delimiter) end opt[:footer].each {|line| out.puts "# #{line}" } if opt[:footer] end end |