Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow custom placeholder for missing data in tsv_join task #227

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pipes/WDL/tasks/tasks_utils.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ task tsv_join {
Array[File]+ input_tsvs
String id_col
String out_basename = "merged"
String placeholder_for_missing = ""
}

command <<<
Expand Down Expand Up @@ -210,8 +211,8 @@ task tsv_join {
row_out = out_row_by_id.get(row_id, {})
for h in header:
# prefer non-empty values from earlier files in in_tsvs, populate from subsequent files only if missing
if not row_out.get(h):
row_out[h] = row.get(h, '')
if row_out.get(h, '~{placeholder_for_missing}') == '~{placeholder_for_missing}':
row_out[h] = row.get(h, '~{placeholder_for_missing}')
out_row_by_id[row_id] = row_out
out_ids.append(row_id)
out_ids = list(collections.OrderedDict(((i,0) for i in out_ids)).keys())
Expand Down
7 changes: 4 additions & 3 deletions pipes/WDL/workflows/sarscov2_nextstrain.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ workflow sarscov2_nextstrain {
if(length(sample_metadata_tsvs)>1) {
call utils.tsv_join {
input:
input_tsvs = sample_metadata_tsvs,
id_col = 'strain',
out_basename = "metadata-merged"
input_tsvs = sample_metadata_tsvs,
id_col = 'strain',
out_basename = "metadata-merged"
placeholder_for_missing = "?"
}
}
call nextstrain.derived_cols {
Expand Down