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+
3640def 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+
87100def 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 :
0 commit comments