5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/bio-table/merge.rb', line 5
def self.merge_tables(tables, options)
logger = Bio::Log::LoggerPlus['bio-table']
logger.info("Merging tables")
= tables.first.[0..0] +
tables.map { |t| t.[1..-1].map{|n|
(options[:keep_headers] ? n : t.name+'-'+n)
}}.flatten
t = Table.new()
idxs = []
tables.each do |t|
idxs << Indexer::create_index(t,[0])
end
all_rownames = idxs.map { |idx| idx.keys }.flatten.uniq
all_rownames.each do | rowname |
row = TableRow.new(rowname)
fields = tables.map { |t|
fields = t.find_fields(rowname)
row.append(fields)
}
t.push(row)
end
t
end
|