Skip to content

Commit

Permalink
corrects infinte annotation columns problem
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Oct 26, 2016
1 parent 357c784 commit 014ad68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/reporting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,19 +236,25 @@ def merge_csv(file, index)
added = false
my_headers = []
CSV.foreach(file, headers: true, col_sep: "\t") do |row|
# skip if empty line
next if row[0].nil? || row[1].nil? || row[0].empty? || row[1].empty?
# determine headers
unless added
my_headers = (row.headers[2..(row.headers.size)]).collect do |str|
str + "_annot_#{index}"
end
@results_headers.concat my_headers
added = true
end
added = true
# add additional information to each entry
# note: this can take some time depending on the annotation files size
@db.add_info({ one: row.headers[0], two: row.headers[1] },
{ one: row[0], two: row[1] },
my_headers,
row.values_at[2..(row.headers.size)],
my_headers.collect { file })
end
byebug
end
#
#
Expand Down
13 changes: 10 additions & 3 deletions src/results_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,17 @@ def values
end
end

# Add additional information to each row
def add_info(keys, values, new_col_key, new_col_val, file_origin = nil)
header.concat new_col_key
file_origin = [new_col_key] if file_origin.nil?
header_meaning.concat file_origin
file_origin = new_col_key.size.collect { '' } if file_origin.nil?
# only add header if it is not yet declared
new_col_key.each_with_index do |val, ix|
unless header.include?(val)
header.concat([val])
header_meaning.concat([file_origin[ix]])
end
end
#
db.values.each do |el|
new_col_key.each_with_index do |col_key, ix|
if el[keys[:one]] == values[:one] && el[keys[:two]] == values[:two]
Expand Down

0 comments on commit 014ad68

Please sign in to comment.