Skip to content

Commit 48b71a3

Browse files
committed
added support for passing down "info.origin"
1 parent cbe3484 commit 48b71a3

6 files changed

Lines changed: 39 additions & 0 deletions

payload-gen-variant-calling/main.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,31 @@ def get_sample_info(sample_list):
212212

213213
def main(args):
214214
normal_analysis = {}
215+
normal_origin = None
215216
with open(args.normal_analysis, 'r') as f:
216217
normal_analysis = json.load(f)
218+
if 'info' in normal_analysis and 'origin' in normal_analysis['info']:
219+
normal_origin = normal_analysis['info']['origin']
217220

218221
tumour_analysis = {}
222+
tumour_origin = None
219223
if args.tumour_analysis:
220224
with open(args.tumour_analysis, 'r') as f:
221225
tumour_analysis = json.load(f)
226+
if 'info' in tumour_analysis and 'origin' in tumour_analysis['info']:
227+
tumour_origin = tumour_analysis['info']['origin']
228+
229+
if normal_origin is not None and tumour_origin is not None:
230+
if normal_origin == tumour_origin:
231+
analysis_origin = normal_origin
232+
else:
233+
sys.exit(f'Origins of normal and tumour analyses differ, normal: {normal_origin}, tumour: {tumour_origin}')
234+
elif normal_origin is not None:
235+
analysis_origin = normal_origin
236+
elif tumour_origin is not None:
237+
analysis_origin = tumour_origin
238+
else:
239+
analysis_origin = None
222240

223241
somatic_or_germline = 'Somatic' # default
224242
if args.wf_short_name in ['sanger-wgs', 'sanger-wxs', 'gatk-mutect2']:
@@ -233,6 +251,9 @@ def main(args):
233251
'analysisType': {
234252
'name': None
235253
},
254+
'info': {
255+
'origin': analysis_origin # adding this here, so the info field will maintain it's position
256+
},
236257
'studyId': normal_analysis.get('studyId'), # normal/tumour analysis should always from the same study
237258
'experiment': {},
238259
'samples': [],
@@ -248,6 +269,9 @@ def main(args):
248269
}
249270
}
250271

272+
if analysis_origin is None: # if origin is None, remove the info field
273+
payload.pop('info')
274+
251275
# get sample of the payload
252276
if somatic_or_germline == 'Somatic': # somatic variants
253277
payload['samples'] = get_sample_info(tumour_analysis.get('samples'))

tests/data/1a7df8db-cb54-43e1-952f-3c458a14800a.variant_calling.payload.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"analysisType": {
33
"name": "variant_calling"
44
},
5+
"info": {
6+
"origin": "ICGC-25K"
7+
},
58
"studyId": "TEST-PR",
69
"experiment": {
710
"experimental_strategy": "WGS",

tests/data/66f84b1e-dad1-4981-916e-07e62ff53410.variant_calling_supplement.payload.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"analysisType": {
33
"name": "variant_calling_supplement"
44
},
5+
"info": {
6+
"origin": "ICGC-25K"
7+
},
58
"studyId": "TEST-PR",
69
"experiment": {
710
"experimental_strategy": "WGS",

tests/data/735a4c34-c928-4f03-957b-fe808df68f63.qc_metrics.payload.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"analysisType": {
33
"name": "qc_metrics"
44
},
5+
"info": {
6+
"origin": "ICGC-25K"
7+
},
58
"studyId": "TEST-PR",
69
"experiment": {
710
"experimental_strategy": "WGS",

tests/data/7ad90309-21df-4345-9903-0921df73456b.sequencing_alignment.analysis.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"info": {
3+
"origin": "ICGC-25K"
4+
},
25
"analysisId": "7ad90309-21df-4345-9903-0921df73456b",
36
"studyId": "TEST-PR",
47
"analysisState": "PUBLISHED",

tests/data/f7ca0bd4-53a7-4663-b7b6-1b3d414e0018.variant_calling.payload.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"analysisType": {
33
"name": "variant_calling"
44
},
5+
"info": {
6+
"origin": "ICGC-25K"
7+
},
58
"studyId": "TEST-PR",
69
"experiment": {
710
"experimental_strategy": "WGS",

0 commit comments

Comments
 (0)