Skip to content

Commit aa89a09

Browse files
committed
changes to address pr comments
1 parent 4dc976e commit aa89a09

9 files changed

Lines changed: 58 additions & 33 deletions

payload-gen-variant-filtering/main.nf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ params.files_to_upload = []
4949
params.wf_name = ""
5050
params.wf_short_name = ""
5151
params.wf_version = ""
52+
params.controlled = false
5253

5354

5455
process payloadGenVariantFiltering {
@@ -64,24 +65,25 @@ process payloadGenVariantFiltering {
6465
val wf_name
6566
val wf_short_name
6667
val wf_version
68+
val controlled
6769

6870
output: // output, make update as needed
6971
path "*.payload.json", emit: payload
7072

7173
script:
7274
// add and initialize variables here as needed
75+
arg_controlled = controlled ? "-c" : ""
7376

74-
"""
75-
mkdir -p output_dir
76-
77+
"""
7778
main.py \
7879
-a ${analysis} \
7980
-f ${files_to_upload} \
8081
-w ${wf_name} \
8182
-s ${wf_short_name} \
8283
-v ${wf_version} \
8384
-r ${workflow.runName} \
84-
-j ${workflow.sessionId}
85+
-j ${workflow.sessionId} \
86+
${arg_controlled}
8587
8688
"""
8789
}
@@ -95,6 +97,7 @@ workflow {
9597
Channel.fromPath(params.files_to_upload).collect(),
9698
params.wf_name,
9799
params.wf_short_name,
98-
params.wf_version
100+
params.wf_version,
101+
params.controlled
99102
)
100103
}

payload-gen-variant-filtering/main.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
'indel': ['Simple Nucleotide Variation', 'Raw InDel Calls', ['Pindel', 'bcftools'], ['GATK-Mutect2', 'bcftools']]
3434
}
3535

36+
workflow_full_name = {
37+
'open-access-variant-filtering': 'Open Access Variant Filtering'
38+
}
39+
3640
def calculate_size(file_path):
3741
return os.stat(file_path).st_size
3842

@@ -45,16 +49,15 @@ def calculate_md5(file_path):
4549
return md5.hexdigest()
4650

4751

48-
def get_files_info(file_to_upload):
49-
basename = os.path.basename(file_to_upload)
50-
input_wf = basename.split(".")[5]
51-
variant_type = basename.split(".")[7]
52+
def get_files_info(file_to_upload, args, input_wf, variant_type):
53+
basename = os.path.basename(file_to_upload).replace("filtered", args.wf_short_name)
54+
5255
file_info = {
5356
'fileName': basename,
5457
'fileType': 'VCF' if basename.endswith('.vcf.gz') else basename.split(".")[-1].upper(),
5558
'fileSize': calculate_size(file_to_upload),
5659
'fileMd5sum': calculate_md5(file_to_upload),
57-
'fileAccess': 'open',
60+
'fileAccess': 'open' if not args.controlled else 'controlled',
5861
'info': {
5962
'data_category': variant_type_to_data_type_etc[variant_type][0]
6063
}
@@ -84,6 +87,16 @@ def get_sample_info(sample_list):
8487

8588
return samples
8689

90+
def get_variant_type(analysis):
91+
for f in analysis.get('files'):
92+
if f.get('dataType') == "VCF Index": continue
93+
if f.get('dataType') == "Raw SNV Calls":
94+
variant_type = 'snv'
95+
elif f.get('dataType') == "Raw InDel Calls":
96+
variant_type = 'indel'
97+
98+
return variant_type
99+
87100
def main():
88101
"""
89102
Python implementation of tool: payload-gen-variant-filtering
@@ -98,13 +111,17 @@ def main():
98111
parser.add_argument("-v", dest="wf_version", type=str, required=True, help="workflow version")
99112
parser.add_argument("-r", dest="wf_run", type=str, required=True, help="workflow run ID")
100113
parser.add_argument("-j", dest="wf_session", type=str, required=True, help="workflow session ID")
114+
parser.add_argument("-c", dest="controlled", action='store_true', help="set file to be controlled access")
101115
args = parser.parse_args()
102116

103117
analysis = {}
104118
with open(args.analysis, 'r') as f:
105119
analysis = json.load(f)
106120

107121
input_analysis_type = analysis.get('analysisType').get('name')
122+
input_wf = analysis.get('workflow', {}).get('workflow_short_name')
123+
variant_type = get_variant_type(analysis)
124+
108125
output_analysis_type = "variant_filtering"
109126
payload = {
110127
'analysisType': {
@@ -115,7 +132,7 @@ def main():
115132
'samples': get_sample_info(analysis.get('samples')),
116133
'files': [],
117134
'workflow': {
118-
'workflow_name': 'Open Access Variant Filtering',
135+
'workflow_name': workflow_full_name.get(args.wf_name),
119136
'workflow_short_name': args.wf_short_name,
120137
'workflow_version': args.wf_version,
121138
'run_id': args.wf_run,
@@ -132,7 +149,7 @@ def main():
132149
}
133150

134151
for f in args.files_to_upload:
135-
file_info = get_files_info(f)
152+
file_info = get_files_info(f, args, input_wf, variant_type)
136153
payload['files'].append(file_info)
137154

138155
with open("%s.%s.payload.json" % (str(uuid.uuid4()), output_analysis_type), 'w') as f:

payload-gen-variant-filtering/tests/checker.nf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ params.files_to_upload = []
4848
params.wf_name = ""
4949
params.wf_short_name = ""
5050
params.wf_version = ""
51+
params.controlled = false
5152
params.expected_output = ""
5253

5354
include { payloadGenVariantFiltering } from '../main'
@@ -78,6 +79,7 @@ workflow checker {
7879
wf_name
7980
wf_short_name
8081
wf_version
82+
controlled
8183
expected_output
8284

8385
main:
@@ -86,7 +88,8 @@ workflow checker {
8688
files_to_upload,
8789
wf_name,
8890
wf_short_name,
89-
wf_version
91+
wf_version,
92+
controlled
9093
)
9194

9295
file_smart_diff(
@@ -103,6 +106,7 @@ workflow {
103106
params.wf_name,
104107
params.wf_short_name,
105108
params.wf_version,
109+
params.controlled,
106110
file(params.expected_output)
107111
)
108112
}

payload-gen-variant-filtering/tests/expected/expected.gatk-mutect2.filtered.snv.payload.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
],
2727
"files": [
2828
{
29-
"fileName": "TEST-PR.DO250183.SA610229.wgs.20200922.gatk-mutect2.somatic.snv.filtered.vcf.gz",
29+
"fileName": "TEST-PR.DO250183.SA610229.wgs.20200922.gatk-mutect2.somatic.snv.open-filter.vcf.gz",
3030
"fileType": "VCF",
3131
"fileSize": 23947,
3232
"fileMd5sum": "1ebce71c8231aeb7ac6c06c92adfd5db",
@@ -41,7 +41,7 @@
4141
"dataType": "Raw SNV Calls"
4242
},
4343
{
44-
"fileName": "TEST-PR.DO250183.SA610229.wgs.20200922.gatk-mutect2.somatic.snv.filtered.vcf.gz.tbi",
44+
"fileName": "TEST-PR.DO250183.SA610229.wgs.20200922.gatk-mutect2.somatic.snv.open-filter.vcf.gz.tbi",
4545
"fileType": "TBI",
4646
"fileSize": 185,
4747
"fileMd5sum": "7a8482dc43849a4ee8bdd4c9c77fae0c",
@@ -58,10 +58,10 @@
5858
],
5959
"workflow": {
6060
"workflow_name": "Open Access Variant Filtering",
61-
"workflow_short_name": "variant-filtering",
61+
"workflow_short_name": "open-filter",
6262
"workflow_version": "0.1.0",
63-
"run_id": "nice_easley",
64-
"session_id": "f8271e1f-a0b8-466f-9dc0-c95bd3ec9c83",
63+
"run_id": "maniac_saha",
64+
"session_id": "cb4d9dc6-d0b2-4998-bfae-80976e1ded55",
6565
"inputs": [
6666
{
6767
"input_analysis_id": "ca105e4d-d16b-461c-905e-4dd16b861cc8",

payload-gen-variant-filtering/tests/expected/expected.sanger-wgs.filtered.snv.payload.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
],
2727
"files": [
2828
{
29-
"fileName": "TEST-PR.DO250183.SA610229.wgs.20200513.sanger-wgs.somatic.snv.filtered.vcf.gz",
29+
"fileName": "TEST-PR.DO250183.SA610229.wgs.20200513.sanger-wgs.somatic.snv.open-filter.vcf.gz",
3030
"fileType": "VCF",
3131
"fileSize": 23947,
3232
"fileMd5sum": "1ebce71c8231aeb7ac6c06c92adfd5db",
33-
"fileAccess": "open",
33+
"fileAccess": "controlled",
3434
"info": {
3535
"data_category": "Simple Nucleotide Variation",
3636
"analysis_tools": [
@@ -41,11 +41,11 @@
4141
"dataType": "Raw SNV Calls"
4242
},
4343
{
44-
"fileName": "TEST-PR.DO250183.SA610229.wgs.20200513.sanger-wgs.somatic.snv.filtered.vcf.gz.tbi",
44+
"fileName": "TEST-PR.DO250183.SA610229.wgs.20200513.sanger-wgs.somatic.snv.open-filter.vcf.gz.tbi",
4545
"fileType": "TBI",
4646
"fileSize": 185,
4747
"fileMd5sum": "7a8482dc43849a4ee8bdd4c9c77fae0c",
48-
"fileAccess": "open",
48+
"fileAccess": "controlled",
4949
"info": {
5050
"data_category": "Simple Nucleotide Variation",
5151
"analysis_tools": [
@@ -58,10 +58,10 @@
5858
],
5959
"workflow": {
6060
"workflow_name": "Open Access Variant Filtering",
61-
"workflow_short_name": "variant-filtering",
61+
"workflow_short_name": "open-filter",
6262
"workflow_version": "0.1.0",
63-
"run_id": "crazy_elion",
64-
"session_id": "fe789152-666b-4915-946b-61bacd19e292",
63+
"run_id": "festering_davinci",
64+
"session_id": "33388531-767b-4fd4-ba84-1c6732983ae1",
6565
"inputs": [
6666
{
6767
"input_analysis_id": "3414534a-47a4-492d-9453-4a47a4192d6d",

payload-gen-variant-filtering/tests/expected/expected.sanger-wxs.filtered.indel.payload.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
],
2727
"files": [
2828
{
29-
"fileName": "TEST-PR.DO250183.SA610229.wxs.20200911.sanger-wxs.somatic.indel.filtered.vcf.gz",
29+
"fileName": "TEST-PR.DO250183.SA610229.wxs.20200911.sanger-wxs.somatic.indel.open-filter.vcf.gz",
3030
"fileType": "VCF",
3131
"fileSize": 23947,
3232
"fileMd5sum": "1ebce71c8231aeb7ac6c06c92adfd5db",
@@ -41,7 +41,7 @@
4141
"dataType": "Raw InDel Calls"
4242
},
4343
{
44-
"fileName": "TEST-PR.DO250183.SA610229.wxs.20200911.sanger-wxs.somatic.indel.filtered.vcf.gz.tbi",
44+
"fileName": "TEST-PR.DO250183.SA610229.wxs.20200911.sanger-wxs.somatic.indel.open-filter.vcf.gz.tbi",
4545
"fileType": "TBI",
4646
"fileSize": 185,
4747
"fileMd5sum": "7a8482dc43849a4ee8bdd4c9c77fae0c",
@@ -58,10 +58,10 @@
5858
],
5959
"workflow": {
6060
"workflow_name": "Open Access Variant Filtering",
61-
"workflow_short_name": "variant-filtering",
61+
"workflow_short_name": "open-filter",
6262
"workflow_version": "0.1.0",
63-
"run_id": "exotic_booth",
64-
"session_id": "154945ec-df0f-4ec8-ae23-ff8cdab626e0",
63+
"run_id": "adoring_mercator",
64+
"session_id": "cd1fcd50-3231-4ce6-9dec-722ed044d970",
6565
"inputs": [
6666
{
6767
"input_analysis_id": "775eeab5-9cbf-4443-9eea-b59cbf144389",

payload-gen-variant-filtering/tests/test-job-1.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
],
77
"expected_output": "expected/expected.sanger-wgs.filtered.snv.payload.json",
88
"wf_name": "open-access-variant-filtering",
9-
"wf_short_name": "variant-filtering",
9+
"wf_short_name": "open-filter",
1010
"wf_version": "0.1.0",
11+
"controlled": true,
1112
"publish_dir": "outdir",
1213
"cpus": 1,
1314
"mem": 0.5

payload-gen-variant-filtering/tests/test-job-2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"expected_output": "expected/expected.gatk-mutect2.filtered.snv.payload.json",
88
"wf_name": "open-access-variant-filtering",
9-
"wf_short_name": "variant-filtering",
9+
"wf_short_name": "open-filter",
1010
"wf_version": "0.1.0",
1111
"publish_dir": "outdir",
1212
"cpus": 1,

payload-gen-variant-filtering/tests/test-job-3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"expected_output": "expected/expected.sanger-wxs.filtered.indel.payload.json",
88
"wf_name": "open-access-variant-filtering",
9-
"wf_short_name": "variant-filtering",
9+
"wf_short_name": "open-filter",
1010
"wf_version": "0.1.0",
1111
"publish_dir": "outdir",
1212
"cpus": 1,

0 commit comments

Comments
 (0)