comparison queue_genotype_workflow.py @ 6:b7212fe2d597 draft

Uploaded
author greg
date Mon, 02 Dec 2019 09:17:50 -0500
parents 163ecfba5961
children 41477ff2ce8e
comparison
equal deleted inserted replaced
5:934acc64b30c 6:b7212fe2d597
20 parser.add_argument('--config_file', dest='config_file', help='qgw_config.ini') 20 parser.add_argument('--config_file', dest='config_file', help='qgw_config.ini')
21 parser.add_argument('--dbkey', dest='dbkey', help='Reference genome dbkey') 21 parser.add_argument('--dbkey', dest='dbkey', help='Reference genome dbkey')
22 parser.add_argument('--reference_genome', dest='reference_genome', help='Reference genome') 22 parser.add_argument('--reference_genome', dest='reference_genome', help='Reference genome')
23 parser.add_argument('--history_id', dest='history_id', help='Encoded id of current history') 23 parser.add_argument('--history_id', dest='history_id', help='Encoded id of current history')
24 parser.add_argument('--output', dest='output', help='Output dataset') 24 parser.add_argument('--output', dest='output', help='Output dataset')
25 parser.add_argument('--output_nj_phylogeny_tree', dest='output_nj_phylogeny_tree', help='Flag to plot neighbor-joining phylogeny tree')
25 parser.add_argument('--report', dest='report', help='Apt-probeset genotype report file') 26 parser.add_argument('--report', dest='report', help='Apt-probeset genotype report file')
26 parser.add_argument('--sample_attributes', dest='sample_attributes', help='Sample attributes tabular file') 27 parser.add_argument('--sample_attributes', dest='sample_attributes', help='Sample attributes tabular file')
27 parser.add_argument('--snp-posteriors', dest='snp-posteriors', help='Apt-probeset genotype snp-posteriors file') 28 parser.add_argument('--snp-posteriors', dest='snp-posteriors', help='Apt-probeset genotype snp-posteriors file')
28 parser.add_argument('--summary', dest='summary', help='Apt-probeset genotype summary file') 29 parser.add_argument('--summary', dest='summary', help='Apt-probeset genotype summary file')
29 args = parser.parse_args() 30 args = parser.parse_args()
231 outputfh.write("\nRenaming library dataset with id %s to be named %s.\n" % (str(dataset_id), str(name))) 232 outputfh.write("\nRenaming library dataset with id %s to be named %s.\n" % (str(dataset_id), str(name)))
232 library_dataset_dict = gi.libraries.update_library_dataset(dataset_id, name=name) 233 library_dataset_dict = gi.libraries.update_library_dataset(dataset_id, name=name)
233 return library_dataset_dict 234 return library_dataset_dict
234 235
235 236
236 def update_workflow_params(workflow_dict, dbkey, outputfh): 237 def update_workflow_params(workflow_dict, dbkey, output_nj_phylogeny_tree, outputfh):
237 parameter_updates = None 238 parameter_updates = None
238 name = workflow_dict['name'] 239 name = workflow_dict['name']
239 outputfh.write("\nChecking for tool parameter updates for workflow %s using dbkey %s.\n" % (name, dbkey)) 240 outputfh.write("\nChecking for tool parameter updates for workflow %s using dbkey %s.\n" % (name, dbkey))
240 step_dicts = workflow_dict.get('steps', None) 241 step_dicts = workflow_dict.get('steps', None)
241 for step_id, step_dict in list(step_dicts.items()): 242 for step_id, step_dict in list(step_dicts.items()):
255 # The value of reference_genome_source_cond_dict['reference_genome_source'] 256 # The value of reference_genome_source_cond_dict['reference_genome_source']
256 # will always be 'cached'. 257 # will always be 'cached'.
257 workflow_db_key = reference_genome_source_cond_dict['locally_cached_item'] 258 workflow_db_key = reference_genome_source_cond_dict['locally_cached_item']
258 if dbkey != workflow_db_key: 259 if dbkey != workflow_db_key:
259 reference_genome_source_cond_dict['locally_cached_item'] = dbkey 260 reference_genome_source_cond_dict['locally_cached_item'] = dbkey
260 parameter_updates = {} 261 if parameter_updates is None:
262 parameter_updates = {}
261 parameter_updates[step_id] = reference_genome_source_cond_dict 263 parameter_updates[step_id] = reference_genome_source_cond_dict
262 outputfh.write("Updated step id %s with the following entry:\n%s\n" % (step_id, str(reference_genome_source_cond_dict))) 264 outputfh.write("Updated step id %s with the following entry:\n%s\n" % (step_id, str(reference_genome_source_cond_dict)))
265 if tool_id.find('coral_multilocus_genotype') > 0 and output_nj_phylogeny_tree == 'yes':
266 # Reset the default value 'no' of output_nj_phylogeny_tree to 'yes'.
267 if parameter_updates is None:
268 parameter_updates = {}
269 output_nj_phylogeny_tree_dict = {'output_nj_phylogeny_tree' : 'yes'}
270 parameter_updates[step_id] = output_nj_phylogeny_tree_dict
271 outputfh.write("Updated step id %s with the following entry:\n%s\n" % (step_id, str(output_nj_phylogeny_tree_dict)))
263 return parameter_updates 272 return parameter_updates
264 273
265 274
266 outputfh = open(args.output, "w") 275 outputfh = open(args.output, "w")
267 config_defaults = get_config_settings(args.config_file) 276 config_defaults = get_config_settings(args.config_file)
370 # Map the history datasets to the input datasets for 379 # Map the history datasets to the input datasets for
371 # the CoralSNP workflow. 380 # the CoralSNP workflow.
372 coralsnp_workflow_input_datasets = get_workflow_input_datasets(gi, history_datasets, coralsnp_workflow_name, coralsnp_workflow_dict, outputfh) 381 coralsnp_workflow_input_datasets = get_workflow_input_datasets(gi, history_datasets, coralsnp_workflow_name, coralsnp_workflow_dict, outputfh)
373 outputfh.write("\nCoralSNP workflow input datasets: %s\n" % str(coralsnp_workflow_input_datasets)) 382 outputfh.write("\nCoralSNP workflow input datasets: %s\n" % str(coralsnp_workflow_input_datasets))
374 # Get the CoralSNP workflow params that could be updated. 383 # Get the CoralSNP workflow params that could be updated.
375 coralsnp_params = update_workflow_params(coralsnp_workflow_dict, args.dbkey, outputfh) 384 coralsnp_params = update_workflow_params(coralsnp_workflow_dict, args.dbkey, args.output_nj_phylogeny_tree, outputfh)
376 outputfh.write("\nCoralSNP params: %s\n" % str(coralsnp_params)) 385 outputfh.write("\nCoralSNP params: %s\n" % str(coralsnp_params))
377 # Start the CoralSNP workflow. 386 # Start the CoralSNP workflow.
378 start_workflow(gi, coralsnp_workflow_id, coralsnp_workflow_name, coralsnp_workflow_input_datasets, coralsnp_params, args.history_id, outputfh) 387 start_workflow(gi, coralsnp_workflow_id, coralsnp_workflow_name, coralsnp_workflow_input_datasets, coralsnp_params, args.history_id, outputfh)
379 outputfh.write("\nSleeping for 15 seconds...\n") 388 outputfh.write("\nSleeping for 15 seconds...\n")
380 time.sleep(15) 389 time.sleep(15)