Skip to content

Commit

Permalink
Add year column
Browse files Browse the repository at this point in the history
So that we can easily see the sample collection date using a continuous colour scale in auspice
  • Loading branch information
jameshadfield committed Jun 28, 2023
1 parent f2d3d1b commit a423fad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/auspice_config_all.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
"title": "collection date",
"type": "categorical"
},
{
"key": "year",
"title": "collection year",
"type": "continuous"
},
{
"key": "circularise",
"title": "genome re-cut?",
Expand Down
3 changes: 2 additions & 1 deletion ingest/ingest.smk
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ rule transform_metadata:
output:
metadata = "ingest/results/metadata.tsv"
params:
metadata_columns = ['name', 'accesion', "strain_name", "date", "region", "country", "host", "genotype_genbank", "subgenotype_genbank", \
metadata_columns = ['name', 'accesion', "strain_name", "date", "year", "region", "country", "host", "genotype_genbank", "subgenotype_genbank", \
"circularise", "circularise_shift_bp","clade_nextclade","QC_overall_score","QC_overall_status","total_substitutions","total_deletions", \
"total_insertions","total_frame_shifts","total_missing","alignment_score","coverage","QC_missing_data","QC_mixed_sites","QC_rare_mutations", \
"QC_frame_shifts","QC_stop_codons"]
Expand All @@ -92,6 +92,7 @@ rule transform_metadata:
ingest/scripts/tsv-to-ndjson.py < {input.metadata} |
ingest/scripts/fix_country_field.py |
ingest/scripts/apply-geolocation-rules.py --geolocation-rules ingest/config/geoLocationRules.tsv |
ingest/scripts/add-year.py |
ingest/scripts/ndjson-to-tsv.py --metadata-columns {params.metadata_columns} --metadata {output.metadata}
"""

Expand Down
10 changes: 10 additions & 0 deletions ingest/scripts/add-year.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3

from sys import stdin, stdout
import json

for record in stdin:
record = json.loads(record)
record['year'] = record['date'][0:4]
json.dump(record, stdout, allow_nan=False, indent=None, separators=',:')
print()

0 comments on commit a423fad

Please sign in to comment.