# HG changeset patch # User epigenome # Date 1460227853 14400 # Node ID 11b4dfe32bc3413b206c0a862368c7f4309bd7e4 planemo upload for repository https://github.com/epigenome/galaxy-epigenome/tree/history/tools/history_summary commit 2e0a8a269e408eab18f8dbd67beed656f7694042 diff -r 000000000000 -r 11b4dfe32bc3 history_summary.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/history_summary.xml Sat Apr 09 14:50:53 2016 -0400 @@ -0,0 +1,360 @@ + + generates a html for summarizing the current history contents along with renaming the output files + + + + + + > $output; + #end def + + #def enum_DatasetCollection($dsc, $jobs) + #for $el in $dsc.elements + #if $el.hda + $enum_HistoryDatasetAssociation($el.hda, $jobs) + #elif $el.ldda + $enum_LibraryDatasetAssociation($el.ldda, $jobs) + #elif $el.child_collection + $enum_DatasetCollection($el.child_collection, $jobs) + #end if + #end for + #end def + + #def print_JobToDataAssociation($jda, $useName, $rules, $isOutput=False) + #if $jda.dataset + #set $buf = "
  • " + #if $useName + #set $buf += $jda.name + ": " + #end if + #set $buf += "" + #if $rules and $rules.has_key(str($jda.dataset.id)) + #set $file = $rules[str($jda.dataset.id)] + #else + #set $file = $jda.dataset.name + #end if + #if $isOutput and $save_zip + ln -s "$jda.dataset.get_file_name()" "$os.path.join($history.name, $file)"; + #end if + echo "$buf$file
  • " >> $output; + #end if + #end def + + #def print_JobParameter($parameters, $ident) + #for $par in $parameters + echo "${ident}P:$par.name '$par.value'" >> $output; + #end for + #end def + + #def job_state_color($job) + #if $job.state == $job.states.OK + #return "#B0F1B0" + #elif $job.state == $job.states.RUNNING + #return "#FFFFCC" + #elif $job.state == $job.states.QUEUED + #return "#FFFFCC" + #elif $job.state == $job.states.WAITING + #return "#EEE" + #end if + #return "#F9C7C5" + #end def + + #def print_Job($job, $rules=None, $ident="") + echo "" >> $output; + echo "$job.tool_id$job.exit_code" >> $output; + echo "" >> $output; + #for $jda in $job.input_datasets + $print_JobToDataAssociation($jda, True, $rules) + #end for + echo "" >> $output; + echo "" >> $output; + #for $jda in $job.output_datasets + $print_JobToDataAssociation($jda, False, $rules, True) + #end for + echo "" >> $output; + #* + #for $jda in $job.input_dataset_collections + $print_JobToDataAssociation($jda) + #end for + #for $jda in $job.output_dataset_collections + $print_JobToDataAssociation($jda) + #end for + #for $jda in $job.input_library_datasets + $print_JobToDataAssociation($jda) + #end for + #for $jda in $job.output_library_datasets + $print_JobToDataAssociation($jda) + #end for + *# + #end def + + #def enum_LibraryDatasetAssociation($hda, $jobs) + #end def + + #def enum_HistoryDatasetAssociation($hda, $jobs) + #if ($use_deleted or $hda.deleted == False) and ($use_hidden or $hda.visible == True) + #set $original_hda = $hda + #for $assoc in $original_hda.creating_job_associations + #set $jobs[$assoc.job.id] = $assoc.job + #end for + #end if + #end def + + #def enum_HistoryDatasetCollectionAssociation($hdca, $jobs) + #if ($use_deleted or $hdca.deleted == False) and ($use_hidden or $hdca.visible == True) + #set $dsc = $hdca.collection + $enum_DatasetCollection($dsc, $jobs) + #end if + #end def + + #def get_output_file($file, $jda) + #if $jda.name + #if $file != "" + #set $file += "." + #end if + #set $file += $jda.name + #end if + #if $jda.dataset.extension + #if $file != "" + #set $file += "." + #end if + #set $file += $jda.dataset.extension + #end if + #return $file + #end def + + #def rename_file($file, $rep) + #for $k, $v in $rep.iteritems() + #set $file = $file.replace($k, $v) + #end for + #return $file + #end def + + #set global $history = $output.creating_job.history + echo "" > $output; + echo "" >> $output; + echo " " >> $output; + echo " " >> $output; + echo " " >> $output; + echo "" >> $output; + echo "" >> $output; + echo "

    $history.name

    " >> $output; + + #set $order = [] + #set $conf = {} + #set $subst = {} + #set $lines = $configuration.rstrip().split('\n') + #if len($lines) > 1 or len($lines[0].rstrip()) > 0 + echo "

    Parameters for rename
    " >> $output; + #for $line in $lines + #set $arr = $line.split() + echo "$arr
    " >> $output; + $order.append($arr[0]) + #set $subst[$arr[0]] = {} + #if len($arr) == 1 + #set $subst[$arr[0]]["PREFIX"] = "" + #set $conf[$arr[0]] = "PREFIX" + #elif $arr[1].startswith("PREFIX=") + #set $z = $arr[1].split("=") + #set $subst[$arr[0]]["PREFIX"] = $z[1] if len($z) > 1 else "" + #set $conf[$arr[0]] = "PREFIX" + #else + #set $conf[$arr[0]] = $arr[1].replace(".", "_0X") + #end if + #for $x in $arr[2:] + #set $y = $x.split("=") + #set $subst[$arr[0]][$y[0]] = $y[1] if len($y) > 1 else "" + #end for + #end for + #end if + + #set $jobs = {} + #for $hda in $history.datasets + $enum_HistoryDatasetAssociation($hda, $jobs) + #end for + #for $hdca in $history.dataset_collections + $enum_HistoryDatasetCollectionAssociation($hdca, $jobs) + #end for + + #set $tools = {} + #set $specified_jobs = set() + #for $job_id, $job in $jobs.iteritems() + #set $arr = $job.tool_id.split('/') + #set $tar_tid = $arr[-1] + #if $re.match(r'^[0-9\\.]+$', $arr[-1], $re.M) + #set $tar_tid = $arr[-2] + #end if + #if not $tools.has_key($tar_tid) + #set $tools[$tar_tid] = [] + #end if + $tools[$tar_tid].append($job_id) + #if $conf.has_key($tar_tid) + $specified_jobs.add($job_id) + #end if + #end for + + #set $rules = {} + #for $tar_tid in $order if len($order) > 0 else $tools.keys() + #if $tools.has_key($tar_tid) + ##echo ">$tar_tid $conf.get($tar_tid) $"|".join($subst[$tar_tid].keys())
    " >> $output; + #for $tar_jid in $tools[$tar_tid] + #for $jda in $jobs[$tar_jid].input_datasets + #set $tar_new = None + #if $jda.dataset + #if $conf.get($tar_tid) == "PREFIX" + #set $tar_new = $subst[$tar_tid][$conf.get($tar_tid)] + #elif str($jda.name) == $conf.get($tar_tid) + #if $rules.has_key(str($jda.dataset.id)) + #set $tar_new = $rules[str($jda.dataset.id)] + #else + #set $tar_new = $jda.dataset.name + #if $tar_new.endswith(":forward") + #set $tar_new = $tar_new[:-8] + #end if + #if $tar_new.endswith(":forward") + #set $tar_new = $tar_new[:-8] + #end if + #end if + #end if + #if $tar_new != None + #break + #end if + #end if + #end for + #if $tar_new != None + #for $jda in $jobs[$tar_jid].output_datasets + #if $jda.dataset + #set $rules[str($jda.dataset.id)] = $rename_file($get_output_file($tar_new, $jda), $subst[$tar_tid]) + ##echo "[$tar_new | $jda.dataset.id | $rules[str($jda.dataset.id)]]
    " >> $output; + #end if + #end for + #end if + #end for + #end if + #end for + + #if $save_zip + mkdir "$history.name"; + #end if + + echo "

    " >> $output; + echo "" >> $output; + #for $job_id, $job in $jobs.iteritems() + #if $job_id != $output.creating_job.id and (not $use_specified or $job_id in $specified_jobs) + $print_Job($job, $rules) + #end if + #end for + echo "
    ToolECInputOutput
    " >> $output; + echo "" >> $output; + echo "" >> $output; + + #if $save_zip + rm $zip_file; zip -r $zip_file "$history.name"; + #end if + ]]> + + + + + + + + + + + + save_zip == True + + + +