mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Allow setting dataset attributes of additional primary datasets through galaxy.json.
This commit is contained in:
@@ -2623,10 +2623,19 @@ class Tool:
|
||||
Find any additional datasets generated by a tool and attach (for
|
||||
cases where number of outputs is not known in advance).
|
||||
"""
|
||||
primary_datasets = {}
|
||||
new_primary_datasets = {}
|
||||
try:
|
||||
json_file = open( os.path.join( job_working_directory, jobs.TOOL_PROVIDED_JOB_METADATA_FILE ), 'r' )
|
||||
for line in json_file:
|
||||
line = simplejson.loads( line )
|
||||
if line.get( 'type' ) == 'new_primary_dataset':
|
||||
new_primary_datasets[ os.path.split( line.get( 'filename' ) )[-1] ] = line
|
||||
except Exception, e:
|
||||
log.debug( "Error opening galaxy.json file: %s" % e )
|
||||
# Loop through output file names, looking for generated primary
|
||||
# datasets in form of:
|
||||
# 'primary_associatedWithDatasetID_designation_visibility_extension(_DBKEY)'
|
||||
primary_datasets = {}
|
||||
for name, outdata in output.items():
|
||||
filenames = []
|
||||
if 'new_file_path' in self.app.config.collect_outputs_from:
|
||||
@@ -2664,8 +2673,6 @@ class Tool:
|
||||
primary_data.info = outdata.info
|
||||
primary_data.init_meta( copy_from=outdata )
|
||||
primary_data.dbkey = dbkey
|
||||
primary_data.set_meta()
|
||||
primary_data.set_peek()
|
||||
# Associate new dataset with job
|
||||
job = None
|
||||
for assoc in outdata.creating_job_associations:
|
||||
@@ -2677,6 +2684,15 @@ class Tool:
|
||||
self.sa_session.add( assoc )
|
||||
self.sa_session.flush()
|
||||
primary_data.state = outdata.state
|
||||
#add tool/metadata provided information
|
||||
new_primary_datasets_attributes = new_primary_datasets.get( os.path.split( filename )[-1] )
|
||||
if new_primary_datasets_attributes:
|
||||
dataset_att_by_name = dict( ext='extension' )
|
||||
for att_set in [ 'name', 'info', 'ext', 'dbkey' ]:
|
||||
dataset_att_name = dataset_att_by_name.get( att_set, att_set )
|
||||
setattr( primary_data, dataset_att_name, new_primary_datasets_attributes.get( att_set, getattr( primary_data, dataset_att_name ) ) )
|
||||
primary_data.set_meta()
|
||||
primary_data.set_peek()
|
||||
self.sa_session.add( primary_data )
|
||||
self.sa_session.flush()
|
||||
outdata.history.add_dataset( primary_data )
|
||||
|
||||
Reference in New Issue
Block a user