Locked History Actions

attachment:step_5.py of Events/GCC2013/TrainingDay/API

Attachment 'step_5.py'

Download

   1 #!/usr/bin/env python
   2 
   3 """
   4 Step 5
   5 ======
   6 In this step, we'll create a new history named 'Step 5' and upload a file
   7 to it to create a new HDA.
   8 """
   9 import os
  10 import sys
  11 import pprint
  12 
  13 import users_1
  14 import histories_3
  15 # note: that we're using the new tools module for this step
  16 import tools_1
  17 # and we're using the new get_hda from hdas_2
  18 import hdas_2
  19 
  20 NEW_HISTORY_NAME = 'Step 5'
  21 # we'll now store the name of the file to upload here
  22 DATA_TO_UPLOAD = 'data/myIlluminaRun.solexa.fastq'
  23 
  24 # ----------------------------------------------------------------------------- main
  25 if __name__ == '__main__':
  26     try:
  27         # check the connection
  28         users = users_1.get_users()
  29 
  30         # create a new history
  31         new_history = histories_3.create_history( NEW_HISTORY_NAME )
  32         print 'created history!', new_history[ 'name' ]
  33         new_history_id = new_history[ 'id' ]
  34         new_history_details = histories_3.get_history( new_history_id )
  35 
  36         # upload a file - the tool API will generally return a list of 'outputs' when
  37         #   running a tool. Since we know there will only be one output from the upload tool, grab it
  38         tool_output_datasets = tools_1.upload_hda( new_history_id, DATA_TO_UPLOAD )
  39         # outputs is a list of dictionaries
  40         uploaded_file_data = tool_output_datasets[ 'outputs' ][0]
  41         print 'uploaded hda!', uploaded_file_data[ 'name' ]
  42         uploaded_file_id = uploaded_file_data[ 'id' ]
  43 
  44         # get the (not empty!) list of hdas inside that history
  45         hdas = hdas_2.get_hdas( new_history_id )
  46         # and use get_hda to get details on the new, uploaded HDA
  47         uploaded_hda_details = hdas_2.get_hda( new_history_id, uploaded_file_id )
  48         
  49     except Exception, exc:
  50         print 'Error uploading file to history:', str( exc )
  51         sys.exit( 1 )
  52 
  53     print 'HDAs now:'
  54     pprint.pprint( hdas, indent=2 )
  55     print 'Uploaded:'
  56     pprint.pprint( uploaded_hda_details, indent=2 )

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2013-06-24 16:01:09, 8.2 KB) [[attachment:Galaxy-Workflow-Joined_Solexa_QC.ga]]
  • [get | view] (2013-06-24 16:46:36, 14.0 KB) [[attachment:all-scripts.tar.gz]]
  • [get | view] (2013-06-24 16:01:23, 5.2 KB) [[attachment:common.py]]
  • [get | view] (2013-06-24 16:04:07, 0.9 KB) [[attachment:datasets_1.py]]
  • [get | view] (2013-06-24 16:04:15, 1.2 KB) [[attachment:datasets_2.py]]
  • [get | view] (2013-06-24 16:04:22, 3.4 KB) [[attachment:datasets_3.py]]
  • [get | view] (2013-06-24 16:04:33, 1.5 KB) [[attachment:hdas_1.py]]
  • [get | view] (2013-06-24 16:04:50, 1.7 KB) [[attachment:hdas_2.py]]
  • [get | view] (2013-06-24 16:05:07, 2.2 KB) [[attachment:hdas_3.py]]
  • [get | view] (2013-06-24 16:03:38, 0.9 KB) [[attachment:histories_1.py]]
  • [get | view] (2013-06-24 16:03:52, 2.1 KB) [[attachment:histories_2.py]]
  • [get | view] (2013-06-24 16:05:25, 2.2 KB) [[attachment:histories_3.py]]
  • [get | view] (2013-06-24 16:05:34, 3.3 KB) [[attachment:lddas_1.py]]
  • [get | view] (2013-06-24 16:05:41, 1.3 KB) [[attachment:libraries_1.py]]
  • [get | view] (2013-06-24 16:01:36, 0.8 KB) [[attachment:setup.py]]
  • [get | view] (2013-06-24 16:02:45, 1.1 KB) [[attachment:step_1.py]]
  • [get | view] (2013-06-24 16:07:15, 9.9 KB) [[attachment:step_10.py]]
  • [get | view] (2013-06-24 16:03:28, 1.4 KB) [[attachment:step_2.py]]
  • [get | view] (2013-06-24 16:06:01, 1.6 KB) [[attachment:step_3.py]]
  • [get | view] (2013-06-24 16:06:11, 1.1 KB) [[attachment:step_4.py]]
  • [get | view] (2013-06-24 16:06:20, 1.9 KB) [[attachment:step_5.py]]
  • [get | view] (2013-06-24 16:06:44, 2.5 KB) [[attachment:step_6.py]]
  • [get | view] (2013-06-24 16:06:53, 4.9 KB) [[attachment:step_7.py]]
  • [get | view] (2013-06-24 16:07:05, 5.9 KB) [[attachment:step_8.py]]
  • [get | view] (2013-06-30 13:51:46, 8.0 KB) [[attachment:step_9.py]]
  • [get | view] (2013-06-24 16:41:51, 1.8 KB) [[attachment:tools_1.py]]
  • [get | view] (2013-06-24 16:44:32, 2.0 KB) [[attachment:upload_to_history.py]]
  • [get | view] (2013-06-24 16:03:03, 1.3 KB) [[attachment:users_1.py]]
  • [get | view] (2013-06-24 16:44:44, 2.9 KB) [[attachment:workflows_1.py]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.