Locked History Actions

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

Attachment 'hdas_3.py'

Download

   1 #!/usr/bin/env python
   2 
   3 """
   4 Access a Galaxy instance and get data for HistoryDatasetAssociations.
   5 """
   6 import os
   7 import sys
   8 import pprint
   9 
  10 import setup
  11 import common
  12 
  13 RESOURCE_URL = '/api/histories'
  14 
  15 # ----------------------------------------------------------------------------- functions
  16 def get_hdas( history_id ):
  17     """
  18     Return a list of dictionaries that describe the HDAs *in* a *specifc* history.
  19     :param history_id: the id of the history which we want to query.
  20     """
  21     # similar users.get_users and histories.get_histories, but
  22     apikey = setup.get_apikey()
  23     container_url = setup.get_base_url() + RESOURCE_URL
  24 
  25     # ...note that we'll add the id of a specific history to 'look inside of'
  26     #   and the keyword 'contents'
  27     full_url = container_url + '/' + history_id + '/contents'
  28     return common.get( apikey, full_url )
  29 
  30 def get_hda( history_id, hda_id ):
  31     """
  32     Return a dictionary of detailed information for a specific HDA.
  33     :param history_id: the id of the history which we want to query.
  34     :param hda_id: the id of the HDA which we want to query.
  35     """
  36     apikey = setup.get_apikey()
  37     container_url = setup.get_base_url() + RESOURCE_URL
  38 
  39     full_url = container_url + '/' + history_id + '/contents/' + hda_id
  40     return common.get( apikey, full_url )
  41 
  42 def update_hda( history_id, hda_id, new_data ):
  43     """
  44     Change an HDA by sending it new data.
  45     :param history_id: the id of the history which we want to change.
  46     :param hda_id: the id of the HDA which we want to change.
  47     :param new_data: a dictionary containing the data to change.
  48     """
  49     apikey = setup.get_apikey()
  50     container_url = setup.get_base_url() + RESOURCE_URL
  51 
  52     full_url = container_url + '/' + history_id + '/contents/' + hda_id
  53     return common.put( apikey, full_url, new_data )
  54 
  55 
  56 # ----------------------------------------------------------------------------- main
  57 if __name__ == '__main__':
  58     # no changes here - check step_9 for an example use of update_hda
  59     if len( sys.argv ) <= 2:
  60         print 'USAGE: hdas_1.py <history id> <hda_id>'
  61         sys.exit( 1 )
  62 
  63     history_id = sys.argv[1]
  64     hda_id     = sys.argv[2]
  65     returned = get_hda( history_id, hda_id )
  66     pprint.pprint( returned, 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.