HTS Workflow has a small API for downloading information about specific libraries or flowcells.

The core of the python code needed to access the api is as follows:

#!/usr/bin/env python
import json
import urllib
import urllib2

def retrieve_info(url, apidata):
    """
    Return a dictionary from the HTSworkflow API
    """
    try:
        apipayload = urllib.urlencode(apidata)
        web = urllib2.urlopen(url, apipayload)
    except urllib2.URLError, e:
        errmsg = 'URLError: %d %s' % (e.code, e.msg)
        raise IOError(errmsg)
    
    contents = web.read()
    headers = web.info()

    return json.loads(contents)

apidata needs to be a dictionary containing:

 { 'apiid': API_ID,
   'apikey': API_KEY,
 }

You'll need to ask for an ID and key.

Also hts_api.py is more complete example program.

The per library information returns a json formatted dictionary accessible at http://jumpgate.caltech.edu/samples/library/<library id>/json (There are libraries to parse JSON for most languages, and its a bit easier to work with than XML.)

The resulting data looks like the following.

{u'antibody_id': None,
 u'avg_lib_size': 225,
 u'cell_line': u'Unknown',
 u'cell_line_id': 1,
 u'experiment_type': u'RNA-seq',
 u'experiment_type_id': 4,
 u'id': u'10155',
 u'lane_set': [{u'flowcell': u'2038EAAXX', u'lane_number': 1},
               {u'flowcell': u'2023DAAXX', u'lane_number': 8}],
 u'library_id': u'10155',
 u'library_name': u'C57 Brain + Spikes (profile 2)',
 u'library_species': u'Mus musculus',
 u'library_species_id': 9,
 u'library_type': None,
 u'library_type_id': None,
 u'made_by': u'Brian',
 u'made_for': u'Brian',
 u'notes': u'2023DAAXX: (free form text field)',
 u'replicate': 1,
 u'stopping_point': u'1Aa',
 u'successful_pM': u'30523',
 u'undiluted_concentration': u'None'}

The flowcell information is accessible using the URL: http://jumpgate.caltech.edu/experiments/config/<Flowcell ID>/json and the resulting data looks like the following:

{u'advanced_run': False,
 u'cluster_station': u'old',
 u'cluster_station_id': 1,
 u'control_lane': None,
 u'flowcell_id': u'2023DAAXX',
 u'id': 8,
 u'lane_set': {u'1': {u'cluster_estimate': None,
                      u'comment': None,
                      u'experiment_type': u'RNA-seq',
                      u'experiment_type_id': 4,
                      u'flowcell': u'2023DAAXX',
                      u'lane_number': 1,
                      u'library_id': u'10127',
                      u'library_name': u'AFD RT-PCR new a',
                      u'library_species': u'Caenorhabditis elegans',
                      u'pM': u'3',
                      u'read_length': 32},
               u'2': {u'cluster_estimate': None,
                      u'comment': None,
                      u'experiment_type': u'RNA-seq',
                      u'experiment_type_id': 4,
                      u'flowcell': u'2023DAAXX',
                      u'lane_number': 2,
                      u'library_id': u'10127',
                      u'library_name': u'AFD RT-PCR new a',
                      u'library_species': u'Caenorhabditis elegans',
                      u'pM': u'3',
                      u'read_length': 32},
               u'3': {u'cluster_estimate': None,
                      u'comment': None,
                      u'experiment_type': u'RNA-seq',
                      u'experiment_type_id': 4,
                      u'flowcell': u'2023DAAXX',
                      u'lane_number': 3,
                      u'library_id': u'10128',
                      u'library_name': u'ASER RT-PCR new a',
                      u'library_species': u'Caenorhabditis elegans',
                      u'pM': u'3',
                      u'read_length': 32},
               u'4': {u'cluster_estimate': None,
                      u'comment': None,
                      u'experiment_type': u'RNA-seq',
                      u'experiment_type_id': 4,
                      u'flowcell': u'2023DAAXX',
                      u'lane_number': 4,
                      u'library_id': u'10129',
                      u'library_name': u'PLML RT-PCR new a',
                      u'library_species': u'Caenorhabditis elegans',
                      u'pM': u'3',
                      u'read_length': 32},
               u'5': {u'cluster_estimate': None,
                      u'comment': None,
                      u'experiment_type': u'RNA-seq',
                      u'experiment_type_id': 4,
                      u'flowcell': u'2023DAAXX',
                      u'lane_number': 5,
                      u'library_id': u'10155',
                      u'library_name': u'C57 Brain + Spikes (profile 2)',
                      u'library_species': u'Mus musculus',
                      u'pM': u'3',
                      u'read_length': 32},
               u'6': {u'cluster_estimate': None,
                      u'comment': None,
                      u'experiment_type': u'RNA-seq',
                      u'experiment_type_id': 4,
                      u'flowcell': u'2023DAAXX',
                      u'lane_number': 6,
                      u'library_id': u'10155',
                      u'library_name': u'C57 Brain + Spikes (profile 2)',
                      u'library_species': u'Mus musculus',
                      u'pM': u'3',
                      u'read_length': 32},
               u'7': {u'cluster_estimate': None,
                      u'comment': None,
                      u'experiment_type': u'RNA-seq',
                      u'experiment_type_id': 4,
                      u'flowcell': u'2023DAAXX',
                      u'lane_number': 7,
                      u'library_id': u'10155',
                      u'library_name': u'C57 Brain + Spikes (profile 2)',
                      u'library_species': u'Mus musculus',
                      u'pM': u'3',
                      u'read_length': 32},
               u'8': {u'cluster_estimate': None,
                      u'comment': None,
                      u'experiment_type': u'RNA-seq',
                      u'experiment_type_id': 4,
                      u'flowcell': u'2023DAAXX',
                      u'lane_number': 8,
                      u'library_id': u'10155',
                      u'library_name': u'C57 Brain + Spikes (profile 2)',
                      u'library_species': u'Mus musculus',
                      u'pM': u'3',
                      u'read_length': 32}},
 u'notes': u'Lot #s:\r\n147 4090453\r\n148 4113951\r\n183 4086825\r\n625 4086841',
 u'paired_end': False,
 u'read_length': 32,
 u'run_date': u'2008-01-04T20:07:16',
 u'sequencer': u'Rotifer (HWI-EAS229)',
 u'sequencer_id': 1}

'/samples/lanes_for/%{username}s/json' will return lanes associated with a particular user, sorted in reverse chronological order.

Example output is below. The run date is in 'iso format', and is actually based on when the record is created in the database, so I'm not sure how accurate the time portion of the date/time is.

[{u'comment': u'',
  u'flowcell': u'42YU5AAXX',
  u'lane_number': 1,
  u'library': u'11216',
  u'run_date': u'2010-01-15T18:49:56'},
 {u'comment': u'',
  u'flowcell': u'42YU5AAXX',
  u'lane_number': 2,
  u'library': u'11218',
  u'run_date': u'2010-01-15T18:49:56'},
]

HtsApi (last edited 2010-01-29 01:08:44 by diane)