Skip to content

Commit

Permalink
add json-encoded biosample attributes to sample table
Browse files Browse the repository at this point in the history
  • Loading branch information
dpark01 committed Jan 14, 2025
1 parent 98d8d3c commit c45ba1c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pipes/WDL/tasks/tasks_ncbi.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,11 @@ task biosample_to_table {
samples_seen_without_biosample = set(sample_names_seen) - set(row['sample_name'] for row in biosample_attributes)
print("samples seen in bams without biosample entries ({}): {}".format(len(samples_seen_without_biosample), sorted(samples_seen_without_biosample)))
# add biosample json payload to output table
for row in biosample_attributes:
row['biosample_json'] = json.dumps({k: v for k,v in row.items() if k in biosample_headers})
biosample_headers.append('biosample_json')
# write reformatted table
with open('~{base}.entities.tsv', 'w', newline='') as outf:
writer = csv.DictWriter(outf, delimiter='\t', fieldnames=["~{sanitized_id_col}"]+biosample_headers, dialect=csv.unix_dialect, quoting=csv.QUOTE_MINIMAL)
Expand Down

0 comments on commit c45ba1c

Please sign in to comment.